You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
My analysis:
The dumping code is calling Spam's __reduce_ex__method on the class itself and therefore supplies one argument less than needed. Since enum.Enum has a meta class, the normal dumping for type instances is not run.
Adding a representer for enum.EnumMeta is a simple workaround, but I suppose the problem could also be solved by making
the representer for type a multi representer.
The text was updated successfully, but these errors were encountered:
One way or another, this shouldn't be too hard to fix for pyyaml 6.0...
That said- I am curious what you're doing that you're serializing actual types- care to share? Serializing instances of custom enums makes total sense (and works fine), but the tests around serializing language infra are ancient (ie, long-predating enum). I'm sure there are a number of other cases like these (off the top of my head, dataclasses, namedtuples, and anything involving abc probably don't work right either), but they're also not done by the vast majority of users.
I was dumping a quick attempt at an ECS, where types were used as keys in a dict. Essentially, a value is saved in a dict with its type as key.
I was a bit hesitant to open this issue because I knew it is an obscure case.:)
Steps to reproduce:
gives
TypeError: __reduce_ex__() missing 1 required positional argument: 'proto'
in
represent_object(self, data)
.My analysis:
The dumping code is calling
Spam
's__reduce_ex__
method on the class itself and therefore supplies one argument less than needed. Sinceenum.Enum
has a meta class, the normal dumping fortype
instances is not run.Adding a representer for
enum.EnumMeta
is a simple workaround, but I suppose the problem could also be solved by makingthe representer for
type
a multi representer.The text was updated successfully, but these errors were encountered: