Skip to content

unify IntoPyObject/FromPyObject derive attributes #5070

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

Merged
merged 1 commit into from
May 4, 2025
Merged

Conversation

Icxolu
Copy link
Contributor

@Icxolu Icxolu commented Apr 12, 2025

This combines the attributes of the IntoPyObject and FromPyObject derive macros, such that individual options can still be used when deriving both.

Closes #4884

@Icxolu Icxolu force-pushed the fix/4884 branch 3 times, most recently from 11313a0 to bb3560d Compare April 12, 2025 10:56
@davidhewitt davidhewitt mentioned this pull request May 2, 2025
Copy link
Member

@davidhewitt davidhewitt left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks, this looks great to me! It's slightly unfortunate that if a user writes just #[derive(IntoPyObject)] and then adds a load of attributes only specific to #[derive(FromPyObject)] they are (often) just silently ignored, but it seems there is no better alternative (and the same as serde).

Comment on lines +20 to +21
/// Converts the field idents according to the [RenamingRule](attributes::RenamingRule) before extraction
RenameAll(RenameAllAttribute),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this be supported for IntoPyObject? I guess a separate follow-up issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably, will have a look 👍

@Icxolu Icxolu enabled auto-merge May 4, 2025 20:50
@Icxolu Icxolu added this pull request to the merge queue May 4, 2025
Merged via the queue into PyO3:main with commit c25c6f7 May 4, 2025
42 of 44 checks passed
@Icxolu Icxolu deleted the fix/4884 branch May 4, 2025 21:57
@bbstilson
Copy link

@davidhewitt any idea which release this will release in?

@davidhewitt
Copy link
Member

See #5107

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

limited pyo3 options when deriving both FromPyObject and IntoPyObject?
3 participants