Closed
Description
Bug Report
Mypy doesn't support typing_extensions.TypeVar
at all
To Reproduce
from typing import Generic
from typing_extensions import (
TypeVar,
)
T = TypeVar("T")
class A(Generic[T]):
def __init__(self, value: T):
self.value = value
a: A = A(8)
b: A[str] = A("")
Expected Behavior
This code should work fine (importing TypeVar
from typing
works, but my actual use case depends on default
argument of TypeVar
, so I can't use typing.TypeVar
)
Actual Behavior
main.py:8: error: Free type variable expected in Generic[...] [misc]
main.py:9: error: Variable "__main__.T" is not valid as a type [valid-type]
main.py:9: note: See https://mypy.readthedocs.io/en/stable/common_issues.html#variables-vs-type-aliases
main.py:13: error: "A" expects no type arguments, but 1 given [type-arg]
Found 3 errors in 1 file (checked 1 source file)
Your Environment
mypy Playground, latest mypy (0.991)