Add support for PEP 692: **kwargs: typing.Unpack[TypedDict]
#579
Labels
enhancement
New feature or request
**kwargs: typing.Unpack[TypedDict]
#579
🚀 Feature request
Allow using
TypedDict
for more precise**kwargs
typing as described in PEP 692.Motivation
I want to be able to enjoy static typing guarantees through
mypy
for classes or functions withTypedDict
-annotated**kwargs
and use those classes in configurations parsed byjsonargparse
.Right now, I either have to remove the annotation from
**kwargs
and hope thatjsonargparse
is able to inspect and infer the types using its heuristics, or I have to expand thekwargs
and duplicate keywords that would otherwise be represented by theTypedDict
.Pitch
I want the following script to work without errors:
The script should print the following:
Partial Solution
The following diff from 7874273 partially provides a solution.
It does not account for earlier Python versions that do not support
Unpack
withouttyping_extensions
, and it probably violates some conventions or expectations of the existing codebase.It may also have some unintended side-effects.
Diff for Partial Solution
The text was updated successfully, but these errors were encountered: