-
Notifications
You must be signed in to change notification settings - Fork 216
Open
Description
Summary
Even though the feature overview and the support TypedDict issues show NotRequired as supported, it seems to be not working correctly.
In the following example MyDict.foo must not necessarily exist, but ty always assumes it's existence.
Example
from typing import TypedDict, NotRequired
class MyDict(TypedDict):
foo: NotRequired[str]
my_dict: MyDict = {}
# assignment to a string variable doesn't give a warning
my_string: str = my_dict["foo"]
# assignment to a string parameter doesn't give a warning
def print_string(s: str) -> None:
print(s)
print_string(my_dict["foo"])Version
ty 0.0.17 (8cec857 2026-02-13)
Reactions are currently unavailable