Replace ASSERT statements with if statements #175#60
Replace ASSERT statements with if statements #175#60shafi456 wants to merge 2 commits intoaboutcode-org:mainfrom
Conversation
pombredanne
left a comment
There was a problem hiding this comment.
Same as for your other PR: https://aboutcode.readthedocs.io/en/latest/contributing/writing_good_commit_messages.html
src/container_inspector/cli.py
Outdated
| def _container_inspector_squash(image_path, extract_directory): | ||
| images = get_images_from_dir_or_tarball(image_path) | ||
| assert len(images) == 1, 'Can only squash one image at a time' | ||
| if(len(images) == 1): raise ValueError("Can only squash one image at a time") |
There was a problem hiding this comment.
no one liner please, and check your code formatting.
There was a problem hiding this comment.
sorry I thought if extra lines were added it might clash or smth.
There was a problem hiding this comment.
Used the imperative mood in the message and changed the code(No one liners).
pombredanne
left a comment
There was a problem hiding this comment.
The tests are failing. The logic is not correct, as the assert is now inverted. Also please squash your commits and add missing DCO signoff. Please run the test and review the code you are pushing twice before pushing. ;)
| def _container_inspector_squash(image_path, extract_directory): | ||
| images = get_images_from_dir_or_tarball(image_path) | ||
| assert len(images) == 1, 'Can only squash one image at a time' | ||
| if(len(images) == 1): |
There was a problem hiding this comment.
Is the code formatted? Is this if statement correct?
You need to have a hard look, and if need be, also add a test that passes before making this change.
Replace ASSERT statements with if statements #175
Reported by: pombredanne aboutcode-org/aboutcode#175
Replace assert with explicit exception handling
Raise ValueError if inputs are invalid
Signed-off-by: Shafi456 shafiul.azam@g.bracu.ac.bd