Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add "RegressError" to the "regress" module #8

Merged
merged 1 commit into from
Aug 16, 2023

Conversation

sirosen
Copy link
Contributor

@sirosen sirosen commented Aug 16, 2023

By exposing the exception as a module attribute, we ensure that callers can use that name in except clauses.

Without this addition, regress.RegressError can still be raised, but it has a type which can't be referred to by name.

pyo3 docs use PyModule.add(...) in a formulation similar to, but slightly different from, add_class usage.


I noticed this when trying to setup regress to replace the "format": "regex" checker in check-jsonschema. I'll be fine using except Exception for now, but it would be nice to be able to write the exception handler as except regress.RegressError.

By exposing the exception as a module attribute, we ensure that
callers can use that name in `except` clauses.

Without this addition, `regress.RegressError` can still be raised, but
it has a type which can't be referred to by name.

pyo3 docs use `PyModule.add(...)` in a formulation similar to, but
slightly different from, `add_class` usage.
@Julian
Copy link
Member

Julian commented Aug 16, 2023

Nice, thanks!

@Julian Julian merged commit 2f7eeb4 into crate-py:main Aug 16, 2023
@sirosen sirosen deleted the add-regresserr branch August 16, 2023 08:08
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