summaryrefslogtreecommitdiffstats
path: root/Doc
diff options
context:
space:
mode:
authorMiss Skeleton (bot) <31488909+miss-islington@users.noreply.github.com>2020-10-30 04:23:33 (GMT)
committerGitHub <noreply@github.com>2020-10-30 04:23:33 (GMT)
commita39068bf48766e5520e175eae8cda33531e16039 (patch)
treeec757b5a5b581ed641ffe29ba85fd2394269d53e /Doc
parentb626d2218c03127502025ccdf93d555e0487ea95 (diff)
downloadcpython-a39068bf48766e5520e175eae8cda33531e16039.zip
cpython-a39068bf48766e5520e175eae8cda33531e16039.tar.gz
cpython-a39068bf48766e5520e175eae8cda33531e16039.tar.bz2
bpo-42198: Link to GenericAlias in typing and expressions (GH-23030)
Follow up to 7cdf30fff39ea97f403b5472096349998d190e30 and 4173320920706b49a004bdddd8d7108e8984e3fc. This addresses the point "1. Update links in typing, subscription and union to point to GenericAlias." in the bpo for this PR. (cherry picked from commit 9129af6050b747f288baa9d4e7d43031647ed222) Co-authored-by: kj <28750310+Fidget-Spinner@users.noreply.github.com>
Diffstat (limited to 'Doc')
-rw-r--r--Doc/library/typing.rst111
-rw-r--r--Doc/reference/expressions.rst8
2 files changed, 75 insertions, 44 deletions
diff --git a/Doc/library/typing.rst b/Doc/library/typing.rst
index 67e8a3f..a5f8b04 100644
--- a/Doc/library/typing.rst
+++ b/Doc/library/typing.rst
@@ -509,7 +509,8 @@ These can be used as types in annotations using ``[]``, each having a unique syn
is equivalent to ``Tuple[Any, ...]``, and in turn to :class:`tuple`.
.. deprecated:: 3.9
- :class:`builtins.tuple <tuple>` now supports ``[]``. See :pep:`585`.
+ :class:`builtins.tuple <tuple>` now supports ``[]``. See :pep:`585` and
+ :ref:`types-genericalias`.
.. data:: Union
@@ -583,7 +584,8 @@ These can be used as types in annotations using ``[]``, each having a unique syn
:class:`collections.abc.Callable`.
.. deprecated:: 3.9
- :class:`collections.abc.Callable` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.Callable` now supports ``[]``. See :pep:`585` and
+ :ref:`types-genericalias`.
.. class:: Type(Generic[CT_co])
@@ -628,7 +630,8 @@ These can be used as types in annotations using ``[]``, each having a unique syn
.. versionadded:: 3.5.2
.. deprecated:: 3.9
- :class:`builtins.type <type>` now supports ``[]``. See :pep:`585`.
+ :class:`builtins.type <type>` now supports ``[]``. See :pep:`585` and
+ :ref:`types-genericalias`.
.. data:: Literal
@@ -1060,7 +1063,8 @@ Corresponding to built-in types
...
.. deprecated:: 3.9
- :class:`builtins.dict <dict>` now supports ``[]``. See :pep:`585`.
+ :class:`builtins.dict <dict>` now supports ``[]``. See :pep:`585` and
+ :ref:`types-genericalias`.
.. class:: List(list, MutableSequence[T])
@@ -1080,7 +1084,8 @@ Corresponding to built-in types
return [item for item in vector if item > 0]
.. deprecated:: 3.9
- :class:`builtins.list <list>` now supports ``[]``. See :pep:`585`.
+ :class:`builtins.list <list>` now supports ``[]``. See :pep:`585` and
+ :ref:`types-genericalias`.
.. class:: Set(set, MutableSet[T])
@@ -1089,14 +1094,16 @@ Corresponding to built-in types
to use an abstract collection type such as :class:`AbstractSet`.
.. deprecated:: 3.9
- :class:`builtins.set <set>` now supports ``[]``. See :pep:`585`.
+ :class:`builtins.set <set>` now supports ``[]``. See :pep:`585` and
+ :ref:`types-genericalias`.
.. class:: FrozenSet(frozenset, AbstractSet[T_co])
A generic version of :class:`builtins.frozenset <frozenset>`.
.. deprecated:: 3.9
- :class:`builtins.frozenset <frozenset>` now supports ``[]``. See :pep:`585`.
+ :class:`builtins.frozenset <frozenset>` now supports ``[]``. See
+ :pep:`585` and :ref:`types-genericalias`.
.. note:: :data:`Tuple` is a special form.
@@ -1110,7 +1117,8 @@ Corresponding to types in :mod:`collections`
.. versionadded:: 3.5.2
.. deprecated:: 3.9
- :class:`collections.defaultdict` now supports ``[]``. See :pep:`585`.
+ :class:`collections.defaultdict` now supports ``[]``. See :pep:`585` and
+ :ref:`types-genericalias`.
.. class:: OrderedDict(collections.OrderedDict, MutableMapping[KT, VT])
@@ -1119,7 +1127,8 @@ Corresponding to types in :mod:`collections`
.. versionadded:: 3.7.2
.. deprecated:: 3.9
- :class:`collections.OrderedDict` now supports ``[]``. See :pep:`585`.
+ :class:`collections.OrderedDict` now supports ``[]``. See :pep:`585` and
+ :ref:`types-genericalias`.
.. class:: ChainMap(collections.ChainMap, MutableMapping[KT, VT])
@@ -1129,7 +1138,8 @@ Corresponding to types in :mod:`collections`
.. versionadded:: 3.6.1
.. deprecated:: 3.9
- :class:`collections.ChainMap` now supports ``[]``. See :pep:`585`.
+ :class:`collections.ChainMap` now supports ``[]``. See :pep:`585` and
+ :ref:`types-genericalias`.
.. class:: Counter(collections.Counter, Dict[T, int])
@@ -1139,7 +1149,8 @@ Corresponding to types in :mod:`collections`
.. versionadded:: 3.6.1
.. deprecated:: 3.9
- :class:`collections.Counter` now supports ``[]``. See :pep:`585`.
+ :class:`collections.Counter` now supports ``[]``. See :pep:`585` and
+ :ref:`types-genericalias`.
.. class:: Deque(deque, MutableSequence[T])
@@ -1149,7 +1160,8 @@ Corresponding to types in :mod:`collections`
.. versionadded:: 3.6.1
.. deprecated:: 3.9
- :class:`collections.deque` now supports ``[]``. See :pep:`585`.
+ :class:`collections.deque` now supports ``[]``. See :pep:`585` and
+ :ref:`types-genericalias`.
Other concrete types
""""""""""""""""""""
@@ -1174,7 +1186,8 @@ Other concrete types
``Match[bytes]``. These types are also in the ``typing.re`` namespace.
.. deprecated:: 3.9
- Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``. See :pep:`585`.
+ Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``.
+ See :pep:`585` and :ref:`types-genericalias`.
.. class:: Text
@@ -1201,7 +1214,8 @@ Corresponding to collections in :mod:`collections.abc`
A generic version of :class:`collections.abc.Set`.
.. deprecated:: 3.9
- :class:`collections.abc.Set` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.Set` now supports ``[]``. See :pep:`585` and
+ :ref:`types-genericalias`.
.. class:: ByteString(Sequence[int])
@@ -1214,7 +1228,8 @@ Corresponding to collections in :mod:`collections.abc`
annotate arguments of any of the types mentioned above.
.. deprecated:: 3.9
- :class:`collections.abc.ByteString` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.ByteString` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: Collection(Sized, Iterable[T_co], Container[T_co])
@@ -1223,28 +1238,32 @@ Corresponding to collections in :mod:`collections.abc`
.. versionadded:: 3.6.0
.. deprecated:: 3.9
- :class:`collections.abc.Collection` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.Collection` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: Container(Generic[T_co])
A generic version of :class:`collections.abc.Container`.
.. deprecated:: 3.9
- :class:`collections.abc.Container` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.Container` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: ItemsView(MappingView, Generic[KT_co, VT_co])
A generic version of :class:`collections.abc.ItemsView`.
.. deprecated:: 3.9
- :class:`collections.abc.ItemsView` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.ItemsView` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: KeysView(MappingView[KT_co], AbstractSet[KT_co])
A generic version of :class:`collections.abc.KeysView`.
.. deprecated:: 3.9
- :class:`collections.abc.KeysView` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.KeysView` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: Mapping(Sized, Collection[KT], Generic[VT_co])
@@ -1255,49 +1274,56 @@ Corresponding to collections in :mod:`collections.abc`
return word_list[word]
.. deprecated:: 3.9
- :class:`collections.abc.Mapping` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.Mapping` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: MappingView(Sized, Iterable[T_co])
A generic version of :class:`collections.abc.MappingView`.
.. deprecated:: 3.9
- :class:`collections.abc.MappingView` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.MappingView` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: MutableMapping(Mapping[KT, VT])
A generic version of :class:`collections.abc.MutableMapping`.
.. deprecated:: 3.9
- :class:`collections.abc.MutableMapping` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.MutableMapping` now supports ``[]``. See
+ :pep:`585` and :ref:`types-genericalias`.
.. class:: MutableSequence(Sequence[T])
A generic version of :class:`collections.abc.MutableSequence`.
.. deprecated:: 3.9
- :class:`collections.abc.MutableSequence` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.MutableSequence` now supports ``[]``. See
+ :pep:`585` and :ref:`types-genericalias`.
.. class:: MutableSet(AbstractSet[T])
A generic version of :class:`collections.abc.MutableSet`.
.. deprecated:: 3.9
- :class:`collections.abc.MutableSet` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.MutableSet` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: Sequence(Reversible[T_co], Collection[T_co])
A generic version of :class:`collections.abc.Sequence`.
.. deprecated:: 3.9
- :class:`collections.abc.Sequence` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.Sequence` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: ValuesView(MappingView[VT_co])
A generic version of :class:`collections.abc.ValuesView`.
.. deprecated:: 3.9
- :class:`collections.abc.ValuesView` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.ValuesView` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
Corresponding to other types in :mod:`collections.abc`
""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -1307,14 +1333,16 @@ Corresponding to other types in :mod:`collections.abc`
A generic version of :class:`collections.abc.Iterable`.
.. deprecated:: 3.9
- :class:`collections.abc.Iterable` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.Iterable` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: Iterator(Iterable[T_co])
A generic version of :class:`collections.abc.Iterator`.
.. deprecated:: 3.9
- :class:`collections.abc.Iterator` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.Iterator` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: Generator(Iterator[T_co], Generic[T_co, T_contra, V_co])
@@ -1348,7 +1376,8 @@ Corresponding to other types in :mod:`collections.abc`
start += 1
.. deprecated:: 3.9
- :class:`collections.abc.Generator` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.Generator` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: Hashable
@@ -1359,7 +1388,8 @@ Corresponding to other types in :mod:`collections.abc`
A generic version of :class:`collections.abc.Reversible`.
.. deprecated:: 3.9
- :class:`collections.abc.Reversible` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.Reversible` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: Sized
@@ -1384,7 +1414,8 @@ Asynchronous programming
.. versionadded:: 3.5.3
.. deprecated:: 3.9
- :class:`collections.abc.Coroutine` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.Coroutine` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: AsyncGenerator(AsyncIterator[T_co], Generic[T_co, T_contra])
@@ -1420,7 +1451,8 @@ Asynchronous programming
.. versionadded:: 3.6.1
.. deprecated:: 3.9
- :class:`collections.abc.AsyncGenerator` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.AsyncGenerator` now supports ``[]``. See
+ :pep:`585` and :ref:`types-genericalias`.
.. class:: AsyncIterable(Generic[T_co])
@@ -1429,7 +1461,8 @@ Asynchronous programming
.. versionadded:: 3.5.2
.. deprecated:: 3.9
- :class:`collections.abc.AsyncIterable` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.AsyncIterable` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: AsyncIterator(AsyncIterable[T_co])
@@ -1438,7 +1471,8 @@ Asynchronous programming
.. versionadded:: 3.5.2
.. deprecated:: 3.9
- :class:`collections.abc.AsyncIterator` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.AsyncIterator` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
.. class:: Awaitable(Generic[T_co])
@@ -1447,7 +1481,8 @@ Asynchronous programming
.. versionadded:: 3.5.2
.. deprecated:: 3.9
- :class:`collections.abc.Awaitable` now supports ``[]``. See :pep:`585`.
+ :class:`collections.abc.Awaitable` now supports ``[]``. See :pep:`585`
+ and :ref:`types-genericalias`.
Context manager types
@@ -1461,7 +1496,8 @@ Context manager types
.. versionadded:: 3.6.0
.. deprecated:: 3.9
- :class:`contextlib.AbstractContextManager` now supports ``[]``. See :pep:`585`.
+ :class:`contextlib.AbstractContextManager` now supports ``[]``. See
+ :pep:`585` and :ref:`types-genericalias`.
.. class:: AsyncContextManager(Generic[T_co])
@@ -1471,7 +1507,8 @@ Context manager types
.. versionadded:: 3.6.2
.. deprecated:: 3.9
- :class:`contextlib.AbstractAsyncContextManager` now supports ``[]``. See :pep:`585`.
+ :class:`contextlib.AbstractAsyncContextManager` now supports ``[]``. See
+ :pep:`585` and :ref:`types-genericalias`.
Protocols
---------
diff --git a/Doc/reference/expressions.rst b/Doc/reference/expressions.rst
index 938a973..512aa5a 100644
--- a/Doc/reference/expressions.rst
+++ b/Doc/reference/expressions.rst
@@ -837,14 +837,8 @@ this method will need to explicitly add that support.
A string's items are characters. A character is not a separate data type but a
string of exactly one character.
-..
- At the time of writing this, there is no documentation for generic alias
- or PEP 585. Thus the link currently points to PEP 585 itself.
- Please change the link for generic alias to reference the correct
- documentation once documentation for PEP 585 becomes available.
-
Subscription of certain :term:`classes <class>` or :term:`types <type>`
-creates a `generic alias <https://www.python.org/dev/peps/pep-0585/>`_.
+creates a :ref:`generic alias <types-genericalias>`.
In this case, user-defined classes can support subscription by providing a
:meth:`__class_getitem__` classmethod.