@@ -1231,7 +1231,7 @@ fun(lambda: (yield from [1])) # E: Incompatible types in "yield from" (actual t
12311231from typing import List
12321232a = None # type: List[A]
12331233a = [x for x in a]
1234- b = [x for x in a] # type: List[B] # E: List comprehension has incompatible type List[A]
1234+ b = [x for x in a] # type: List[B] # E: List comprehension has incompatible type List[A]; expected List[B]
12351235class A: pass
12361236class B: pass
12371237[builtins fixtures/for.pyi]
@@ -1240,7 +1240,7 @@ class B: pass
12401240from typing import List, Tuple
12411241l = None # type: List[Tuple[A, Tuple[A, B]]]
12421242a = [a2 for a1, (a2, b1) in l] # type: List[A]
1243- b = [a2 for a1, (a2, b1) in l] # type: List[B] # E: List comprehension has incompatible type List[A]
1243+ b = [a2 for a1, (a2, b1) in l] # type: List[B] # E: List comprehension has incompatible type List[A]; expected List[B]
12441244class A: pass
12451245class B: pass
12461246[builtins fixtures/for.pyi]
@@ -1259,7 +1259,7 @@ from typing import List
12591259a = None # type: List[A]
12601260b = None # type: List[B]
12611261b = [f(x) for x in a]
1262- a = [f(x) for x in a] # E: List comprehension has incompatible type List[B]
1262+ a = [f(x) for x in a] # E: List comprehension has incompatible type List[B]; expected List[A]
12631263([f(x) for x in b]) # E: Argument 1 to "f" has incompatible type "B"; expected "A"
12641264class A: pass
12651265class B: pass
@@ -1285,7 +1285,7 @@ from typing import List
12851285class A:
12861286 a = None # type: List[A]
12871287 a = [x for x in a]
1288- b = [x for x in a] # type: List[B] # E: List comprehension has incompatible type List[A]
1288+ b = [x for x in a] # type: List[B] # E: List comprehension has incompatible type List[A]; expected List[B]
12891289class B: pass
12901290[builtins fixtures/for.pyi]
12911291[out]
@@ -1299,7 +1299,7 @@ class B: pass
12991299from typing import Set
13001300a = None # type: Set[A]
13011301a = {x for x in a}
1302- b = {x for x in a} # type: Set[B] # E: Set comprehension has incompatible type Set[A]
1302+ b = {x for x in a} # type: Set[B] # E: Set comprehension has incompatible type Set[A]; expected Set[B]
13031303class A: pass
13041304class B: pass
13051305[builtins fixtures/set.pyi]
@@ -1351,15 +1351,15 @@ from typing import Iterator
13511351a = None # type: Iterator[int]
13521352a = (x for x in a)
13531353b = None # type: Iterator[str]
1354- b = (x for x in a) # E: Generator has incompatible item type "int"
1354+ b = (x for x in a) # E: Generator has incompatible item type "int"; expected "str"
13551355[builtins fixtures/for.pyi]
13561356
13571357[case testGeneratorIncompatibleErrorMessage]
13581358from typing import Callable, Iterator, List
13591359
13601360a = [] # type: List[Callable[[], str]]
13611361b = None # type: Iterator[Callable[[], int]]
1362- b = (x for x in a) # E: Generator has incompatible item type Callable[[], str]
1362+ b = (x for x in a) # E: Generator has incompatible item type Callable[[], str]; expected Callable[[], int]
13631363[builtins fixtures/list.pyi]
13641364
13651365-- Conditional expressions
@@ -1394,7 +1394,7 @@ y = '' # E: Incompatible types in assignment (expression has type "str", variabl
13941394import typing
13951395x = [1] if bool() else []
13961396x = [1]
1397- x = ['x'] # E: List item 0 has incompatible type "str"
1397+ x = ['x'] # E: List item 0 has incompatible type "str"; expected "int"
13981398[builtins fixtures/list.pyi]
13991399
14001400
@@ -1550,8 +1550,8 @@ def g() -> Iterator[int]:
15501550[case testDictWithKeywordArgsOnly]
15511551from typing import Dict, Any
15521552d1 = dict(a=1, b=2) # type: Dict[str, int]
1553- d2 = dict(a=1, b='') # type: Dict[str, int] # E: Dict entry 1 has incompatible type "str": "str"
1554- d3 = dict(a=1) # type: Dict[int, int] # E: Dict entry 0 has incompatible type "str": "int"
1553+ d2 = dict(a=1, b='') # type: Dict[str, int] # E: Dict entry 1 has incompatible type "str": "str"; expected "str": "int"
1554+ d3 = dict(a=1) # type: Dict[int, int] # E: Dict entry 0 has incompatible type "str": "int"; expected "int": "int"
15551555d4 = dict(a=1, b=1)
15561556d4.xyz # E: Dict[str, int] has no attribute "xyz"
15571557d5 = dict(a=1, b='') # type: Dict[str, Any]
@@ -1568,7 +1568,7 @@ dict(undefined) # E: Name 'undefined' is not defined
15681568from typing import Dict
15691569d = dict([(1, 'x'), (2, 'y')])
15701570d() # E: Dict[int, str] not callable
1571- d2 = dict([(1, 'x')]) # type: Dict[str, str] # E: List item 0 has incompatible type "Tuple[int, str]"
1571+ d2 = dict([(1, 'x')]) # type: Dict[str, str] # E: List item 0 has incompatible type "Tuple[int, str]"; expected "Tuple[str, str]"
15721572[builtins fixtures/dict.pyi]
15731573
15741574[case testDictFromIterableAndKeywordArg]
@@ -1701,7 +1701,7 @@ b = {'z': 26, **a}
17011701c = {**b}
17021702d = {**a, **b, 'c': 3}
17031703e = {1: 'a', **a} # E: Argument 1 to "update" of "dict" has incompatible type Dict[str, int]; expected Mapping[int, str]
1704- f = {**b} # type: Dict[int, int] # E: List item 0 has incompatible type Dict[str, int]
1704+ f = {**b} # type: Dict[int, int] # E: List item 0 has incompatible type Dict[str, int]; expected Mapping[int, int]
17051705[builtins fixtures/dict.pyi]
17061706
17071707[case testDictIncompatibleTypeErrorMessage]
@@ -1710,11 +1710,39 @@ from typing import Dict, Callable
17101710def things() -> int:
17111711 return 42
17121712
1713- stuff: Dict[int, Callable[[], str]] = { # E: Dict entry 0 has incompatible type "int": Callable[[], int]
1713+ stuff: Dict[int, Callable[[], str]] = { # E: Dict entry 0 has incompatible type "int": Callable[[], int]; expected "int": Callable[[], str]
17141714 1: things
17151715}
17161716[builtins fixtures/dict.pyi]
17171717
1718+ [case testDictIncompatibleKeyVerbosity]
1719+ from typing import Dict
1720+ import mod
1721+
1722+ class A: ...
1723+ class B(A): ...
1724+
1725+ d: Dict[A, B] = {A(): mod.B()} # E: Dict entry 0 has incompatible type "A": "mod.B"; expected "A": "__main__.B"
1726+
1727+ [file mod.py]
1728+ class B: ...
1729+
1730+ [builtins fixtures/dict.pyi]
1731+
1732+ [case testDictIncompatibleValueVerbosity]
1733+ from typing import Dict
1734+ import mod
1735+
1736+ class A: ...
1737+ class B(A): ...
1738+
1739+ d: Dict[B, A] = {mod.B(): A()} # E: Dict entry 0 has incompatible type "mod.B": "A"; expected "__main__.B": "A"
1740+
1741+ [file mod.py]
1742+ class B: ...
1743+
1744+ [builtins fixtures/dict.pyi]
1745+
17181746-- Type checker default plugin
17191747-- ---------------------------
17201748
0 commit comments