Skip to content

Commit e04eb73

Browse files
committed
Add more tests for inference in generic function
1 parent ff716fa commit e04eb73

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

test-data/unit/check-inference-context.test

+16
Original file line numberDiff line numberDiff line change
@@ -755,4 +755,20 @@ T = TypeVar('T')
755755
def f(a: T) -> None:
756756
l = [] # type: List[T]
757757
l.append(a)
758+
l.append(1) # E: Argument 1 to "append" of "list" has incompatible type "int"; expected "T"
758759
[builtins fixtures/list.py]
760+
[out]
761+
main: note: In function "f":
762+
763+
[case testInferenceInGenericClass]
764+
from typing import TypeVar, Generic, List
765+
S = TypeVar('S')
766+
T = TypeVar('T')
767+
class A(Generic[S]):
768+
def f(self, a: T, b: S) -> None:
769+
l = [] # type: List[T]
770+
l.append(a)
771+
l.append(b) # E: Argument 1 to "append" of "list" has incompatible type "S"; expected "T"
772+
[builtins fixtures/list.py]
773+
[out]
774+
main: note: In member "f" of class "A":

0 commit comments

Comments
 (0)