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
The following code does not throw errors in 0.730, but does in 0.740. Likely to do with #7723
classA:
def__init_subclass__(cls, *args, **kwargs):
super().__init_subclass__(*args, **kwargs)
classB(A):
pass# error: Too few arguments for "__init_subclass__"
And slightly more complicated, a self registering subclass:
fromtypingimportClassVar, List, TypeclassA:
registered_classes: ClassVar[List[Type["A"]]] = []
def__init_subclass__(cls, *args, register=True, **kwargs):
ifregister:
cls.registered_classes.append(cls)
super().__init_subclass__(*args, **kwargs)
classB(A):
passclassC(A, register=False):
passclassD(C):
passprint(A.registered_classes) # >>> [<class '__main__.B'>, <class '__main__.D'>]# 13: error: Too few arguments for "__init_subclass__"# 17: error: Missing positional argument "cls" in call to "__init_subclass__"# 21: error: Too few arguments for "__init_subclass__"
Reacted by Marat Sharafutdinov, Hugo Dupras, nwalsh1995 and Eugene
Activity
ilevkivskyi commentedon Oct 17, 2019
Thanks for reporting! This is quite subtle issue, #7739 should fix this.
Don't use mypy 0.740
Don't use mypy 0.740 (#1616)
Fix accessing unannotated implicit class methods (#7739)
tdamsma commentedon Oct 20, 2019
@ilevkivskyi Thanks for the quick fix!