pyo3 icon indicating copy to clipboard operation
pyo3 copied to clipboard

Collecting multiple attribute error

Open Cheukting opened this issue 1 year ago • 1 comments

~~Attempt to clos e #2892~~ (Edit by @davidhewitt - I think there's more we can do with #[pymethods] probably, though might be a fair bit more work.)

I am not sure how to add the test in CI but I have tested manually with the following:

use pyo3::prelude::*;

#[pyclass]
struct Example {
    #[pyo3(foo)]
    #[pyo3(blah)]
    x: i32,
    #[pyo3(pop)]
    y: i32,
}

Originally it gave:

error: expected one of: `get`, `set`, `name`
 --> pytests/src/pyclasses.rs:7:12
  |
7 |     #[pyo3(foo)]
  |            ^^^

error: cannot find attribute `pyo3` in this scope
  --> pytests/src/pyclasses.rs:10:7
   |
10 |     #[pyo3(pop)]
   |       ^^^^
   |
   = note: `pyo3` is in scope, but it is a crate, not an attribute

error: could not compile `pyo3-pytests` (lib) due to 2 previous errors

Now it gives:

error: expected one of: `get`, `set`, `name`
 --> pytests/src/pyclasses.rs:7:12
  |
7 |     #[pyo3(foo)]
  |            ^^^

error: expected one of: `get`, `set`, `name`
 --> pytests/src/pyclasses.rs:8:12
  |
8 |     #[pyo3(blah)]
  |            ^^^^

error: expected one of: `get`, `set`, `name`
  --> pytests/src/pyclasses.rs:10:12
   |
10 |     #[pyo3(pop)]
   |            ^^^

error: could not compile `pyo3-pytests` (lib) due to 3 previous errors

Cheukting avatar Jun 13 '24 09:06 Cheukting

Thanks for the suggestions @davidhewitt i have added the test and have refactored as suggested.

Cheukting avatar Jun 14 '24 17:06 Cheukting

Thank you for your patience. I was busy with EuroPython. I plan to finish this PR this weekend or next week.

Cheukting avatar Jul 13 '24 07:07 Cheukting

(I took the liberty to fix the new merge conflicts.)

davidhewitt avatar Jul 20 '24 06:07 davidhewitt

Thank you @davidhewitt

Cheukting avatar Jul 20 '24 16:07 Cheukting