[3.12] gh-106745: typing docs: Clarify that removal of PEP-585 aliases is not currently planned (#106748) (#106772)

This commit is contained in:
Alex Waygood 2023-07-15 11:31:12 +01:00 committed by GitHub
parent 1fe841254e
commit e99b69c5ae
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -3053,6 +3053,7 @@ Constant
.. versionadded:: 3.5.2 .. versionadded:: 3.5.2
.. _generic-concrete-collections: .. _generic-concrete-collections:
.. _deprecated-aliases:
Deprecated aliases Deprecated aliases
------------------ ------------------
@ -3061,16 +3062,21 @@ This module defines several deprecated aliases to pre-existing
standard library classes. These were originally included in the typing standard library classes. These were originally included in the typing
module in order to support parameterizing these generic classes using ``[]``. module in order to support parameterizing these generic classes using ``[]``.
However, the aliases became redundant in Python 3.9 when the However, the aliases became redundant in Python 3.9 when the
corresponding pre-existing classes were enhanced to support ``[]``. corresponding pre-existing classes were enhanced to support ``[]`` (see
:pep:`585`).
The redundant types are deprecated as of Python 3.9 but no The redundant types are deprecated as of Python 3.9. However, while the aliases
deprecation warnings are issued by the interpreter. may be removed at some point, removal of these aliases is not currently
It is expected that type checkers will flag the deprecated types planned. As such, no deprecation warnings are currently issued by the
when the checked program targets Python 3.9 or newer. interpreter for these aliases.
The deprecated types will be removed from the :mod:`typing` module If at some point it is decided to remove these deprecated aliases, a
no sooner than the first Python version released 5 years after the release of Python 3.9.0. deprecation warning will be issued by the interpreter for at least two releases
See details in :pep:`585`*Type Hinting Generics In Standard Collections*. prior to removal. The aliases are guaranteed to remain in the typing module
without deprecation warnings until at least Python 3.14.
Type checkers are encouraged to flag uses of the deprecated types if the
program they are checking targets a minimum Python version of 3.9 or newer.
.. _corresponding-to-built-in-types: .. _corresponding-to-built-in-types:
@ -3611,21 +3617,34 @@ Certain features in ``typing`` are deprecated and may be removed in a future
version of Python. The following table summarizes major deprecations for your version of Python. The following table summarizes major deprecations for your
convenience. This is subject to change, and not all deprecations are listed. convenience. This is subject to change, and not all deprecations are listed.
+----------------------------------+---------------+-------------------+----------------+ .. list-table::
| Feature | Deprecated in | Projected removal | PEP/issue | :header-rows: 1
+==================================+===============+===================+================+
| ``typing.io`` and ``typing.re`` | 3.8 | 3.13 | :issue:`38291` | * - Feature
| submodules | | | | - Deprecated in
+----------------------------------+---------------+-------------------+----------------+ - Projected removal
| ``typing`` versions of standard | 3.9 | Undecided | :pep:`585` | - PEP/issue
| collections | | | | * - ``typing.io`` and ``typing.re`` submodules
+----------------------------------+---------------+-------------------+----------------+ - 3.8
| ``typing.ByteString`` | 3.9 | 3.14 | :gh:`91896` | - 3.13
+----------------------------------+---------------+-------------------+----------------+ - :issue:`38291`
| ``typing.Text`` | 3.11 | Undecided | :gh:`92332` | * - ``typing`` versions of standard collections
+----------------------------------+---------------+-------------------+----------------+ - 3.9
| ``typing.Hashable`` and | 3.12 | Undecided | :gh:`94309` | - Undecided (see :ref:`deprecated-aliases` for more information)
| ``typing.Sized`` | | | | - :pep:`585`
+----------------------------------+---------------+-------------------+----------------+ * - :class:`typing.ByteString`
| ``typing.TypeAlias`` | 3.12 | Undecided | :pep:`695` | - 3.9
+----------------------------------+---------------+-------------------+----------------+ - 3.14
- :gh:`91896`
* - :data:`typing.Text`
- 3.11
- Undecided
- :gh:`92332`
* - :class:`typing.Hashable` and :class:`typing.Sized`
- 3.12
- Undecided
- :gh:`94309`
* - :data:`typing.TypeAlias`
- 3.12
- Undecided
- :pep:`695`