Skip to content

Commit 5fb35eb

Browse files
committed
Fix #175: Replace unsafe assert statements with explicit exceptions
Signed-off-by: RAJATSINGH <rajat.singh20242@lpu.in>
1 parent 5c654da commit 5fb35eb

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

src/container_inspector/cli.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ def container_inspector_squash(image_path, extract_directory):
4141

4242
def _container_inspector_squash(image_path, extract_directory):
4343
images = get_images_from_dir_or_tarball(image_path)
44-
assert len(images) == 1, 'Can only squash one image at a time'
44+
if len(images) != 1:
45+
raise ValueError('Can only squash one image at a time')
4546
img = images[0]
4647
target_loc = os.path.abspath(os.path.expanduser(extract_directory))
4748
rootfs.rebuild_rootfs(img, target_loc)
@@ -61,7 +62,8 @@ def container_inspector_dockerfile(directory, json=False, csv=False):
6162

6263

6364
def _container_inspector_dockerfile(directory, json=False, csv=False):
64-
assert json or csv, 'At least one of --json or --csv is required.'
65+
if not (json or csv):
66+
raise ValueError('At least one of --json or --csv is required.')
6567
dir_loc = os.path.abspath(os.path.expanduser(directory))
6668

6769
dockerfiles = dockerfile.collect_dockerfiles(location=dir_loc)

0 commit comments

Comments
 (0)