FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

Replace resource production asserts with explicit exceptions by huda-code · Pull Request #107 · aboutcode-org/commoncode · GitHub

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

Replace resource production asserts with explicit exceptions#107
huda-code wants to merge 1 commit into
aboutcode-org:mainfrom
huda-code:fix-resource-production-asserts

Conversation

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 file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant


Back | FazBrowse Home | New Git URL