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

introduce into_py_with/into_py_with_ref for #[derive(IntoPyObject, IntoPyObjectRef)] #4850

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

Icxolu
Copy link
Contributor

@Icxolu Icxolu commented Jan 10, 2025

This adds #[pyo3(into_py_with = ..., into_py_with_ref = ...)] field options to the #[derive(IntoPyObject, IntoPyObjectRef)] derive macros as a complement to #[pyo3(from_py_with= ...)] of #[derive(FromPyObject)].

This allows simple customization of the generated implementation, which allows (for example) the usage of the derive macro in cases where one or more fields do not implement IntoPyObject themselves.

One notable difference in the current implementation compared to from_py_with is the type of the argument. from_py_with takes it's argument via a string (mostly for historical reasons I believe), into_py_with takes it directly as a path, which has the advantage that we get better IDE support (proper syntax highlighting and autocomplete). For consistency I would propose to switch over from_py_with to the path syntax in a followup.

@Icxolu

This comment was marked as resolved.

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

Successfully merging this pull request may close these issues.

1 participant