Skip to content

Commit a161c2e

Browse files
committed
Move PEP 747 TypeForm from 'Removed' to 'Improved modules'
1 parent 03c01a7 commit a161c2e

File tree

1 file changed

+26
-22
lines changed

1 file changed

+26
-22
lines changed

Doc/whatsnew/3.15.rst

Lines changed: 26 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1126,14 +1126,39 @@ tomllib
11261126

11271127

11281128
types
1129-
------
1129+
-----
11301130

11311131
* Expose the write-through :func:`locals` proxy type
11321132
as :data:`types.FrameLocalsProxyType`.
11331133
This represents the type of the :attr:`frame.f_locals` attribute,
11341134
as described in :pep:`667`.
11351135

11361136

1137+
typing
1138+
------
1139+
1140+
.. _whatsnew315-typeform:
1141+
1142+
* :pep:`747`: Add :data:`~typing.TypeForm`, a new special form for annotating
1143+
values that are themselves type expressions.
1144+
``TypeForm[T]`` means "a type form object describing ``T`` (or a type
1145+
assignable to ``T``)". At runtime, ``TypeForm(x)`` simply returns ``x``,
1146+
which allows explicit annotation of type-form values without changing
1147+
behavior.
1148+
1149+
This helps libraries that accept user-provided type expressions
1150+
(for example ``int``, ``str | None``, :class:`~typing.TypedDict`
1151+
classes, or ``list[int]``) expose precise signatures:
1152+
1153+
.. code-block:: python
1154+
1155+
from typing import Any, TypeForm
1156+
1157+
def cast[T](typ: TypeForm[T], value: Any) -> T: ...
1158+
1159+
(Contributed by Jelle Zijlstra in :gh:`145033`.)
1160+
1161+
11371162
unicodedata
11381163
-----------
11391164

@@ -1458,27 +1483,6 @@ typing
14581483
:class:`!typing.ByteString` has been deprecated since Python 3.9, and is
14591484
scheduled for removal in Python 3.17.
14601485

1461-
.. _whatsnew315-typeform:
1462-
1463-
* :pep:`747`: Add :data:`~typing.TypeForm`, a new special form for annotating
1464-
values that are themselves type expressions.
1465-
``TypeForm[T]`` means "a type form object describing ``T`` (or a type
1466-
assignable to ``T``)". At runtime, ``TypeForm(x)`` simply returns ``x``,
1467-
which allows explicit annotation of type-form values without changing
1468-
behavior.
1469-
1470-
This helps libraries that accept user-provided type expressions
1471-
(for example ``int``, ``str | None``, :class:`~typing.TypedDict`
1472-
classes, or ``list[int]``) expose precise signatures:
1473-
1474-
.. code-block:: python
1475-
1476-
from typing import Any, TypeForm
1477-
1478-
def cast[T](typ: TypeForm[T], value: Any) -> T: ...
1479-
1480-
(Contributed by Jelle Zijlstra in :gh:`145033`.)
1481-
14821486
* The undocumented keyword argument syntax for creating
14831487
:class:`~typing.NamedTuple` classes (for example,
14841488
``Point = NamedTuple("Point", x=int, y=int)``) is no longer supported.

0 commit comments

Comments
 (0)