We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
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:
mypy
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.
The text was updated successfully, but these errors were encountered:
Seems like a typeshed issue. Possibly dict.__init__() is missing an overload like:
dict.__init__()
@overload def __init__(self, iterable: Iterable[Iterable[Union[_KT, _VT]]], **kwargs: _VT) -> None: ...
Sorry, something went wrong.
@srittau I'm not yet good a assessing which of these repos issues belong to! I will create a typeshed issue, thank you.
Closing in favour of python/typeshed#2862.
No branches or pull requests
I have the following code which works.
mypy
gives the following error: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:
The text was updated successfully, but these errors were encountered: