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 is giving an error Too many arguments for "<class>" if cls argument is used for creating object in a classmethod that is defined before __init__. I would expect this to work as similar constructs (see below) work.
The case for having separate class method create is to allow doing some initializations in certain cases (when the classmethod is called) but not in others (when the __init__ is called). The example code is not complete in that sense but is enough to demonstrate the issue I faced.
Used versions:
Mypy: 0.620 and 0.630+dev-132dfa264e983a0c566f3fa6f316cde27afff131, i.e. the latest version from master branch
Python: 3.6 and 3.7 (haven't tried others)
The output from mypy example.py: example.py:4: error: Too many arguments for "A" for the code below:
The code below contains similar constructs (in addition to the case above) that do not cause mypy to report errors, i.e. the only reported error is from create1 class method (and the error is the same as in the above code):
deffoo() ->A:
returnbar(9)
defbar(value: int) ->A:
returnA(value)
classA:
# The only error is reported from this class method@classmethoddefcreate1(cls) ->A:
returncls(0)
@classmethoddefcreate2(cls) ->A:
returnA(0)
@staticmethoddefcreate3() ->A:
returnA(1)
def__init__(self, arg: int) ->None:
self.arg=arg@classmethoddefcreate4(cls) ->A:
returncls(0)
@classmethoddefcreate5(cls) ->A:
returnA(0)
@staticmethoddefcreate6() ->A:
returnA(1)
The text was updated successfully, but these errors were encountered:
Mypy is giving an error
Too many arguments for "<class>"
if cls argument is used for creating object in a classmethod that is defined before __init__. I would expect this to work as similar constructs (see below) work.The case for having separate class method create is to allow doing some initializations in certain cases (when the classmethod is called) but not in others (when the __init__ is called). The example code is not complete in that sense but is enough to demonstrate the issue I faced.
Used versions:
The output from
mypy example.py
:example.py:4: error: Too many arguments for "A"
for the code below:The code below contains similar constructs (in addition to the case above) that do not cause mypy to report errors, i.e. the only reported error is from create1 class method (and the error is the same as in the above code):
The text was updated successfully, but these errors were encountered: