We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent ff716fa commit e04eb73Copy full SHA for e04eb73
test-data/unit/check-inference-context.test
@@ -755,4 +755,20 @@ T = TypeVar('T')
755
def f(a: T) -> None:
756
l = [] # type: List[T]
757
l.append(a)
758
+ l.append(1) # E: Argument 1 to "append" of "list" has incompatible type "int"; expected "T"
759
[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
774
+main: note: In member "f" of class "A":
0 commit comments