Why in the following does test not typecheck (with Mypy 0.780)?
from typing import Iterator, Tuple
xs: Iterator[int] = (i for i in (1,2,3))
ys: Iterator[int] = (i for i in (1,2,3))
xys: Iterator[Tuple[int,int]] = zip(*(xs,ys))
test: Tuple[int,int,int] = tuple(map(sum, xys))
The error message:
error: Incompatible types in assignment (expression has type "Tuple[Union[_T, int], ...]", variable has type "Tuple[int, int, int]")
Observation: switching to Tuple[int, ...] removes the error.
Comment: I find this much more surprising than the failure of test: Tuple[int,int,int] = tuple(range(3)) to typecheck (with a more understandable error message), but perhaps it is the same underlying issue: length inference.
EDIT:
In response to @MisterMiyagi's second comment, consider the following, which raises the same error but has clearly inferable length:
xss: Tuple[Tuple[int,int,int], ...] = tuple((1,2,3) for _ in range(10))
test: Tuple[int,int,int] = tuple(map(sum, zip(*xss)))