You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Are you reporting a bug, or opening a feature request?
Bug
Please insert below the code you are checking with mypy.
from typing import Sequence, Union
def baz(idx: int, arg: Union[int, str]) -> None:
pass
def foo(the_list: Union[Sequence[int], Sequence[str]]) -> None:
for idx, val in enumerate(the_list):
reveal_type(idx)
reveal_type(val)
baz(idx, val)
What is the actual behavior/output?
foo.py:8: note: Revealed type is 'builtins.int'
foo.py:9: note: Revealed type is 'builtins.object*'
foo.py:10: error: Argument 2 to "baz" has incompatible type "object"; expected "Union[int, str]"
What is the behavior/output you expect?
foo.py:8: note: Revealed type is 'builtins.int'
foo.py:9: note: Revealed type is 'Union[int, str]'
What are the versions of mypy and Python you are using?
Do you see the same issue after installing mypy from Git master?
0.761, 0.770 and master all have the same result.
What are the mypy flags you are using? (For example --strict-optional) --strict
The text was updated successfully, but these errors were encountered:
jbwdevries
changed the title
enumerate(Union)
enumerate(Union[Sequence, Sequence])
Mar 25, 2020
This is actually an expected behavior, but maybe it may sense to special case constraint solver for type variables to use a union instead of join if multiple constraints come from union items.
Bug
Do you see the same issue after installing mypy from Git master?
0.761, 0.770 and master all have the same result.
--strict
The text was updated successfully, but these errors were encountered: