Skip to content

Is it possible to use from_py_with when deriving both FromPyObject and IntoPyObject? #4883

Answered by Icxolu
baxtersa asked this question in Questions
Discussion options

You must be logged in to vote

I agree this should be supported and would consider this a bug on PyO3s side. The problem here is that derive macros declare the same
#[pyo3] attribute and thus get passed the same set of options. However they both only accept a subset of all options and reject everything else, i.e. IntoPyObject does not know what to do with from_py_with. So this problem is present for all attributes that are not common between these two.

Currently I can see two ways to solve this:

  • We could just accept unknown/all pyo3 options. I think this is what serde does. This would solve the error, but the experience around single derive and meaningless options is a bit worse.
  • We could have different top-level attr…

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@baxtersa
Comment options

Answer selected by baxtersa
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
2 participants