Description
The following code runs correctly on Python 3.7.3:
vals = (("zz", 1), ("yyy", 8))
EXAMPLE: Dict[str, List[Union[str, int]]] = { k: list(val) for k, val in zip(["A", "B"], zip(*vals)) }
producing
>>> EXAMPLE {'A': ['zz', 'yyy'], 'B': [1, 8]}
but raises the following error with mypy 0.761 (and on https://mypy-play.net/):
error: Argument 1 to "list" has incompatible type "Tuple[object, object]"; expected "Iterable[Union[str, int]]"
Explicitly typing the tuple as follows removes the error:
vals: Tuple[Tuple[str, int], ...] = (("zz", 1), ("yyy", 8))
Interesting, explicitly typing the tuple and the nested tuples does not remove the error:
vals: Tuple[Tuple[str, int], Tuple[str, int]] = (("zz", 1), ("yyy", 8))
produces the same error above when no type hint is provided.
Possibly related to #4975 ?