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
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
Same result with both master mypy 0.710+dev.44172caa122b01af5a63ec5787931b910f272eb6 and latest stable mypy 0.701 using Python 3.7.0.
The text was updated successfully, but these errors were encountered:
antonagestam
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
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.
ilevkivskyi
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
Jun 18, 2019
In the code below I expected both subclasses to raise errors due to overriding method marked with
@final
, but only theB
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.setup.cfg:
Same result with both master
mypy 0.710+dev.44172caa122b01af5a63ec5787931b910f272eb6
and latest stablemypy 0.701
using Python 3.7.0.The text was updated successfully, but these errors were encountered: