I think it makes sense to add tests that check that dataclasses interact nicely with typing.Generic and type variables. Most likely no changes is needed to the code (only tests) since we use a decorator @dataclass. But still Generic uses a complex metaclass (this will be removed if/when PEP 560 is accepted and replaced with __init_subclass__ and new friends).
I think it makes sense to add tests checking that things like this work:
@dataclass
class LabeledBox(Generic[T]):
content: T
label: str = '<unknown>'
box = LabeledBox(42)
assert box.content == 42
assert box.label == '<unknown>'
boxes: List[LabeledBox[int]] = [] # subscripting the resulting class should work, etc.
I think it makes sense to add tests that check that dataclasses interact nicely with
typing.Generic
and type variables. Most likely no changes is needed to the code (only tests) since we use a decorator@dataclass
. But stillGeneric
uses a complex metaclass (this will be removed if/when PEP 560 is accepted and replaced with__init_subclass__
and new friends).I think it makes sense to add tests checking that things like this work: