mypy doesn't recognize incompatible type in Dict
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 35/100
Research direction
Reproduce the report with Python 3.5.2 and mypy 0.4.6 using the example in mypy_bug.py, then compare diagnostics for the two update() calls. The work is done when the incompatible key and value types are both reported consistently.
Written by the indexing model from the issue text.
Description
On windows,
python --version
Python 3.5.2
with the following mypy_bug.py:
from typing import Dict
CHESSDICT = {} # type: Dict[str, int]
CHESSDICT.update({("a", 1): "Rook"})
CHESSDICT.update({(0, 0): "Rook"})
for key in CHESSDICT:
print('position {0}, figure {1}'.format(key, CHESSDICT[key]))
python -m mypy -v .\mypy_bug.py
LOG: Mypy version 0.4.6
LOG: Parsing .\mypy_bug.py (mypy_bug)
LOG: Parsing C:\Users\user\venv\lib\mypy\typeshed\stdlib\3\typing.pyi (typing)
LOG: Parsing C:\Users\user\venv\lib\mypy\typeshed\stdlib\3\builtins.pyi (builtins)
LOG: Parsing C:\Users\user\venv\lib\mypy\typeshed\stdlib\3\sys.pyi (sys)
LOG: Parsing C:\Users\user\venv\lib\mypy\typeshed\stdlib\3\abc.pyi (abc)
LOG: Parsing C:\Users\user\venv\lib\mypy\typeshed\stdlib\3\types.pyi (types)
LOG: Parsing C:\Users\user\venv\lib\mypy\typeshed\stdlib\3_importlib_modulespec.pyi (_importlib_modulespec)
LOG: Loaded graph with 7 nodes
LOG: Found 2 SCCs; largest has 6 nodes
LOG: Processing SCC of size 6 (_importlib_modulespec types abc typing sys builtins) as inherently stale
LOG: Processing SCC singleton (mypy_bug) as inherently stale
LOG: No fresh SCCs left in queue
LOG: Build finished in 0.579 seconds with 7 modules, 1708 types, and 1 errors
mypy_bug.py:5: error: List item 0 has incompatible type "Tuple[Tuple[int, int], str]"
The line no 5 is recognised correctly as incompatible with Dict[str, int]
But line no 4 is not recognised, but in my opinion Dict[str, int] != Dict[Tuple[str, int], str]
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- Avg merge
- 1d 18h
- Merged PRs (30d)
- 54
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from python/mypy
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 75/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 76/100
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
bug topic-configuration topic-error-reporting
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Similar issues
-
Difficulty 1/5 Under an hour Newbie friendliness 90/100
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
zostera/django-bootstrap4#894 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
use-agent-os/agent-os#3276 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
zephyrproject-rtos/zephyr#119726 ·
-
area/auth bug comp/agent P3 platform/discord type/security
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
NousResearch/hermes-agent#117848 ·