-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed as not planned
Labels
Description
Bug Report
Accessing a NotRequired
field in a TypedDict
does not result in an error.
To Reproduce
from typing import NotRequired, TypedDict
TypeDef = TypedDict(
"TypeDef",
{
"Field": NotRequired[str],
},
)
sample = TypeDef()
val: str = sample["Field"] # expect error here
Expected Behavior
The final line should produce an error, either that "Field"
is not necessarily defined or that the resulting access might produce a None, and that val
is therefore the wrong type.
Actual Behavior
No error.
Your Environment
MacOS Sonoma, arm64.
- Mypy version used: 1.10.0
- Mypy command-line flags: default
- Mypy configuration options from
mypy.ini
(and other config files): default - Python version used: 3.12.3