You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: test-data/unit/check-based-type-render.test
+12-6Lines changed: 12 additions & 6 deletions
Original file line number
Diff line number
Diff line change
@@ -1,8 +1,8 @@
1
1
[case testGenericMethod]
2
2
from typing import TypeVar, Generic, Union
3
3
4
-
T = TypeVar('T')
5
-
T2 = TypeVar('T2')
4
+
T = TypeVar('T', bound=str)
5
+
T2 = TypeVar('T2', bound=int)
6
6
7
7
class A(Generic[T2]):
8
8
def f(self, t: T, t2: T2) -> Union[T, T2]:
@@ -12,10 +12,10 @@ class A(Generic[T2]):
12
12
t = t2 # E: Incompatible types in assignment (expression has type "T2@A", variable has type "T@f") [assignment]
13
13
return t
14
14
15
-
reveal_type(A.f) # N: Revealed type is "def [T2 (from A), T] (self: __main__.A[T2], t: T, t2: T2) -> T | T2"
16
-
reveal_type(A[int]().f) # N: Revealed type is "def [T] (t: T, t2: int) -> T | int"
15
+
reveal_type(A.f) # N: Revealed type is "def [T2 (from A): int, T: str] (self: __main__.A[T2], t: T, t2: T2) -> T | T2"
16
+
reveal_type(A[int]().f) # N: Revealed type is "def [T: str] (t: T, t2: int) -> T | int"
17
17
A.f = 1 # E: Cannot assign to a method [assignment] \
18
-
# E: Incompatible types in assignment (expression has type "int", variable has type "[T2 (from A), T] (A[T2], T, T2) -> T | T2") [assignment]
18
+
# E: Incompatible types in assignment (expression has type "int", variable has type "[T2 (from A): int, T: str] (A[T2], T, T2) -> T | T2") [assignment]
19
19
20
20
21
21
[case testGenericFunction]
@@ -58,7 +58,7 @@ from typing import TypeVar
58
58
T = TypeVar("T", bound=int)
59
59
60
60
def foo(t: T): ...
61
-
reveal_type(foo) # N: Revealed type is "def [T: int] (t: T)"
61
+
reveal_type(foo) # N: Revealed type is "def [T: int] (t: T) -> None"
62
62
63
63
64
64
[case testInferredNever]
@@ -73,3 +73,9 @@ def b() -> NoReturn: ...
73
73
reveal_type(a) # N: Revealed type is "Never"
74
74
reveal_type(b) # N: Revealed type is "def () -> Never"
75
75
b = 1 # E: Incompatible types in assignment (expression has type "int", variable has type "() -> Never") [assignment]
76
+
77
+
78
+
[case testRenderNoneReturn]
79
+
def foo(): ...
80
+
reveal_type(foo) # N: Revealed type is "def () -> None"
81
+
foo = 1 # E: Incompatible types in assignment (expression has type "int", variable has type "() -> None") [assignment]
0 commit comments