Skip to content

Commit 9129af6

Browse files
bpo-42198: Link to GenericAlias in typing and expressions (GH-23030)
Follow up to 7cdf30f and 4173320. This addresses the point "1. Update links in typing, subscription and union to point to GenericAlias." in the bpo for this PR.
1 parent 3317466 commit 9129af6

File tree

2 files changed

+75
-44
lines changed

2 files changed

+75
-44
lines changed

Doc/library/typing.rst

Lines changed: 74 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -524,7 +524,8 @@ These can be used as types in annotations using ``[]``, each having a unique syn
524524
is equivalent to ``Tuple[Any, ...]``, and in turn to :class:`tuple`.
525525

526526
.. deprecated:: 3.9
527-
:class:`builtins.tuple <tuple>` now supports ``[]``. See :pep:`585`.
527+
:class:`builtins.tuple <tuple>` now supports ``[]``. See :pep:`585` and
528+
:ref:`types-genericalias`.
528529

529530
.. data:: Union
530531

@@ -602,7 +603,8 @@ These can be used as types in annotations using ``[]``, each having a unique syn
602603
:class:`collections.abc.Callable`.
603604

604605
.. deprecated:: 3.9
605-
:class:`collections.abc.Callable` now supports ``[]``. See :pep:`585`.
606+
:class:`collections.abc.Callable` now supports ``[]``. See :pep:`585` and
607+
:ref:`types-genericalias`.
606608

607609
.. class:: Type(Generic[CT_co])
608610

@@ -647,7 +649,8 @@ These can be used as types in annotations using ``[]``, each having a unique syn
647649
.. versionadded:: 3.5.2
648650

649651
.. deprecated:: 3.9
650-
:class:`builtins.type <type>` now supports ``[]``. See :pep:`585`.
652+
:class:`builtins.type <type>` now supports ``[]``. See :pep:`585` and
653+
:ref:`types-genericalias`.
651654

652655
.. data:: Literal
653656

@@ -1079,7 +1082,8 @@ Corresponding to built-in types
10791082
...
10801083

10811084
.. deprecated:: 3.9
1082-
:class:`builtins.dict <dict>` now supports ``[]``. See :pep:`585`.
1085+
:class:`builtins.dict <dict>` now supports ``[]``. See :pep:`585` and
1086+
:ref:`types-genericalias`.
10831087

10841088
.. class:: List(list, MutableSequence[T])
10851089

@@ -1099,7 +1103,8 @@ Corresponding to built-in types
10991103
return [item for item in vector if item > 0]
11001104

11011105
.. deprecated:: 3.9
1102-
:class:`builtins.list <list>` now supports ``[]``. See :pep:`585`.
1106+
:class:`builtins.list <list>` now supports ``[]``. See :pep:`585` and
1107+
:ref:`types-genericalias`.
11031108

11041109
.. class:: Set(set, MutableSet[T])
11051110

@@ -1108,14 +1113,16 @@ Corresponding to built-in types
11081113
to use an abstract collection type such as :class:`AbstractSet`.
11091114

11101115
.. deprecated:: 3.9
1111-
:class:`builtins.set <set>` now supports ``[]``. See :pep:`585`.
1116+
:class:`builtins.set <set>` now supports ``[]``. See :pep:`585` and
1117+
:ref:`types-genericalias`.
11121118

11131119
.. class:: FrozenSet(frozenset, AbstractSet[T_co])
11141120

11151121
A generic version of :class:`builtins.frozenset <frozenset>`.
11161122

11171123
.. deprecated:: 3.9
1118-
:class:`builtins.frozenset <frozenset>` now supports ``[]``. See :pep:`585`.
1124+
:class:`builtins.frozenset <frozenset>` now supports ``[]``. See
1125+
:pep:`585` and :ref:`types-genericalias`.
11191126

11201127
.. note:: :data:`Tuple` is a special form.
11211128

@@ -1129,7 +1136,8 @@ Corresponding to types in :mod:`collections`
11291136
.. versionadded:: 3.5.2
11301137

11311138
.. deprecated:: 3.9
1132-
:class:`collections.defaultdict` now supports ``[]``. See :pep:`585`.
1139+
:class:`collections.defaultdict` now supports ``[]``. See :pep:`585` and
1140+
:ref:`types-genericalias`.
11331141

11341142
.. class:: OrderedDict(collections.OrderedDict, MutableMapping[KT, VT])
11351143

@@ -1138,7 +1146,8 @@ Corresponding to types in :mod:`collections`
11381146
.. versionadded:: 3.7.2
11391147

11401148
.. deprecated:: 3.9
1141-
:class:`collections.OrderedDict` now supports ``[]``. See :pep:`585`.
1149+
:class:`collections.OrderedDict` now supports ``[]``. See :pep:`585` and
1150+
:ref:`types-genericalias`.
11421151

11431152
.. class:: ChainMap(collections.ChainMap, MutableMapping[KT, VT])
11441153

@@ -1148,7 +1157,8 @@ Corresponding to types in :mod:`collections`
11481157
.. versionadded:: 3.6.1
11491158

11501159
.. deprecated:: 3.9
1151-
:class:`collections.ChainMap` now supports ``[]``. See :pep:`585`.
1160+
:class:`collections.ChainMap` now supports ``[]``. See :pep:`585` and
1161+
:ref:`types-genericalias`.
11521162

11531163
.. class:: Counter(collections.Counter, Dict[T, int])
11541164

@@ -1158,7 +1168,8 @@ Corresponding to types in :mod:`collections`
11581168
.. versionadded:: 3.6.1
11591169

11601170
.. deprecated:: 3.9
1161-
:class:`collections.Counter` now supports ``[]``. See :pep:`585`.
1171+
:class:`collections.Counter` now supports ``[]``. See :pep:`585` and
1172+
:ref:`types-genericalias`.
11621173

11631174
.. class:: Deque(deque, MutableSequence[T])
11641175

@@ -1168,7 +1179,8 @@ Corresponding to types in :mod:`collections`
11681179
.. versionadded:: 3.6.1
11691180

11701181
.. deprecated:: 3.9
1171-
:class:`collections.deque` now supports ``[]``. See :pep:`585`.
1182+
:class:`collections.deque` now supports ``[]``. See :pep:`585` and
1183+
:ref:`types-genericalias`.
11721184

11731185
Other concrete types
11741186
""""""""""""""""""""
@@ -1193,7 +1205,8 @@ Other concrete types
11931205
``Match[bytes]``. These types are also in the ``typing.re`` namespace.
11941206

11951207
.. deprecated:: 3.9
1196-
Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``. See :pep:`585`.
1208+
Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``.
1209+
See :pep:`585` and :ref:`types-genericalias`.
11971210

11981211
.. class:: Text
11991212

@@ -1220,7 +1233,8 @@ Corresponding to collections in :mod:`collections.abc`
12201233
A generic version of :class:`collections.abc.Set`.
12211234

12221235
.. deprecated:: 3.9
1223-
:class:`collections.abc.Set` now supports ``[]``. See :pep:`585`.
1236+
:class:`collections.abc.Set` now supports ``[]``. See :pep:`585` and
1237+
:ref:`types-genericalias`.
12241238

12251239
.. class:: ByteString(Sequence[int])
12261240

@@ -1233,7 +1247,8 @@ Corresponding to collections in :mod:`collections.abc`
12331247
annotate arguments of any of the types mentioned above.
12341248

12351249
.. deprecated:: 3.9
1236-
:class:`collections.abc.ByteString` now supports ``[]``. See :pep:`585`.
1250+
:class:`collections.abc.ByteString` now supports ``[]``. See :pep:`585`
1251+
and :ref:`types-genericalias`.
12371252

12381253
.. class:: Collection(Sized, Iterable[T_co], Container[T_co])
12391254

@@ -1242,28 +1257,32 @@ Corresponding to collections in :mod:`collections.abc`
12421257
.. versionadded:: 3.6.0
12431258

12441259
.. deprecated:: 3.9
1245-
:class:`collections.abc.Collection` now supports ``[]``. See :pep:`585`.
1260+
:class:`collections.abc.Collection` now supports ``[]``. See :pep:`585`
1261+
and :ref:`types-genericalias`.
12461262

12471263
.. class:: Container(Generic[T_co])
12481264

12491265
A generic version of :class:`collections.abc.Container`.
12501266

12511267
.. deprecated:: 3.9
1252-
:class:`collections.abc.Container` now supports ``[]``. See :pep:`585`.
1268+
:class:`collections.abc.Container` now supports ``[]``. See :pep:`585`
1269+
and :ref:`types-genericalias`.
12531270

12541271
.. class:: ItemsView(MappingView, Generic[KT_co, VT_co])
12551272

12561273
A generic version of :class:`collections.abc.ItemsView`.
12571274

12581275
.. deprecated:: 3.9
1259-
:class:`collections.abc.ItemsView` now supports ``[]``. See :pep:`585`.
1276+
:class:`collections.abc.ItemsView` now supports ``[]``. See :pep:`585`
1277+
and :ref:`types-genericalias`.
12601278

12611279
.. class:: KeysView(MappingView[KT_co], AbstractSet[KT_co])
12621280

12631281
A generic version of :class:`collections.abc.KeysView`.
12641282

12651283
.. deprecated:: 3.9
1266-
:class:`collections.abc.KeysView` now supports ``[]``. See :pep:`585`.
1284+
:class:`collections.abc.KeysView` now supports ``[]``. See :pep:`585`
1285+
and :ref:`types-genericalias`.
12671286

12681287
.. class:: Mapping(Sized, Collection[KT], Generic[VT_co])
12691288

@@ -1274,49 +1293,56 @@ Corresponding to collections in :mod:`collections.abc`
12741293
return word_list[word]
12751294

12761295
.. deprecated:: 3.9
1277-
:class:`collections.abc.Mapping` now supports ``[]``. See :pep:`585`.
1296+
:class:`collections.abc.Mapping` now supports ``[]``. See :pep:`585`
1297+
and :ref:`types-genericalias`.
12781298

12791299
.. class:: MappingView(Sized, Iterable[T_co])
12801300

12811301
A generic version of :class:`collections.abc.MappingView`.
12821302

12831303
.. deprecated:: 3.9
1284-
:class:`collections.abc.MappingView` now supports ``[]``. See :pep:`585`.
1304+
:class:`collections.abc.MappingView` now supports ``[]``. See :pep:`585`
1305+
and :ref:`types-genericalias`.
12851306

12861307
.. class:: MutableMapping(Mapping[KT, VT])
12871308

12881309
A generic version of :class:`collections.abc.MutableMapping`.
12891310

12901311
.. deprecated:: 3.9
1291-
:class:`collections.abc.MutableMapping` now supports ``[]``. See :pep:`585`.
1312+
:class:`collections.abc.MutableMapping` now supports ``[]``. See
1313+
:pep:`585` and :ref:`types-genericalias`.
12921314

12931315
.. class:: MutableSequence(Sequence[T])
12941316

12951317
A generic version of :class:`collections.abc.MutableSequence`.
12961318

12971319
.. deprecated:: 3.9
1298-
:class:`collections.abc.MutableSequence` now supports ``[]``. See :pep:`585`.
1320+
:class:`collections.abc.MutableSequence` now supports ``[]``. See
1321+
:pep:`585` and :ref:`types-genericalias`.
12991322

13001323
.. class:: MutableSet(AbstractSet[T])
13011324

13021325
A generic version of :class:`collections.abc.MutableSet`.
13031326

13041327
.. deprecated:: 3.9
1305-
:class:`collections.abc.MutableSet` now supports ``[]``. See :pep:`585`.
1328+
:class:`collections.abc.MutableSet` now supports ``[]``. See :pep:`585`
1329+
and :ref:`types-genericalias`.
13061330

13071331
.. class:: Sequence(Reversible[T_co], Collection[T_co])
13081332

13091333
A generic version of :class:`collections.abc.Sequence`.
13101334

13111335
.. deprecated:: 3.9
1312-
:class:`collections.abc.Sequence` now supports ``[]``. See :pep:`585`.
1336+
:class:`collections.abc.Sequence` now supports ``[]``. See :pep:`585`
1337+
and :ref:`types-genericalias`.
13131338

13141339
.. class:: ValuesView(MappingView[VT_co])
13151340

13161341
A generic version of :class:`collections.abc.ValuesView`.
13171342

13181343
.. deprecated:: 3.9
1319-
:class:`collections.abc.ValuesView` now supports ``[]``. See :pep:`585`.
1344+
:class:`collections.abc.ValuesView` now supports ``[]``. See :pep:`585`
1345+
and :ref:`types-genericalias`.
13201346

13211347
Corresponding to other types in :mod:`collections.abc`
13221348
""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -1326,14 +1352,16 @@ Corresponding to other types in :mod:`collections.abc`
13261352
A generic version of :class:`collections.abc.Iterable`.
13271353

13281354
.. deprecated:: 3.9
1329-
:class:`collections.abc.Iterable` now supports ``[]``. See :pep:`585`.
1355+
:class:`collections.abc.Iterable` now supports ``[]``. See :pep:`585`
1356+
and :ref:`types-genericalias`.
13301357

13311358
.. class:: Iterator(Iterable[T_co])
13321359

13331360
A generic version of :class:`collections.abc.Iterator`.
13341361

13351362
.. deprecated:: 3.9
1336-
:class:`collections.abc.Iterator` now supports ``[]``. See :pep:`585`.
1363+
:class:`collections.abc.Iterator` now supports ``[]``. See :pep:`585`
1364+
and :ref:`types-genericalias`.
13371365

13381366
.. class:: Generator(Iterator[T_co], Generic[T_co, T_contra, V_co])
13391367

@@ -1367,7 +1395,8 @@ Corresponding to other types in :mod:`collections.abc`
13671395
start += 1
13681396

13691397
.. deprecated:: 3.9
1370-
:class:`collections.abc.Generator` now supports ``[]``. See :pep:`585`.
1398+
:class:`collections.abc.Generator` now supports ``[]``. See :pep:`585`
1399+
and :ref:`types-genericalias`.
13711400

13721401
.. class:: Hashable
13731402

@@ -1378,7 +1407,8 @@ Corresponding to other types in :mod:`collections.abc`
13781407
A generic version of :class:`collections.abc.Reversible`.
13791408

13801409
.. deprecated:: 3.9
1381-
:class:`collections.abc.Reversible` now supports ``[]``. See :pep:`585`.
1410+
:class:`collections.abc.Reversible` now supports ``[]``. See :pep:`585`
1411+
and :ref:`types-genericalias`.
13821412

13831413
.. class:: Sized
13841414

@@ -1403,7 +1433,8 @@ Asynchronous programming
14031433
.. versionadded:: 3.5.3
14041434

14051435
.. deprecated:: 3.9
1406-
:class:`collections.abc.Coroutine` now supports ``[]``. See :pep:`585`.
1436+
:class:`collections.abc.Coroutine` now supports ``[]``. See :pep:`585`
1437+
and :ref:`types-genericalias`.
14071438

14081439
.. class:: AsyncGenerator(AsyncIterator[T_co], Generic[T_co, T_contra])
14091440

@@ -1439,7 +1470,8 @@ Asynchronous programming
14391470
.. versionadded:: 3.6.1
14401471

14411472
.. deprecated:: 3.9
1442-
:class:`collections.abc.AsyncGenerator` now supports ``[]``. See :pep:`585`.
1473+
:class:`collections.abc.AsyncGenerator` now supports ``[]``. See
1474+
:pep:`585` and :ref:`types-genericalias`.
14431475

14441476
.. class:: AsyncIterable(Generic[T_co])
14451477

@@ -1448,7 +1480,8 @@ Asynchronous programming
14481480
.. versionadded:: 3.5.2
14491481

14501482
.. deprecated:: 3.9
1451-
:class:`collections.abc.AsyncIterable` now supports ``[]``. See :pep:`585`.
1483+
:class:`collections.abc.AsyncIterable` now supports ``[]``. See :pep:`585`
1484+
and :ref:`types-genericalias`.
14521485

14531486
.. class:: AsyncIterator(AsyncIterable[T_co])
14541487

@@ -1457,7 +1490,8 @@ Asynchronous programming
14571490
.. versionadded:: 3.5.2
14581491

14591492
.. deprecated:: 3.9
1460-
:class:`collections.abc.AsyncIterator` now supports ``[]``. See :pep:`585`.
1493+
:class:`collections.abc.AsyncIterator` now supports ``[]``. See :pep:`585`
1494+
and :ref:`types-genericalias`.
14611495

14621496
.. class:: Awaitable(Generic[T_co])
14631497

@@ -1466,7 +1500,8 @@ Asynchronous programming
14661500
.. versionadded:: 3.5.2
14671501

14681502
.. deprecated:: 3.9
1469-
:class:`collections.abc.Awaitable` now supports ``[]``. See :pep:`585`.
1503+
:class:`collections.abc.Awaitable` now supports ``[]``. See :pep:`585`
1504+
and :ref:`types-genericalias`.
14701505

14711506

14721507
Context manager types
@@ -1480,7 +1515,8 @@ Context manager types
14801515
.. versionadded:: 3.6.0
14811516

14821517
.. deprecated:: 3.9
1483-
:class:`contextlib.AbstractContextManager` now supports ``[]``. See :pep:`585`.
1518+
:class:`contextlib.AbstractContextManager` now supports ``[]``. See
1519+
:pep:`585` and :ref:`types-genericalias`.
14841520

14851521
.. class:: AsyncContextManager(Generic[T_co])
14861522

@@ -1490,7 +1526,8 @@ Context manager types
14901526
.. versionadded:: 3.6.2
14911527

14921528
.. deprecated:: 3.9
1493-
:class:`contextlib.AbstractAsyncContextManager` now supports ``[]``. See :pep:`585`.
1529+
:class:`contextlib.AbstractAsyncContextManager` now supports ``[]``. See
1530+
:pep:`585` and :ref:`types-genericalias`.
14941531

14951532
Protocols
14961533
---------

Doc/reference/expressions.rst

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -837,14 +837,8 @@ this method will need to explicitly add that support.
837837
A string's items are characters. A character is not a separate data type but a
838838
string of exactly one character.
839839

840-
..
841-
At the time of writing this, there is no documentation for generic alias
842-
or PEP 585. Thus the link currently points to PEP 585 itself.
843-
Please change the link for generic alias to reference the correct
844-
documentation once documentation for PEP 585 becomes available.
845-
846840
Subscription of certain :term:`classes <class>` or :term:`types <type>`
847-
creates a `generic alias <https://www.python.org/dev/peps/pep-0585/>`_.
841+
creates a :ref:`generic alias <types-genericalias>`.
848842
In this case, user-defined classes can support subscription by providing a
849843
:meth:`__class_getitem__` classmethod.
850844

0 commit comments

Comments
 (0)