Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork3.1k
Closed
Description
- Please insert below the code you are checking with mypy,
fromtypingimportIterable,Iterator,Unionfromtyping_extensionsimportProtocolclassMixedIter(Protocol):def__iter__(self)->Iterator[Union[int,str]]: ...deff(xs:Iterable[Union[int,str]])->str:return''.join(str(x)forxinxs)defg(xs:MixedIter)->str:return''.join(str(x)forxinxs)mixedTuple= (56,'A')reveal_type(mixedTuple)reveal_type(mixedTuple.__iter__)print(f(mixedTuple))print(g(mixedTuple))
- What is the actual behavior/output?
mixedtuple.py:14: note: Revealed type is 'Tuple[builtins.int, builtins.str]'mixedtuple.py:15: note: Revealed type is 'def () -> typing.Iterator[builtins.object*]'mixedtuple.py:17: error: Argument 1 to "g" has incompatible type "Tuple[int, str]"; expected "MixedIter" [arg-type]- What is the behavior/output you expect?
I'd expect bothf(mixedTuple) andg(mixedTuple) to be accepted without errors.
- What are the versions of mypy and Python you are using?
mypy 0.730 on Python 3.7.2.