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
{{ message }}
Repository navigation
Struct that contains an Enum property with a metaclass cant be decoded #822
I don't know if this is a bug, or just something that can't be supported. I've reviewed some of the other issues surrounding metaclasses and it seems there isn't a workaround.
This case is a little different though, my classes which inherit from Struct do not define a metaclass - but instead they have a property which is a subclass of Enum with a metaclass.
I put together a minimal reproducible example. Is it possible to support this use case?
I'm having a similar issue when using msgspec with django TextChoices.
A minimal reproducible example:
importmsgspecfromdjango.dbimportmodelsclassSomeEnum(models.TextChoices): # class TextChoices(str, enum.Enum, metaclass=ChoicesMeta)EXAMPLE_VALUE="hello"classSomeModel(msgspec.Struct):
values: SomeEnummsgspec.json.encode(SomeModel(SomeEnum.EXAMPLE_VALUE))
# TypeError: Encoding objects of type SomeEnum is unsupported
I'd love to give some help if it makes sense for this
Activity
UnknownPlatypus commentedon Mar 11, 2025
I'm having a similar issue when using msgspec with django TextChoices.
A minimal reproducible example:
I'd love to give some help if it makes sense for this