Closed
Description
I have the following code which works.
from typing import Dict
my_list = ['a', 'b']
my_dict: Dict[str, str] = dict([my_list])
print(my_dict) # {'a': 'b'}
mypy
gives the following error:
example.py:4: error: List item 0 has incompatible type "List[str]"; expected "Tuple[str, str]"
I expect that in this case mypy
would not show an error because the code is valid.
From https://docs.python.org/3/library/stdtypes.html#dict:
Each item in the iterable must itself be an iterable with exactly two objects.
Metadata
Metadata
Assignees
Labels
No labels