Skip to content

Commit 2cfa405

Browse files
committed
pythonGH-103629: Update NEWS and whatsnew with PEP-692 information
1 parent 9529f87 commit 2cfa405

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

‎Doc/whatsnew/3.12.rst‎

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,10 @@ Summary -- Release highlights
6666
6767
.. PEP-sized items next.
6868
69+
New typing features:
70+
71+
* :ref:`whatsnew312-pep692`
72+
6973
Important deprecations, removals or restrictions:
7074

7175
* :pep:`623`, Remove wstr from Unicode
@@ -145,6 +149,36 @@ New Features
145149
In Python 3.14, the default will switch to ``'data'``.
146150
(Contributed by Petr Viktorin in :pep:`706`.)
147151

152+
New Features Related to Type Hints
153+
==================================
154+
155+
This section covers major changes affecting :pep:`484` type hints and
156+
the :mod:`typing` module.
157+
158+
.. _whatsnew312-pep692:
159+
160+
PEP 692: Using ``TypedDict`` for more precise ``**kwargs`` typing
161+
-----------------------------------------------------------------
162+
163+
Typing ``**kwargs`` in a function signature as introduced by :pep:`484` allowed
164+
for valid annotations only in cases where all of the ``**kwargs`` were of the
165+
same type.
166+
167+
This PEP specifies a more precise way of typing ``**kwargs`` by relying on
168+
typed dictionaries::
169+
170+
from typing import TypedDict, Unpack
171+
172+
class Movie(TypedDict):
173+
name: str
174+
year: int
175+
176+
def foo(**kwargs: Unpack[Movie]): ...
177+
178+
See :pep:`692` for more details.
179+
180+
(PEP written by Franek Magiera)
181+
148182

149183
Other Language Changes
150184
======================
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
Mention the new way of typing ``**kwargs`` with ``Unpack`` and ``TypedDict``
2+
introduced in :pep:`692`.

0 commit comments

Comments
 (0)