`#[pyo3(get)]` and `#[getter]` on same field silently collide
Open
Nobody has claimed this yet.
- Dominant language
- Rust
- Stars
- 16.2k
- Forks
- 1k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 66
Description
The following code compiles without issue. I would expect we should either fail to compile or report an error when initializing the type object. Compile error probably leads to better UX, as long as the compiler error is meaningful enough.
#[pyclass]
pub struct Object {
#[pyo3(get)]
x: u32,
}
#[pymethods]
impl Object {
#[getter]
fn x(&self) -> u32 {
self.x
}
}
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided #[pyclass], #[pyo3(get)], and #[getter] reproducer and trace how the two attributes generate the type's accessors. The work is done when the collision is detected and produces a meaningful compile-time or type-initialization error, with coverage for this example.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python, rust
- Domain
- api, backend-api-design
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Quiet
- Clarity
- Mostly clear
- Newbie friendliness
- 48/100