Closed
Description
Mypy seems to always assume that classes have all fields defined in their superclass' __init__
method, even if their own __init__
never calls the superclass constructor and those fields therefore don't exist.
class A:
def __init__(self) -> None:
self.a = 12
class B(A):
def __init__(self) -> None:
self.b = 14
def m() -> int:
ab = B()
return ab.a + ab.b # accepted by mypy, but fails at runtime
Metadata
Metadata
Assignees
Labels
No labels