PEP 692
lastmod 2026-11-10created 2024-09-242 edits
PEP 692 is a proposal that specifies how to attach more precise types to Python's **kwargs argument. Previously, you could only state that all keyword argument values share the same type, as in **kwargs: int; this proposal lets you use the **kwargs: Unpack[SomeTypedDict] syntax to specify a different type and required/optional status for each key name via a TypedDict. It was accepted in Python 3.12, and type checkers such as mypy and pyright interpret it.
Using TypedDict for more precise **kwargs typing