Hi,
I'm trying to overwrite a required attributed of the parent class using a default value in the subclass, but it looks like dataclass is ignoring it.
Here is an example where I attempt to overwrite a in the parent class:
from dataclasses import dataclass
@dataclass(kw_only=True)
class Parent:
a: str # Required field to be populated by subclass
b: float
c: bool = False
@dataclass(kw_only=True)
class Subclass(Parent):
a = 'bob'
x = Subclass(b=3.14)
Error produced
TypeError: Subclass.__init__() missing 1 required keyword-only argument: 'a'
It would be ideal if I could do this without involving __init__(...) or __post_init__(...) in the subclass as the actual use case has a lot more parameters, some of them nested objects.