-
Notifications
You must be signed in to change notification settings - Fork 830
add exception hierarchy pytests #3475
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
base: main
Are you sure you want to change the base?
Conversation
pytests/src/exceptions.rs
Outdated
|
||
#[pymethods] | ||
impl CustomException { | ||
#[new(signature = (*_args, **_kwargs))] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wrote a bug here which confused me for a bit; #[new]
ignores signature
.
Either this should be a hard error or it should be equivalent to #[new] #[pyo3(signature = (*_args, **_kwargs))]
.
6b8fbe8
to
e4a86e6
Compare
@stinodego did you have any luck with an exception hierarchy on the polars side? I think this is a baseline which you might be able to start from, I think the most practical way forward is that if you try implementing what you want starting from this, please report back on your experience and we can fix any issues or papercuts. |
I haven't worked on this since I opened the issue - I'll take this as a template and try to set it up for Polars! Sometime next week probably. Will let you know my findings. |
Apologies for getting back to this so late. When I try to adapt this for Polars, I get an error that |
Is polars using the |
Ah that's right - we are using the I have been able to get a basic version of a hierarchy working through the create_exception!(polars.exceptions, PolarsBaseError, PyException);
create_exception!(polars.exceptions, ComputeError, PolarsBaseError);
create_exception!(polars.exceptions, ColumnNotFoundError, PolarsBaseError); Though the setup in this PR definitely looks nicer and more powerful. |
In the long run I would like to deprecate the |
WIP solution for #3452
The goal here is to get examples and documentation working for how to create a Python exception hierarchy and interact with it from Rust. This will probably go through a few rounds of rebases as features / bugfixes inspired by it will be opened as separate PRs.