Feature
Right now mypy does not support proper __post_init__ signatures.
For example:
import dataclasses
@dataclasses.dataclass
class My:
x: int
y: dataclasses.InitVar[str] = 'a'
For now, mypy will allow a lot of incorrect code to slip in:
def __post_init__(self, y: str) -> str: ..., which needs to return None
def __post_init__(self, y: int) -> None: ..., which has incorrect type for y
def __post_init__(self) -> None: ..., which has no y
def __post_init__(self, x: int, y: str) -> None: ..., which has extra x param
Pitch
We can easily support this feature and make sure that __post_init__ signature is always correct for a dataclass.
Feature
Right now
mypydoes not support proper__post_init__signatures.For example:
For now,
mypywill allow a lot of incorrect code to slip in:def __post_init__(self, y: str) -> str: ..., which needs to returnNonedef __post_init__(self, y: int) -> None: ..., which has incorrect type forydef __post_init__(self) -> None: ..., which has noydef __post_init__(self, x: int, y: str) -> None: ..., which has extraxparamPitch
We can easily support this feature and make sure that
__post_init__signature is always correct for a dataclass.