@@ -98,6 +98,9 @@ annotations. These include:
9898 *Introducing * :data: `LiteralString `
9999* :pep: `681 `: Data Class Transforms
100100 *Introducing * the :func: `@dataclass_transform<dataclass_transform> ` decorator
101+ * :pep: `692 `: Using ``TypedDict `` for more precise ``**kwargs `` typing
102+ *Introducing * a new way of typing ``**kwargs `` with :data: `Unpack ` and
103+ :data: `TypedDict `
101104* :pep: `698 `: Adding an override decorator to typing
102105 *Introducing * the :func: `@override<override> ` decorator
103106
@@ -1417,8 +1420,10 @@ These are not used in annotations. They are building blocks for creating generic
14171420 tup: tuple[Unpack[Ts]]
14181421
14191422 In fact, ``Unpack `` can be used interchangeably with ``* `` in the context
1420- of types. You might see ``Unpack `` being used explicitly in older versions
1421- of Python, where ``* `` couldn't be used in certain places::
1423+ of :class: `typing.TypeVarTuple <TypeVarTuple> ` and
1424+ :class: `builtins.tuple <tuple> ` types. You might see ``Unpack `` being used
1425+ explicitly in older versions of Python, where ``* `` couldn't be used in
1426+ certain places::
14221427
14231428 # In older versions of Python, TypeVarTuple and Unpack
14241429 # are located in the `typing_extensions` backports package.
@@ -1428,6 +1433,21 @@ These are not used in annotations. They are building blocks for creating generic
14281433 tup: tuple[*Ts] # Syntax error on Python <= 3.10!
14291434 tup: tuple[Unpack[Ts]] # Semantically equivalent, and backwards-compatible
14301435
1436+ ``Unpack `` can also be used along with :class: `typing.TypedDict ` for typing
1437+ ``**kwargs `` in a function signature::
1438+
1439+ from typing import TypedDict, Unpack
1440+
1441+ class Movie(TypedDict):
1442+ name: str
1443+ year: int
1444+
1445+ # This function expects two keyword arguments - `name` of type `str`
1446+ # and `year` of type `int`.
1447+ def foo(**kwargs: Unpack[Movie]): ...
1448+
1449+ See :pep: `692 ` for more details on using ``Unpack `` for ``**kwargs `` typing.
1450+
14311451 .. versionadded :: 3.11
14321452
14331453.. class :: ParamSpec(name, *, bound=None, covariant=False, contravariant=False)
0 commit comments