this seems to be a regression which I am getting with mypy master @ 0df8cf5, havent bisected to find the exact commit:
fromtypingimportDictfromtypingimportGenericfromtypingimportListfromtypingimportTuplefromtypingimportTypeVarfromtypingimportUnionclassThing:
pass_THING=TypeVar("_THING", bound="Thing")
classThingCollection(Generic[_THING]):
_collection: List[Tuple[str, _THING]]
_index: Dict[Union[None, str, int], _THING]
def__init__(self, t: _THING):
self._collection= [("x", t)]
self._index= {}
defdo_thing(self) ->None:
self._index.update(
(idx, c) foridx, (k, c) inenumerate(self._collection)
)
defdo_thing_workaround(self) ->None:
self._index.update(
(idx, c) foridx, cinenumerate(cfor (k, c) inself._collection)
)output:
$ mypy test3.py test3.py:27: error: Generator has incompatible item type "Tuple[int, Tuple[str, _THING]]"; expected "Tuple[Union[None, str, int], _THING]" [misc]
Found 1 error in 1 file (checked 1 source file)
mypy seems to be mis-interpreting the first generator. works in mypy 0.942 and pyright
this seems to be a regression which I am getting with mypy master @ 0df8cf5, havent bisected to find the exact commit:
output:
mypy seems to be mis-interpreting the first generator. works in mypy 0.942 and pyright