I'm running into an interesting issue where the value of an enum is a structured value which isn't being properly unstructured and that's causing issues with serialization.
Here's a simple example:
import attrs
import cattrs
import enum
class E(enum.Enum):
A = 0
B = 1
class EE(enum.Enum):
A0 = (E.A, 0)
A1 = (E.A, 1)
B0 = (E.B, 0)
B1 = (E.B, 1)
@attrs.define
class C:
e: E
ee: EE
c = C(e=E.B, ee=EE.A1)
print(cattrs.unstructure(c))
The e attribute of the C class is properly unstructured to a 1 value and the ee attribute is unstructured to the tuple (E.A, 1), but the E.A in that resulting tuple is not unstructured, which causes, for instance, JSON serialization to fail.
I'm running into an interesting issue where the value of an enum is a structured value which isn't being properly unstructured and that's causing issues with serialization.
Here's a simple example:
The
eattribute of theCclass is properly unstructured to a1value and theeeattribute is unstructured to the tuple(E.A, 1), but theE.Ain that resulting tuple is not unstructured, which causes, for instance, JSON serialization to fail.