I ran into this bizzare behaviour of dataclasses when intermixed with inheritance/type annotations:
>>> @dataclass
... class Base:
... a: int = 10
...
>>>
>>> @dataclass
... class Derived(Base):
... a = 20
...
>>>
>>> Derived.a
20
>>> Derived().a
10
Note that if I add annotation on a
in Derived
, then things behave reasonably.
What exactly is going on here?