Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

gh-103629: Update typing.Unpack docs in compliance with PEP 692 #103894

Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
GH-103629: Update NEWS and whatsnew with PEP-692 information
  • Loading branch information
franekmagiera committed Apr 26, 2023
commit 2cfa405941c464991dc035a81af082ef276a0776
34 changes: 34 additions & 0 deletions Doc/whatsnew/3.12.rst
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,10 @@ Summary -- Release highlights

.. PEP-sized items next.

New typing features:

* :ref:`whatsnew312-pep692`

Important deprecations, removals or restrictions:

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

New Features Related to Type Hints
==================================

This section covers major changes affecting :pep:`484` type hints and
the :mod:`typing` module.

.. _whatsnew312-pep692:

PEP 692: Using ``TypedDict`` for more precise ``**kwargs`` typing
-----------------------------------------------------------------

Typing ``**kwargs`` in a function signature as introduced by :pep:`484` allowed
for valid annotations only in cases where all of the ``**kwargs`` were of the
same type.

This PEP specifies a more precise way of typing ``**kwargs`` by relying on
typed dictionaries::

from typing import TypedDict, Unpack

class Movie(TypedDict):
name: str
year: int

def foo(**kwargs: Unpack[Movie]): ...

See :pep:`692` for more details.

(PEP written by Franek Magiera)


Other Language Changes
======================
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Mention the new way of typing ``**kwargs`` with ``Unpack`` and ``TypedDict``
introduced in :pep:`692`.