-
-
Notifications
You must be signed in to change notification settings - Fork 114
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
Unstructuring subclasses #354
Comments
A little difficult to answer these without concrete examples. I think #312 is a better bet than the old snippets since it's a more sophisticated approach, and it's a better base for experimentation. |
Thanks for your reply! The code example is really just your code + the future import:
However, I've now also tested with python 3.11 and there everything works as expected! So the issue seems really related to how the future imports are handled in older python versions 🤔 Nonetheless, it might be worth mentioning this somewhere in the docs once one of us figures out the source of the problem... |
Description
Hi @Tinche, I am currently working on several projects where I need to (un)structure objects of subclasses of a common base class. Digging through the documentation and also some issues here on Github, I eventually found your example how this can be done with the current version of cattrs. However, I think I have found two problems (bugs? unsupported features?) with the approach and would love to hear your opinion.
But before I go into the details, a quick question upfront: Is this going to remain the "recommended" approach to unstructure objects from a class hierarchy? I am asking because I also saw #312 which seems about to be merged but I am not entirely sure how/if it's going to replace your described method.
So here are now the two issues I noticed:
slotted=False
. I guess this is probably due to due the changes defaults (see also Weird output while structuring unions with custom disambiguation function #267)? On the other hand, I wonder why your example then originally worked because it already usesdefine
instead ofattr.s
?from __future__ import annotations
and throws the following exception:Is the second issue related to #215 or is this a bug?
The text was updated successfully, but these errors were encountered: