Open
Description
Code:
from typing import TypeVar, Generic, reveal_type
T = TypeVar('T')
N = TypeVar('N')
class My(Generic[T]):
def __init__(self, arg: T) -> None:
self.arg = arg
@classmethod
def from_arg(cls, arg: N) -> 'My[N]':
return My(arg)
Alias = My[T]
reveal_type(My.from_arg(1))
# note: Revealed type is "__main__.My[builtins.int]"
reveal_type(Alias.from_arg(1))
# error: Missing type parameters for generic type "Alias" [type-arg]
# note: Revealed type is "__main__.My[builtins.int]"
Problem: I think that [type-arg]
error should not be raised in this case, because no type param is actually needed in this case. classmethod
is often used as a constructor, duplicating type vars is verbose and unneeded.