We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
As a result of the (upcoming) changes in 0.22 and 0.23 with Option<T> arguments requiring a #[pyo3(signature=...)] link to migration guide.
Option<T>
#[pyo3(signature=...)]
This causes a problem for setters of a pyclass, which can be erased by setting None, since you're not allowed to specify a signature on a setter.
pyclass
None
This is caused by #2935. In this case, I do not need a default argument. However, it will be required in version 0.23.
use pyo3::prelude::*; #[pyclass] struct SimpleClass { field: Option<u32> } #[pymethods] impl SimpleClass { #[new] #[pyo3(signature = (value=None))] fn new(field: Option<u32>) -> Self { Self { field } } #[getter] fn get_field(&self) -> Option<u32> { self.field } /// This causes issues #[setter] fn set_field((&mut self, field: Option<u32>) { self.field = field; } }
No response
Windows/Linux (All effected)
python --version
Python 3.10.12
rustc --version
rustc 1.79.0 (129f3b996 2024-06-10)
0.22+
apt + venv
This currently causes non-removable warnings, however in the future this will break code.
EDIT: Added more information
The text was updated successfully, but these errors were encountered:
After some digging, I found a possible solution, which is to check the function type to not be a setter method here.
pyo3/pyo3-macros-backend/src/deprecations.rs
Lines 53 to 60 in 8f7450e
This can probably be done by adding && !matches!(spec.tp, FnType::Setter(_)).
&& !matches!(spec.tp, FnType::Setter(_))
But I am not sure if an error will occur in 0.23 as a result of something somewhere else.
Sorry, something went wrong.
#[setter]
Successfully merging a pull request may close this issue.
Bug Description
As a result of the (upcoming) changes in 0.22 and 0.23 with
Option<T>
arguments requiring a#[pyo3(signature=...)]
link to migration guide.This causes a problem for setters of a
pyclass
, which can be erased by settingNone
, since you're not allowed to specify a signature on a setter.This is caused by #2935. In this case, I do not need a default argument.
However, it will be required in version 0.23.
Steps to Reproduce
Backtrace
No response
Your operating system and version
Windows/Linux (All effected)
Your Python version (
python --version
)Python 3.10.12
Your Rust version (
rustc --version
)rustc 1.79.0 (129f3b996 2024-06-10)
Your PyO3 version
0.22+
How did you install python? Did you use a virtualenv?
apt + venv
Additional Info
This currently causes non-removable warnings, however in the future this will break code.
EDIT: Added more information
The text was updated successfully, but these errors were encountered: