With the following example:
from typing import Literal
dest: Literal["tata", "tutu"]
for src in "tata", "tutu":
dest = src
I'm getting:
error: Incompatible types in assignment (expression has type "str", variable has type "Literal['http', 'https']")
Trying to dig with reveal_type:
t = "tata", "tutu"
reveal_type(t)
reveal_type(t.__iter__())
I get:
test.py:2: note: Revealed type is "Tuple[builtins.str, builtins.str]"
test.py:3: note: Revealed type is "typing.Iterator[builtins.str*]"
So it looks OK, but digging with pdb, in mypy/checker.py:analyze_iterable_item_type(), after calling:
iterator = echk.check_method_call_by_name('__iter__', iterable, [], [], expr)[0]
I see:
iterable == Tuple[Literal['foo']?, Literal['bar']?]
iterator == typing.Iterator[builtins.str*])
I think some information is lost here, should iterator get: typing.Iterator[Literal['foo', 'bar']] instead?
With the following example:
I'm getting:
Trying to dig with
reveal_type:I get:
So it looks OK, but digging with pdb, in
mypy/checker.py:analyze_iterable_item_type(), after calling:I see:
I think some information is lost here, should iterator get:
typing.Iterator[Literal['foo', 'bar']]instead?