Skip to content

Commit 8f4a237

Browse files
committed
Add unbound typevar case
Not exactly a semanal error, but could be and adds useful context
1 parent 68df89a commit 8f4a237

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

test-data/unit/semanal-errors.test

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1072,6 +1072,9 @@ class C(Generic[T]):
10721072
Bad = TypeVar("Bad", int, List[T]) # E: TypeVar constraint type cannot be parametrized by type variables
10731073
class D:
10741074
Bad = TypeVar("Bad", int, List[Self]) # E: TypeVar constraint type cannot be parametrized by type variables
1075+
S = TypeVar("S", int, List[T]) # E: Type variable "__main__.T" is unbound \
1076+
# N: (Hint: Use "Generic[T]" or "Protocol[T]" base class to bind "T" inside a class) \
1077+
# N: (Hint: Use "T" in function signature to bind "T" inside a function)
10751078

10761079
[case testInvalidTypevarValues]
10771080
from typing import TypeVar

0 commit comments

Comments
 (0)