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
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 aisA[str]`.
The text was updated successfully, but these errors were encountered:
I came across this while looking at #1337, but this is a separate issue.
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 argumentcls
as a Callable. But the latter type here isA[T
-1], while the type of
ais
A[str]`.The text was updated successfully, but these errors were encountered: