Skip to content

Commit 563f2ca

Browse files
authored
Move generator and context manager backports out of the “Pure aliases” docs (#834)
1 parent 295c9bc commit 563f2ca

1 file changed

Lines changed: 52 additions & 39 deletions

File tree

‎doc/index.rst‎

Lines changed: 52 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -770,13 +770,63 @@ Special typing primitives
770770
Abstract Base Classes
771771
~~~~~~~~~~~~~~~~~~~~~
772772

773+
.. class:: AsyncContextManager
774+
775+
See :py:class:`typing.AsyncContextManager`. In ``typing`` since 3.5.4 and 3.6.2.
776+
777+
``typing_extensions`` backports the optional second type parameter added
778+
in Python 3.13. It specifies the type of the result of awaiting
779+
``__aexit__()`` and defaults to ``bool | None``.
780+
781+
.. versionchanged:: 4.12.0
782+
783+
Added the second type parameter.
784+
785+
.. class:: AsyncGenerator
786+
787+
See :py:class:`typing.AsyncGenerator`. In ``typing`` since 3.6.1.
788+
789+
``typing_extensions`` backports the Python 3.13 default of ``None`` for
790+
the second type parameter (the send type). This makes ``AsyncGenerator[int]``
791+
equivalent to ``AsyncGenerator[int, None]``.
792+
793+
.. versionchanged:: 4.12.0
794+
795+
Made the second type parameter optional.
796+
773797
.. class:: Buffer
774798

775799
See :py:class:`collections.abc.Buffer`. Added to the standard library
776800
in Python 3.12.
777801

778802
.. versionadded:: 4.6.0
779803

804+
.. class:: ContextManager
805+
806+
See :py:class:`typing.ContextManager`. In ``typing`` since 3.5.4.
807+
808+
``typing_extensions`` backports the optional second type parameter added
809+
in Python 3.13. It specifies the return type of ``__exit__()`` and
810+
defaults to ``bool | None``.
811+
812+
.. versionchanged:: 4.12.0
813+
814+
Added the second type parameter.
815+
816+
.. class:: Generator
817+
818+
See :py:class:`typing.Generator`. In ``typing`` since 3.5.
819+
820+
``typing_extensions`` backports the Python 3.13 defaults for the second
821+
(send) and third (return) type parameters. Both default to ``None``, so
822+
``Generator[int]`` is equivalent to ``Generator[int, None, None]``.
823+
824+
.. versionadded:: 4.7.0
825+
826+
.. versionchanged:: 4.12.0
827+
828+
Made the second and third type parameters optional.
829+
780830
Protocols
781831
~~~~~~~~~
782832

@@ -1278,8 +1328,8 @@ Sentinel objects
12781328
Pure aliases
12791329
~~~~~~~~~~~~
12801330

1281-
Most of these are simply re-exported from the :mod:`typing` module on all supported
1282-
versions of Python, but all are listed here for completeness.
1331+
These names are re-exported directly from :mod:`typing` on all supported
1332+
versions of Python where they are available.
12831333

12841334
.. class:: AbstractSet
12851335

@@ -1301,23 +1351,6 @@ versions of Python, but all are listed here for completeness.
13011351

13021352
.. versionadded:: 4.7.0
13031353

1304-
.. class:: AsyncContextManager
1305-
1306-
See :py:class:`typing.AsyncContextManager`. In ``typing`` since 3.5.4 and 3.6.2.
1307-
1308-
.. versionchanged:: 4.12.0
1309-
1310-
``AsyncContextManager`` now has an optional second parameter, defaulting to
1311-
``Optional[bool]``, signifying the return type of the ``__aexit__`` method.
1312-
1313-
.. class:: AsyncGenerator
1314-
1315-
See :py:class:`typing.AsyncGenerator`. In ``typing`` since 3.6.1.
1316-
1317-
.. versionchanged:: 4.12.0
1318-
1319-
The second type parameter is now optional (it defaults to ``None``).
1320-
13211354
.. class:: AsyncIterable
13221355

13231356
See :py:class:`typing.AsyncIterable`. In ``typing`` since 3.5.2.
@@ -1362,15 +1395,6 @@ versions of Python, but all are listed here for completeness.
13621395

13631396
.. versionadded:: 4.7.0
13641397

1365-
.. class:: ContextManager
1366-
1367-
See :py:class:`typing.ContextManager`. In ``typing`` since 3.5.4.
1368-
1369-
.. versionchanged:: 4.12.0
1370-
1371-
``ContextManager`` now has an optional second parameter, defaulting to
1372-
``Optional[bool]``, signifying the return type of the ``__exit__`` method.
1373-
13741398
.. class:: Coroutine
13751399

13761400
See :py:class:`typing.Coroutine`. In ``typing`` since 3.5.3.
@@ -1409,17 +1433,6 @@ versions of Python, but all are listed here for completeness.
14091433

14101434
.. versionadded:: 4.7.0
14111435

1412-
.. class:: Generator
1413-
1414-
See :py:class:`typing.Generator`.
1415-
1416-
.. versionadded:: 4.7.0
1417-
1418-
.. versionchanged:: 4.12.0
1419-
1420-
The second type and third type parameters are now optional
1421-
(they both default to ``None``).
1422-
14231436
.. class:: Generic
14241437

14251438
See :py:class:`typing.Generic`.

0 commit comments

Comments
 (0)