-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrong
Description
I came across this while looking at #1337, but this is a separate issue.
from typing import TypeVar, Generic
T = TypeVar('T')
class A(Generic[T]):
@classmethod
def foo(cls, x: int) -> int: pass
@staticmethod
def bar(x: int) -> int: pass
a = A() # type: A[str]
a.foo(2) # E: Invalid class method type
a.bar(2) # ok
If the class A
is not generic, then both calls are accepted. So I think this is a bug.
The error arises in check_method_type
when checking that the type of the instance (a
) matches the return type of the argument cls
as a Callable. But the latter type here is A[T
-1], while the type of
ais
A[str]`.
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong