You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
classA:
def__init__(self) ->None:
self.a=12classB(A):
def__init__(self) ->None:
self.b=14defm() ->int:
ab=B()
returnab.a+ab.b# accepted by mypy, but fails at runtime
The text was updated successfully, but these errors were encountered:
Thank you for reporting this! I think, it is an example of known behaviour: mypy does not check whether a variable was actually defined, it only checks that a variable was declared, see e.g. #2400
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.The text was updated successfully, but these errors were encountered: