Skip to content

Replace assert statements with explicit exception handling in non-test files - #591

Merged
chinyeungli merged 1 commit into
aboutcode-org:developfrom
Bhoomi-bombom:develop
Dec 22, 2025
Merged

Replace assert statements with explicit exception handling in non-test files#591
chinyeungli merged 1 commit into
aboutcode-org:developfrom
Bhoomi-bombom:develop

Conversation

@Bhoomi-bombom

Copy link
Copy Markdown
Contributor

Summary

This pull request replaces all assert statements in non-test Python files with explicit exception handling.
The goal is to prevent loss of runtime validation when Python is executed in optimized mode (-O flag), where assert statements are ignored.

Changes Made

Replaced assert statements with appropriate ValueError or RuntimeError exceptions.

Added clear and descriptive error messages for better debugging.

Ensured no modifications were made in test-related files or documentation.

References

Fixes issue: Replace and rewrite "assert" statements in non-test code (#175)

Discussed in: GitHub search and discussion on assert usage

Testing

Verified the changes by running existing unit tests to ensure no regressions.

Confirmed all modified functions raise appropriate exceptions when invalid inputs are provided.

Signed-off-by: bhoomi-bombom <bhoomi.annamdevara2006@gmail.com>
@chinyeungli

Copy link
Copy Markdown
Contributor

Thanks @Bhoomi-bombom looks good to me

@chinyeungli
chinyeungli merged commit 49c2657 into aboutcode-org:develop Dec 22, 2025
2 checks passed
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.

2 participants