@@ -592,17 +592,14 @@ class Node(Generic[T, S]):
592
592
def __init__(self, x: T, y: S) -> None:
593
593
...
594
594
595
- A = Node[T] # E: Type application has too few types (2 expected)
595
+ A = Node[T] # E: "Node" expects 2 type arguments, but 1 given
596
596
B = Node[T, T]
597
- C = Node[T, T, T] # E: Type application has too many types (2 expected)
597
+ C = Node[T, T, T] # E: "Node" expects 2 type arguments, but 3 given
598
598
D = Node[T, S]
599
599
E = Node[Node[T, T], List[T]]
600
600
601
- # Errors for F, G, H are not reported if those aliases left used
602
601
F = Node[List[T, T], S] # E: "list" expects 1 type argument, but 2 given
603
- f = None # type: F
604
602
G = Callable[..., List[T, T]] # E: "list" expects 1 type argument, but 2 given
605
- g = None # type: G[int]
606
603
H = Union[int, Tuple[T, Node[T]]] # E: "Node" expects 2 type arguments, but 1 given
607
604
h = None # type: H
608
605
h1 = None # type: H[int, str] # E: Bad number of arguments for type alias, expected: 1, given: 2
@@ -612,6 +609,8 @@ reveal_type(x) # E: Revealed type is '__main__.Node[builtins.int, builtins.str]'
612
609
y = None # type: E[int]
613
610
reveal_type(y) # E: Revealed type is '__main__.Node[__main__.Node[builtins.int, builtins.int], builtins.list[builtins.int]]'
614
611
612
+ X = T # E: Invalid type "__main__.T" for aliasing
613
+
615
614
[builtins fixtures/list.pyi]
616
615
617
616
[case testGenericTypeAliasesForAliases]
@@ -904,13 +903,13 @@ CA = Callable[[T], int]
904
903
TA = Tuple[T, int]
905
904
UA = Union[T, int]
906
905
907
- cs = CA[str]() # E: Invalid type alias in runtime expression: def (builtins.str) -> builtins.int
906
+ cs = CA[str] + 1 # E: Unsupported left operand type for + ("Type alias to Callable")
908
907
reveal_type(cs) # E: Revealed type is 'Any'
909
908
910
- ts = TA[str]() # E: Invalid type alias in runtime expression: Tuple[builtins.str, builtins.int]
909
+ ts = TA[str]() # E: "Type alias to Tuple" not callable
911
910
reveal_type(ts) # E: Revealed type is 'Any'
912
911
913
- us = UA[str]() # E: Invalid type alias in runtime expression: Union[builtins.str, builtins.int]
912
+ us = UA[str].x # E: "Type alias to Union" has no attribute "x"
914
913
reveal_type(us) # E: Revealed type is 'Any'
915
914
916
915
[out]
0 commit comments