Open
Description
Here's a type variable in a normal method. This works fine:
from typing import TypeVar, Generic
T = TypeVar('T')
class A(Generic[T]):
def f(self) -> None:
x: T
However in a static method this doesn't make sense, since we don't have an instance of A
to provide any parameterized type for T
:
from typing import TypeVar, Generic
T = TypeVar('T')
class A(Generic[T]):
@staticmethod
def f() -> None:
x: T # Error we don't yet provide: Invalid type "__main__.T"
Nor does this make any sense:
from typing import TypeVar, Generic
T = TypeVar('T')
class A(Generic[T]):
@classmethod
def f(cls) -> None:
x: T # Error we don't yet provide: Invalid type "__main__.T"