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
First, methods are actually functions, and therefore are always allowed to be generic, and this has nothing to do with #2811
Second, mypy is not super strong at callable subtyping now, but in this particular case I think everything is right. At least I didn't find any situation with A[int] and B defined this way that is not caught by mypy but fails at runtime.
I agree that mypy is correct -- the method B.f is generic (even though B is not generic) and it can be made to have the base class signature by substituting T with int. B.f can be called with an arbitrary argument type, but it's okay for a subclass to a have a more general signature than the base class.
Currently mypy reports an error only in class
D
, but it should complain aboutB
as well, becauseT
. Does it come from Allow omitting redundant Generic[T] in base classes #2811?D
.The text was updated successfully, but these errors were encountered: