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
{{ message }}
Repository navigation
Overriding final method only raises error if overriding method is annotated #7015
In the code below I expected both subclasses to raise errors due to overriding method marked with @final, but only the B class raises an error, it seems like adding the return type annotation triggers the check. The same behavior is not specific to __init__ but happens with any method name.
fromtyping_extensionsimportfinalclassBase:
@finaldef__init__(self):
passclassA(Base):
def__init__(self): # no error raisedpassclassB(Base):
def__init__(self) ->None: # raises an errorpass
changed the title [-]Bug: Final __init__ only raises error if sub-class __init__ is annotated [/-][+]Bug: Overriding final method only raises error if overriding method is annotated [/+]on Jun 18, 2019
changed the title [-]Bug: Overriding final method only raises error if overriding method is annotated [/-][+]Overriding final method only raises error if overriding method is annotated [/+]on Jun 18, 2019
Activity
[-]Bug: Final __init__ only raises error if sub-class __init__ is annotated [/-][+]Bug: Overriding final method only raises error if overriding method is annotated [/+]ilevkivskyi commentedon Jun 18, 2019
Yes, indeed, this happens with all methods, not just
__init__(). I think mypy should give an error even for non-annotated methods.[-]Bug: Overriding final method only raises error if overriding method is annotated [/-][+]Overriding final method only raises error if overriding method is annotated [/+]