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

fix #[pyclass] could not be named Probe #4794

Merged
merged 1 commit into from
Dec 12, 2024
Merged

Conversation

Icxolu
Copy link
Contributor

@Icxolu Icxolu commented Dec 12, 2024

Fixes #[pyclass] could not be named Probe.

Closes #4792

@Icxolu Icxolu added the bugfix label Dec 12, 2024
@LilyFoote LilyFoote enabled auto-merge December 12, 2024 18:36
@LilyFoote LilyFoote added this pull request to the merge queue Dec 12, 2024
Merged via the queue into PyO3:main with commit 603a55f Dec 12, 2024
46 checks passed
@Icxolu Icxolu deleted the fix/4792 branch December 12, 2024 21:52
davidhewitt pushed a commit that referenced this pull request Jan 3, 2025

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
davidhewitt pushed a commit that referenced this pull request Jan 11, 2025
epontan added a commit to epontan/pyo3 that referenced this pull request Mar 17, 2025
Commit 603a55f ("fix `#[pyclass]` could not be named `Probe`
(PyO3#4794)") fixed the issue where it was not possible to define a class
named `Probe`. However, similar issue exists when trying to add
`#[pymethods]` implementations to the `Probe` class. It generates
similar confusing errors as the original issue (PyO3#4792), due to the
internal `Probe` trait being in scope at the user code:

  error[E0782]: expected a type, found a trait
  help: you can add the `dyn` keyword if you want a trait object
  * | impl dyn Probe {

Fix the issue by avoiding pollution of the imports from the macro
expansion and instead use qualified path to the internal types.
epontan added a commit to epontan/pyo3 that referenced this pull request Mar 17, 2025
Commit 603a55f ("fix `#[pyclass]` could not be named `Probe`
(PyO3#4794)") fixed the issue where it was not possible to define a class
named `Probe`. However, similar issue exists when trying to add
`#[pymethods]` implementations to the `Probe` class. It generates
similar confusing errors as the original issue (PyO3#4792), due to the
internal `Probe` trait being in scope at the user code:

  error[E0782]: expected a type, found a trait
  help: you can add the `dyn` keyword if you want a trait object
  # | impl dyn Probe {

Fix the issue by avoiding pollution of the imports from the macro
expansion and instead use qualified path to the internal types.
github-merge-queue bot pushed a commit that referenced this pull request Mar 17, 2025
Commit 603a55f ("fix `#[pyclass]` could not be named `Probe`
(#4794)") fixed the issue where it was not possible to define a class
named `Probe`. However, similar issue exists when trying to add
`#[pymethods]` implementations to the `Probe` class. It generates
similar confusing errors as the original issue (#4792), due to the
internal `Probe` trait being in scope at the user code:

  error[E0782]: expected a type, found a trait
  help: you can add the `dyn` keyword if you want a trait object
  # | impl dyn Probe {

Fix the issue by avoiding pollution of the imports from the macro
expansion and instead use qualified path to the internal types.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Confusing error message when using #[pyclass] with a struct called Probe
2 participants