-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Open
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
A dict that is typed with literal keys cannot be unpacked into a dict with string keys.
To Reproduce
https://mypy-play.net/?mypy=latest&python=3.13&gist=f150b9f1c64eba97cb0496a6a5d7a2b6
from typing import Literal
data: dict[Literal["foo"], str] = {"foo": "bar"}
def foo() -> dict[str, str]:
return {**data}
Expected Behavior
The code should type check. It works fine in Pyright.
Actual Behavior
error: Unpacked dict entry 0 has incompatible type "dict[Literal['foo'], str]"; expected "SupportsKeysAndGetItem[str, str]" [dict-item]
Your Environment
- Mypy version used: 1.18.2
- Python version used: 3.13
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong