Mypy produce an error with this dataclass inheritance:
import dataclasses
import datetime
import typing
@dataclasses.dataclass
class Crud:
creation_datetime: typing.Optional[datetime.datetime] = dataclasses.field(init=False)
def __post_init__(self) -> None:
self.creation_datetime = getattr(self, "creation_datetime", datetime.datetime.utcnow())
@dataclasses.dataclass
class MyFoo(Crud):
name: str
t.py:17: error: Attributes without a default cannot follow attributes with one
Does exist a way to supress this error or design the code differently to avoid mypy error ?