-
Notifications
You must be signed in to change notification settings - Fork 760
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
Allow #[name]
with #[getter]
and #[setter]
#1507
Conversation
Thanks, this seems reasonable to me. I would actually like to ask your opinion on a further change relating to this. I was thinking of moving the This could compose with So the options would be #[pymethods]
impl Foo {
#[getter(custom_name)]
fn get_foo(&self) { }
// or
#[pyo3(getter, name = "custom_name")]
fn get_bar(&self) { }
} The later one is longer, but I think much clearer what is going on. |
Would you want to also allow multiple #[pyo3(getter)]
#[pyo3(name="custom_name")]
fn foo(&self) -> i32 { ... { If yes, then that’s definitely a change I would support. This avoids clashing with other proc macros and adds uniformity with the existing The ability to have the two attributes separately makes my life easier when generating code: in my case, adding a |
Yes; we allow that for |
Awesome! Are you willing to support the new syntax now in this PR, or you want to leave this PR as-is and I'll make a change to use the new syntax soon? |
Well, to be honest I’m in lack of a personal computer right now so my ability to write code in my free time is severely decreased :) |
👍 let's merge this PR and I'll write the follow-up! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
I think it can be better, but first, shouldn't we summarize what is under the |
A custom name can now be specified either via
#[getter(custom_name)]
or#[name = "custom_name"]
like normal methods.It's easier to have this kind of uniformity when dealing with code generation.