-
Notifications
You must be signed in to change notification settings - Fork 751
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
#[pyfunction]
inside #[pymethods]
could emit a better error
#4340
Labels
Comments
csernazs
added a commit
to csernazs/pyo3
that referenced
this issue
Jul 14, 2024
Fixes PyO3#4340 Co-authored-by: László Vaskó <[email protected]>
csernazs
added a commit
to csernazs/pyo3
that referenced
this issue
Jul 14, 2024
Make error message more specific when `#[pyfunction]` is used in `#[pymethods]`. Effectively, this replaces the error message: ``` error: static method needs #[staticmethod] attribute ``` To: ``` functions inside #[pymethods] do not need to be annotated with #[pyfunction] ``` Fixes PyO3#4340 Co-authored-by: László Vaskó <[email protected]>
csernazs
added a commit
to csernazs/pyo3
that referenced
this issue
Jul 14, 2024
Make error message more specific when `#[pyfunction]` is used in `#[pymethods]`. Effectively, this replaces the error message: ``` error: static method needs #[staticmethod] attribute ``` To: ``` functions inside #[pymethods] do not need to be annotated with #[pyfunction] ``` Fixes PyO3#4340 Co-authored-by: László Vaskó <[email protected]>
csernazs
added a commit
to csernazs/pyo3
that referenced
this issue
Jul 14, 2024
Make error message more specific when `#[pyfunction]` is used in `#[pymethods]`. Effectively, this replaces the error message: ``` error: static method needs #[staticmethod] attribute ``` To: ``` functions inside #[pymethods] do not need to be annotated with #[pyfunction] ``` Fixes PyO3#4340 Co-authored-by: László Vaskó <[email protected]>
csernazs
added a commit
to csernazs/pyo3
that referenced
this issue
Jul 14, 2024
Make error message more specific when `#[pyfunction]` is used in `#[pymethods]`. Effectively, this replaces the error message: ``` error: static method needs #[staticmethod] attribute ``` To: ``` functions inside #[pymethods] do not need to be annotated with #[pyfunction] ``` ...and also removes the other misleading error messages to the function in question. Fixes PyO3#4340 Co-authored-by: László Vaskó <[email protected]>
csernazs
added a commit
to csernazs/pyo3
that referenced
this issue
Jul 16, 2024
Make error message more specific when `#[pyfunction]` is used in `#[pymethods]`. Effectively, this replaces the error message: ``` error: static method needs #[staticmethod] attribute ``` To: ``` functions inside #[pymethods] do not need to be annotated with #[pyfunction] ``` ...and also removes the other misleading error messages to the function in question. Fixes PyO3#4340 Co-authored-by: László Vaskó <[email protected]>
github-merge-queue bot
pushed a commit
that referenced
this issue
Jul 24, 2024
…4349) * Improve error messages for #[pyfunction] defined inside #[pymethods] Make error message more specific when `#[pyfunction]` is used in `#[pymethods]`. Effectively, this replaces the error message: ``` error: static method needs #[staticmethod] attribute ``` To: ``` functions inside #[pymethods] do not need to be annotated with #[pyfunction] ``` ...and also removes the other misleading error messages to the function in question. Fixes #4340 Co-authored-by: László Vaskó <[email protected]> * review fixes --------- Co-authored-by: László Vaskó <[email protected]>
davidhewitt
pushed a commit
that referenced
this issue
Sep 3, 2024
…4349) * Improve error messages for #[pyfunction] defined inside #[pymethods] Make error message more specific when `#[pyfunction]` is used in `#[pymethods]`. Effectively, this replaces the error message: ``` error: static method needs #[staticmethod] attribute ``` To: ``` functions inside #[pymethods] do not need to be annotated with #[pyfunction] ``` ...and also removes the other misleading error messages to the function in question. Fixes #4340 Co-authored-by: László Vaskó <[email protected]> * review fixes --------- Co-authored-by: László Vaskó <[email protected]>
davidhewitt
pushed a commit
that referenced
this issue
Sep 15, 2024
…4349) * Improve error messages for #[pyfunction] defined inside #[pymethods] Make error message more specific when `#[pyfunction]` is used in `#[pymethods]`. Effectively, this replaces the error message: ``` error: static method needs #[staticmethod] attribute ``` To: ``` functions inside #[pymethods] do not need to be annotated with #[pyfunction] ``` ...and also removes the other misleading error messages to the function in question. Fixes #4340 Co-authored-by: László Vaskó <[email protected]> * review fixes --------- Co-authored-by: László Vaskó <[email protected]>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Consider this code:
The
#[pyfunction]
inside#[pymethods]
is an innocent user error that I've seen by folks new to PyO3. At the moment this creates a load of confusing garbage errors (due to the#[pyfunction]
implementation details):Click to show error details
We should be able to detect the
#[pyfunction]
attribute the same way declarative modules detect#[pyclass]
/#[pyfunction]
/#[pymodule]
attributes. In this case, we should emit a helpful error like "functions inside#[pymethods]
do not need to be annotated with#[pyfunction]
".I think this is a good first issue for someone wanting to improve the macro code.
The text was updated successfully, but these errors were encountered: