-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Labels
bugmypy got something wrongmypy got something wrong
Description
Bug Report
Type checking the code below causes mypy errors. In my opinion, everything assignable to type T should be still assignable to type T | something.
To Reproduce
Playground with the following code:
from typing import TypedDict
class AngleDict(TypedDict):
yaw: float
pitch: float
roll: float
angles: dict[str, None] = {"yaw": None, "pitch": None, "roll": None}
angles2: AngleDict | dict[str, None] = {"yaw": None, "pitch": None, "roll": None}Expected Behavior
No errors.
Actual Behavior
main.py:11: error: Incompatible types (expression has type "None", TypedDict item "yaw" has type "float") [typeddict-item]
main.py:11: error: Incompatible types (expression has type "None", TypedDict item "pitch" has type "float") [typeddict-item]
main.py:11: error: Incompatible types (expression has type "None", TypedDict item "roll" has type "float") [typeddict-item]
Found 3 errors in 1 file (checked 1 source file)
Your Environment
- Mypy version used: master and 1.1.1
- Mypy command-line flags: nope
- Mypy configuration options from
mypy.ini(and other config files): nope - Python version used: 3.10, 3.11
Metadata
Metadata
Assignees
Labels
bugmypy got something wrongmypy got something wrong