mirror of
https://github.com/python/cpython.git
synced 2025-09-27 02:39:58 +00:00
GH-109190: Copyedit 3.12 What's New: Typing PEPs (#109659)
This commit is contained in:
parent
22b70ca480
commit
11636788da
1 changed files with 6 additions and 4 deletions
|
@ -331,7 +331,7 @@ See :mod:`sys.monitoring` for details.
|
||||||
New Features Related to Type Hints
|
New Features Related to Type Hints
|
||||||
==================================
|
==================================
|
||||||
|
|
||||||
This section covers major changes affecting :pep:`484` type hints and
|
This section covers major changes affecting :pep:`type hints <484>` and
|
||||||
the :mod:`typing` module.
|
the :mod:`typing` module.
|
||||||
|
|
||||||
.. _whatsnew312-pep692:
|
.. _whatsnew312-pep692:
|
||||||
|
@ -343,7 +343,7 @@ 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
|
for valid annotations only in cases where all of the ``**kwargs`` were of the
|
||||||
same type.
|
same type.
|
||||||
|
|
||||||
This PEP specifies a more precise way of typing ``**kwargs`` by relying on
|
:pep:`692` specifies a more precise way of typing ``**kwargs`` by relying on
|
||||||
typed dictionaries::
|
typed dictionaries::
|
||||||
|
|
||||||
from typing import TypedDict, Unpack
|
from typing import TypedDict, Unpack
|
||||||
|
@ -387,6 +387,8 @@ Example::
|
||||||
def get_colour(self) -> str:
|
def get_colour(self) -> str:
|
||||||
return "red"
|
return "red"
|
||||||
|
|
||||||
|
See :pep:`698` for more details.
|
||||||
|
|
||||||
(Contributed by Steven Troxler in :gh:`101561`.)
|
(Contributed by Steven Troxler in :gh:`101561`.)
|
||||||
|
|
||||||
.. _whatsnew312-pep695:
|
.. _whatsnew312-pep695:
|
||||||
|
@ -432,8 +434,8 @@ parameters with bounds or constraints::
|
||||||
|
|
||||||
The value of type aliases and the bound and constraints of type variables
|
The value of type aliases and the bound and constraints of type variables
|
||||||
created through this syntax are evaluated only on demand (see
|
created through this syntax are evaluated only on demand (see
|
||||||
:ref:`lazy-evaluation`). This means type aliases are able to refer to other
|
:ref:`lazy evaluation <lazy-evaluation>`). This means type aliases are able to
|
||||||
types defined later in the file.
|
refer to other types defined later in the file.
|
||||||
|
|
||||||
Type parameters declared through a type parameter list are visible within the
|
Type parameters declared through a type parameter list are visible within the
|
||||||
scope of the declaration and any nested scopes, but not in the outer scope. For
|
scope of the declaration and any nested scopes, but not in the outer scope. For
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue