There is python bug https://github.com/python/cpython/issues/97727. If field of TypedDict is stringified or from __future__ import annotations is placed in file Required and NotRequired specifiers is ignored when __required_keys__ and __optional_keys__ is calculated. This bug can not be fixed by python because such annotations such be evaluted lazily.
TypedDict's introspection have to exclude fields wrapped with NotRequired from __required_keys__ and Required from __optional_keys__. NotRequired and Required can be wrapped via Annotated, so implementation should use normalize_type and recursively search for specifier.
There is python bug https://github.com/python/cpython/issues/97727. If field of TypedDict is stringified or
from __future__ import annotations
is placed in fileRequired
andNotRequired
specifiers is ignored when__required_keys__
and__optional_keys__
is calculated. This bug can not be fixed by python because such annotations such be evaluted lazily.TypedDict's introspection have to exclude fields wrapped with
NotRequired
from__required_keys__
andRequired
from__optional_keys__
.NotRequired
andRequired
can be wrapped viaAnnotated
, so implementation should usenormalize_type
and recursively search for specifier.