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
False positive when calling object.__new__ inside __new__ with args #4190
classA:
def__new__(cls, x: int) ->'A':
returnobject.__new__(cls) # Argument 1 to "__new__" of "object" has incompatible type "Type[A]"; expected "Type[object]"classB:
def__new__(cls) ->'B':
returnobject.__new__(cls)
The object.__new__(cls) call type checks when inside a __new__ method with a single argument, but not when there are extra arguments.
The code for A is taken from testSuperWithNew, but because object.__new__ is unannotated in fixtures/__new__.pyi, the type error doesn't show up in the unit test. The discrepancy between the fixture and typeshed was noted in #3111.
Activity
ilevkivskyi commentedon Nov 1, 2017
I think #1021 is closely related.
msullivan commentedon Sep 19, 2018
Interestingly, the following works:
msullivan commentedon Sep 19, 2018
I think the fix for this is to make the type of
clsbeType[A].Make classmethod's first argument be Type[...]
gvanrossum commentedon Sep 19, 2018
(By which you mean, mypy should set it to that, right?)
Make classmethod's first argument be Type[...] (#5646)