Skip to content

Replace resource production asserts with explicit exceptions - #107

Open
huda-code wants to merge 1 commit into
aboutcode-org:mainfrom
huda-code:fix-resource-production-asserts
Open

huda-code wants to merge 1 commit into
aboutcode-org:mainfrom
huda-code:fix-resource-production-asserts

Conversation

@huda-code

Copy link
Copy Markdown

Contributes to aboutcode-org/aboutcode#175

This PR replaces production assert statements in commoncode/resource.py with explicit runtime exceptions.

Changes:

  • Replaced file existence assert with FileNotFoundError
  • Replaced path type assert with TypeError
  • Replaced root location validation assert with ValueError
  • Replaced empty path assert with ValueError
  • Kept pytest/test asserts and docstring examples unchanged

Why:
Production asserts can be skipped when Python is run with optimization flags (-O / -OO). Explicit exceptions ensure runtime validation is preserved consistently.

Tested with:
PYTHONPATH=src python3 -m pytest tests/test_resource.py

Signed-off-by: HudaHajira <hudahajira744@gmail.com>

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

1 participant