Skip to content

Incorrect __post_init__ order when KW_ONLY used #17564

Description

@NeilGirdhar
fromdataclassesimportdataclass, InitVar, KW_ONLY@dataclassclassA:
_: KW_ONLYx: InitVar[int]
def__post_init__(self, x: int) ->None:
pass@dataclassclassC(A):
y: InitVar[str]
def__post_init__(self, x: int, y: str) ->None: # Correct order.super().__post_init__(x)

gives

a.py:19: error: Argument 2 of "__post_init__" is incompatible with supertype "dataclass"; supertype defines the argument type as "str" [override]
def __post_init__(self, x: int, y: str) -> None:
^~~~~~
a.py:19: error: Argument 3 of "__post_init__" is incompatible with supertype "dataclass"; supertype defines the argument type as "int" [override]
def __post_init__(self, x: int, y: str) -> None:

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugmypy got something wrong

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions