Closed
Description
Mypy complains about the following code:
from typing import TypeVar, List
T = TypeVar('T')
def f(a: T) -> None:
l = [] # type: List[T] # Error, even though this should be fine
The reason for the error seems to be that the type variable type T
in List[T]
is erased so that it won't conflict with the type variables used for inferring the type of the list expression. Both type variables should be able to coexist during type inference.