-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrongtopic-inferenceWhen to infer types or require explicit annotationsWhen to infer types or require explicit annotations
Description
Bug Report
More specific inline dict type inference can fail on 1.17.0.
To Reproduce
The following fails on 1.17.0 but is fine on 1.16.1 (the playground link uses master as 1.17.0 isn't available there):
https://mypy-play.net/?mypy=master&python=3.13&gist=7e77b89fe5f9cb7e548c4ef83b3783c1
Revealing the type for the inline dict gives:
- 1.16.1:
builtins.dict[builtins.str, Union[typing.Collection[builtins.str], None]]
- 1.17.0:
builtins.dict[builtins.str, builtins.dict[builtins.str, builtins.list[Any] | None] | builtins.dict[builtins.str, builtins.str] | builtins.str | None]
Expected Behavior
No mypy errors.
Actual Behavior
main.py:11: error: Dict entry 0 has incompatible type "str": "None"; expected "str": "str" [dict-item]
main.py:12: error: Dict entry 1 has incompatible type "str": "list[Never]"; expected "str": "str" [dict-item]
Found 2 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: 1.17.0
- Mypy command-line flags: N/A
- Mypy configuration options from
mypy.ini
(and other config files): N/A - Python version used: 3.13.5
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrongtopic-inferenceWhen to infer types or require explicit annotationsWhen to infer types or require explicit annotations