The different type (`str`) of unpacked inner dictionary items from the type (`int`) of outer dictionary items gets error
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 20.6k
- Forks
- 3.3k
- PR merge metrics
- PR metrics pending
Description
*Memo:
- mypy test.py
- Python 3.14.0
- mypy 1.19.1
The different type (str) of unpacked inner list items from the type (int) of outer list items doesn't get error as shown below:
v = [0, 1, *['a', 'b']] # No error
The different type (str) of unpacked inner dictionary items from the type (int) of outer dictionary items gets the error as shown below:
v = {0: 1, **{'a':'b'}} # Error
error: Cannot infer value of type parameter "KT" of
In additioin, if the types of keys in an inter and outer dictionary are the same, error doesn't occur as shown below:
v1 = {0: 1, **{2:'b'}}
v2 = {'0': 1, **{'a':'b'}}
# No error
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.
Research direction
Start with the minimal examples in test.py and run mypy on Python 3.14.0 to reproduce the differing diagnostics for list and dictionary unpacking. Trace the type inference path for the shown dictionary cases and add or update a focused regression test; done means the intended behavior is covered consistently without regressing the existing same-key-type cases.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- devtools
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100