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
I'm using cattrs to destructure and restructure a complex hierarchy of classes.
It is mostly working.
But I've boiled down one of the failures to this small example.
What I Did
from __future__ import annotations
from dataclasses import dataclass
from cattrs.preconf.json import make_converter
CONV = make_converter()
@dataclass(kw_only=True)
class A:
a: str = ""
@dataclass(kw_only=True)
class B:
b: str = ""
@dataclass(kw_only=True)
class C:
c: int = 3
a_or_b: AorB | None = None
AorB = A | B
def test_c_reconstruction():
c = C(a_or_b=B())
s = CONV.dumps(c)
# attr.exceptions.NotAnAttrsClassError: <class 'tests.test_cattrs_fail.A'> is not an attrs-decorated class.
c2 = CONV.loads(s, C)
The text was updated successfully, but these errors were encountered:
Description
I'm using cattrs to destructure and restructure a complex hierarchy of classes.
It is mostly working.
But I've boiled down one of the failures to this small example.
What I Did
The text was updated successfully, but these errors were encountered: