Skip to content

Commit a39068b

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. (cherry picked from commit 9129af6) Co-authored-by: kj <[email protected]>
1 parent b626d22 commit a39068b

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
@@ -509,7 +509,8 @@ These can be used as types in annotations using ``[]``, each having a unique syn
509509
is equivalent to ``Tuple[Any, ...]``, and in turn to :class:`tuple`.
510510

511511
.. deprecated:: 3.9
512-
:class:`builtins.tuple <tuple>` now supports ``[]``. See :pep:`585`.
512+
:class:`builtins.tuple <tuple>` now supports ``[]``. See :pep:`585` and
513+
:ref:`types-genericalias`.
513514

514515
.. data:: Union
515516

@@ -583,7 +584,8 @@ These can be used as types in annotations using ``[]``, each having a unique syn
583584
:class:`collections.abc.Callable`.
584585

585586
.. deprecated:: 3.9
586-
:class:`collections.abc.Callable` now supports ``[]``. See :pep:`585`.
587+
:class:`collections.abc.Callable` now supports ``[]``. See :pep:`585` and
588+
:ref:`types-genericalias`.
587589

588590
.. class:: Type(Generic[CT_co])
589591

@@ -628,7 +630,8 @@ These can be used as types in annotations using ``[]``, each having a unique syn
628630
.. versionadded:: 3.5.2
629631

630632
.. deprecated:: 3.9
631-
:class:`builtins.type <type>` now supports ``[]``. See :pep:`585`.
633+
:class:`builtins.type <type>` now supports ``[]``. See :pep:`585` and
634+
:ref:`types-genericalias`.
632635

633636
.. data:: Literal
634637

@@ -1060,7 +1063,8 @@ Corresponding to built-in types
10601063
...
10611064

10621065
.. deprecated:: 3.9
1063-
:class:`builtins.dict <dict>` now supports ``[]``. See :pep:`585`.
1066+
:class:`builtins.dict <dict>` now supports ``[]``. See :pep:`585` and
1067+
:ref:`types-genericalias`.
10641068

10651069
.. class:: List(list, MutableSequence[T])
10661070

@@ -1080,7 +1084,8 @@ Corresponding to built-in types
10801084
return [item for item in vector if item > 0]
10811085

10821086
.. deprecated:: 3.9
1083-
:class:`builtins.list <list>` now supports ``[]``. See :pep:`585`.
1087+
:class:`builtins.list <list>` now supports ``[]``. See :pep:`585` and
1088+
:ref:`types-genericalias`.
10841089

10851090
.. class:: Set(set, MutableSet[T])
10861091

@@ -1089,14 +1094,16 @@ Corresponding to built-in types
10891094
to use an abstract collection type such as :class:`AbstractSet`.
10901095

10911096
.. deprecated:: 3.9
1092-
:class:`builtins.set <set>` now supports ``[]``. See :pep:`585`.
1097+
:class:`builtins.set <set>` now supports ``[]``. See :pep:`585` and
1098+
:ref:`types-genericalias`.
10931099

10941100
.. class:: FrozenSet(frozenset, AbstractSet[T_co])
10951101

10961102
A generic version of :class:`builtins.frozenset <frozenset>`.
10971103

10981104
.. deprecated:: 3.9
1099-
:class:`builtins.frozenset <frozenset>` now supports ``[]``. See :pep:`585`.
1105+
:class:`builtins.frozenset <frozenset>` now supports ``[]``. See
1106+
:pep:`585` and :ref:`types-genericalias`.
11001107

11011108
.. note:: :data:`Tuple` is a special form.
11021109

@@ -1110,7 +1117,8 @@ Corresponding to types in :mod:`collections`
11101117
.. versionadded:: 3.5.2
11111118

11121119
.. deprecated:: 3.9
1113-
:class:`collections.defaultdict` now supports ``[]``. See :pep:`585`.
1120+
:class:`collections.defaultdict` now supports ``[]``. See :pep:`585` and
1121+
:ref:`types-genericalias`.
11141122

11151123
.. class:: OrderedDict(collections.OrderedDict, MutableMapping[KT, VT])
11161124

@@ -1119,7 +1127,8 @@ Corresponding to types in :mod:`collections`
11191127
.. versionadded:: 3.7.2
11201128

11211129
.. deprecated:: 3.9
1122-
:class:`collections.OrderedDict` now supports ``[]``. See :pep:`585`.
1130+
:class:`collections.OrderedDict` now supports ``[]``. See :pep:`585` and
1131+
:ref:`types-genericalias`.
11231132

11241133
.. class:: ChainMap(collections.ChainMap, MutableMapping[KT, VT])
11251134

@@ -1129,7 +1138,8 @@ Corresponding to types in :mod:`collections`
11291138
.. versionadded:: 3.6.1
11301139

11311140
.. deprecated:: 3.9
1132-
:class:`collections.ChainMap` now supports ``[]``. See :pep:`585`.
1141+
:class:`collections.ChainMap` now supports ``[]``. See :pep:`585` and
1142+
:ref:`types-genericalias`.
11331143

11341144
.. class:: Counter(collections.Counter, Dict[T, int])
11351145

@@ -1139,7 +1149,8 @@ Corresponding to types in :mod:`collections`
11391149
.. versionadded:: 3.6.1
11401150

11411151
.. deprecated:: 3.9
1142-
:class:`collections.Counter` now supports ``[]``. See :pep:`585`.
1152+
:class:`collections.Counter` now supports ``[]``. See :pep:`585` and
1153+
:ref:`types-genericalias`.
11431154

11441155
.. class:: Deque(deque, MutableSequence[T])
11451156

@@ -1149,7 +1160,8 @@ Corresponding to types in :mod:`collections`
11491160
.. versionadded:: 3.6.1
11501161

11511162
.. deprecated:: 3.9
1152-
:class:`collections.deque` now supports ``[]``. See :pep:`585`.
1163+
:class:`collections.deque` now supports ``[]``. See :pep:`585` and
1164+
:ref:`types-genericalias`.
11531165

11541166
Other concrete types
11551167
""""""""""""""""""""
@@ -1174,7 +1186,8 @@ Other concrete types
11741186
``Match[bytes]``. These types are also in the ``typing.re`` namespace.
11751187

11761188
.. deprecated:: 3.9
1177-
Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``. See :pep:`585`.
1189+
Classes ``Pattern`` and ``Match`` from :mod:`re` now support ``[]``.
1190+
See :pep:`585` and :ref:`types-genericalias`.
11781191

11791192
.. class:: Text
11801193

@@ -1201,7 +1214,8 @@ Corresponding to collections in :mod:`collections.abc`
12011214
A generic version of :class:`collections.abc.Set`.
12021215

12031216
.. deprecated:: 3.9
1204-
:class:`collections.abc.Set` now supports ``[]``. See :pep:`585`.
1217+
:class:`collections.abc.Set` now supports ``[]``. See :pep:`585` and
1218+
:ref:`types-genericalias`.
12051219

12061220
.. class:: ByteString(Sequence[int])
12071221

@@ -1214,7 +1228,8 @@ Corresponding to collections in :mod:`collections.abc`
12141228
annotate arguments of any of the types mentioned above.
12151229

12161230
.. deprecated:: 3.9
1217-
:class:`collections.abc.ByteString` now supports ``[]``. See :pep:`585`.
1231+
:class:`collections.abc.ByteString` now supports ``[]``. See :pep:`585`
1232+
and :ref:`types-genericalias`.
12181233

12191234
.. class:: Collection(Sized, Iterable[T_co], Container[T_co])
12201235

@@ -1223,28 +1238,32 @@ Corresponding to collections in :mod:`collections.abc`
12231238
.. versionadded:: 3.6.0
12241239

12251240
.. deprecated:: 3.9
1226-
:class:`collections.abc.Collection` now supports ``[]``. See :pep:`585`.
1241+
:class:`collections.abc.Collection` now supports ``[]``. See :pep:`585`
1242+
and :ref:`types-genericalias`.
12271243

12281244
.. class:: Container(Generic[T_co])
12291245

12301246
A generic version of :class:`collections.abc.Container`.
12311247

12321248
.. deprecated:: 3.9
1233-
:class:`collections.abc.Container` now supports ``[]``. See :pep:`585`.
1249+
:class:`collections.abc.Container` now supports ``[]``. See :pep:`585`
1250+
and :ref:`types-genericalias`.
12341251

12351252
.. class:: ItemsView(MappingView, Generic[KT_co, VT_co])
12361253

12371254
A generic version of :class:`collections.abc.ItemsView`.
12381255

12391256
.. deprecated:: 3.9
1240-
:class:`collections.abc.ItemsView` now supports ``[]``. See :pep:`585`.
1257+
:class:`collections.abc.ItemsView` now supports ``[]``. See :pep:`585`
1258+
and :ref:`types-genericalias`.
12411259

12421260
.. class:: KeysView(MappingView[KT_co], AbstractSet[KT_co])
12431261

12441262
A generic version of :class:`collections.abc.KeysView`.
12451263

12461264
.. deprecated:: 3.9
1247-
:class:`collections.abc.KeysView` now supports ``[]``. See :pep:`585`.
1265+
:class:`collections.abc.KeysView` now supports ``[]``. See :pep:`585`
1266+
and :ref:`types-genericalias`.
12481267

12491268
.. class:: Mapping(Sized, Collection[KT], Generic[VT_co])
12501269

@@ -1255,49 +1274,56 @@ Corresponding to collections in :mod:`collections.abc`
12551274
return word_list[word]
12561275

12571276
.. deprecated:: 3.9
1258-
:class:`collections.abc.Mapping` now supports ``[]``. See :pep:`585`.
1277+
:class:`collections.abc.Mapping` now supports ``[]``. See :pep:`585`
1278+
and :ref:`types-genericalias`.
12591279

12601280
.. class:: MappingView(Sized, Iterable[T_co])
12611281

12621282
A generic version of :class:`collections.abc.MappingView`.
12631283

12641284
.. deprecated:: 3.9
1265-
:class:`collections.abc.MappingView` now supports ``[]``. See :pep:`585`.
1285+
:class:`collections.abc.MappingView` now supports ``[]``. See :pep:`585`
1286+
and :ref:`types-genericalias`.
12661287

12671288
.. class:: MutableMapping(Mapping[KT, VT])
12681289

12691290
A generic version of :class:`collections.abc.MutableMapping`.
12701291

12711292
.. deprecated:: 3.9
1272-
:class:`collections.abc.MutableMapping` now supports ``[]``. See :pep:`585`.
1293+
:class:`collections.abc.MutableMapping` now supports ``[]``. See
1294+
:pep:`585` and :ref:`types-genericalias`.
12731295

12741296
.. class:: MutableSequence(Sequence[T])
12751297

12761298
A generic version of :class:`collections.abc.MutableSequence`.
12771299

12781300
.. deprecated:: 3.9
1279-
:class:`collections.abc.MutableSequence` now supports ``[]``. See :pep:`585`.
1301+
:class:`collections.abc.MutableSequence` now supports ``[]``. See
1302+
:pep:`585` and :ref:`types-genericalias`.
12801303

12811304
.. class:: MutableSet(AbstractSet[T])
12821305

12831306
A generic version of :class:`collections.abc.MutableSet`.
12841307

12851308
.. deprecated:: 3.9
1286-
:class:`collections.abc.MutableSet` now supports ``[]``. See :pep:`585`.
1309+
:class:`collections.abc.MutableSet` now supports ``[]``. See :pep:`585`
1310+
and :ref:`types-genericalias`.
12871311

12881312
.. class:: Sequence(Reversible[T_co], Collection[T_co])
12891313

12901314
A generic version of :class:`collections.abc.Sequence`.
12911315

12921316
.. deprecated:: 3.9
1293-
:class:`collections.abc.Sequence` now supports ``[]``. See :pep:`585`.
1317+
:class:`collections.abc.Sequence` now supports ``[]``. See :pep:`585`
1318+
and :ref:`types-genericalias`.
12941319

12951320
.. class:: ValuesView(MappingView[VT_co])
12961321

12971322
A generic version of :class:`collections.abc.ValuesView`.
12981323

12991324
.. deprecated:: 3.9
1300-
:class:`collections.abc.ValuesView` now supports ``[]``. See :pep:`585`.
1325+
:class:`collections.abc.ValuesView` now supports ``[]``. See :pep:`585`
1326+
and :ref:`types-genericalias`.
13011327

13021328
Corresponding to other types in :mod:`collections.abc`
13031329
""""""""""""""""""""""""""""""""""""""""""""""""""""""
@@ -1307,14 +1333,16 @@ Corresponding to other types in :mod:`collections.abc`
13071333
A generic version of :class:`collections.abc.Iterable`.
13081334

13091335
.. deprecated:: 3.9
1310-
:class:`collections.abc.Iterable` now supports ``[]``. See :pep:`585`.
1336+
:class:`collections.abc.Iterable` now supports ``[]``. See :pep:`585`
1337+
and :ref:`types-genericalias`.
13111338

13121339
.. class:: Iterator(Iterable[T_co])
13131340

13141341
A generic version of :class:`collections.abc.Iterator`.
13151342

13161343
.. deprecated:: 3.9
1317-
:class:`collections.abc.Iterator` now supports ``[]``. See :pep:`585`.
1344+
:class:`collections.abc.Iterator` now supports ``[]``. See :pep:`585`
1345+
and :ref:`types-genericalias`.
13181346

13191347
.. class:: Generator(Iterator[T_co], Generic[T_co, T_contra, V_co])
13201348

@@ -1348,7 +1376,8 @@ Corresponding to other types in :mod:`collections.abc`
13481376
start += 1
13491377

13501378
.. deprecated:: 3.9
1351-
:class:`collections.abc.Generator` now supports ``[]``. See :pep:`585`.
1379+
:class:`collections.abc.Generator` now supports ``[]``. See :pep:`585`
1380+
and :ref:`types-genericalias`.
13521381

13531382
.. class:: Hashable
13541383

@@ -1359,7 +1388,8 @@ Corresponding to other types in :mod:`collections.abc`
13591388
A generic version of :class:`collections.abc.Reversible`.
13601389

13611390
.. deprecated:: 3.9
1362-
:class:`collections.abc.Reversible` now supports ``[]``. See :pep:`585`.
1391+
:class:`collections.abc.Reversible` now supports ``[]``. See :pep:`585`
1392+
and :ref:`types-genericalias`.
13631393

13641394
.. class:: Sized
13651395

@@ -1384,7 +1414,8 @@ Asynchronous programming
13841414
.. versionadded:: 3.5.3
13851415

13861416
.. deprecated:: 3.9
1387-
:class:`collections.abc.Coroutine` now supports ``[]``. See :pep:`585`.
1417+
:class:`collections.abc.Coroutine` now supports ``[]``. See :pep:`585`
1418+
and :ref:`types-genericalias`.
13881419

13891420
.. class:: AsyncGenerator(AsyncIterator[T_co], Generic[T_co, T_contra])
13901421

@@ -1420,7 +1451,8 @@ Asynchronous programming
14201451
.. versionadded:: 3.6.1
14211452

14221453
.. deprecated:: 3.9
1423-
:class:`collections.abc.AsyncGenerator` now supports ``[]``. See :pep:`585`.
1454+
:class:`collections.abc.AsyncGenerator` now supports ``[]``. See
1455+
:pep:`585` and :ref:`types-genericalias`.
14241456

14251457
.. class:: AsyncIterable(Generic[T_co])
14261458

@@ -1429,7 +1461,8 @@ Asynchronous programming
14291461
.. versionadded:: 3.5.2
14301462

14311463
.. deprecated:: 3.9
1432-
:class:`collections.abc.AsyncIterable` now supports ``[]``. See :pep:`585`.
1464+
:class:`collections.abc.AsyncIterable` now supports ``[]``. See :pep:`585`
1465+
and :ref:`types-genericalias`.
14331466

14341467
.. class:: AsyncIterator(AsyncIterable[T_co])
14351468

@@ -1438,7 +1471,8 @@ Asynchronous programming
14381471
.. versionadded:: 3.5.2
14391472

14401473
.. deprecated:: 3.9
1441-
:class:`collections.abc.AsyncIterator` now supports ``[]``. See :pep:`585`.
1474+
:class:`collections.abc.AsyncIterator` now supports ``[]``. See :pep:`585`
1475+
and :ref:`types-genericalias`.
14421476

14431477
.. class:: Awaitable(Generic[T_co])
14441478

@@ -1447,7 +1481,8 @@ Asynchronous programming
14471481
.. versionadded:: 3.5.2
14481482

14491483
.. deprecated:: 3.9
1450-
:class:`collections.abc.Awaitable` now supports ``[]``. See :pep:`585`.
1484+
:class:`collections.abc.Awaitable` now supports ``[]``. See :pep:`585`
1485+
and :ref:`types-genericalias`.
14511486

14521487

14531488
Context manager types
@@ -1461,7 +1496,8 @@ Context manager types
14611496
.. versionadded:: 3.6.0
14621497

14631498
.. deprecated:: 3.9
1464-
:class:`contextlib.AbstractContextManager` now supports ``[]``. See :pep:`585`.
1499+
:class:`contextlib.AbstractContextManager` now supports ``[]``. See
1500+
:pep:`585` and :ref:`types-genericalias`.
14651501

14661502
.. class:: AsyncContextManager(Generic[T_co])
14671503

@@ -1471,7 +1507,8 @@ Context manager types
14711507
.. versionadded:: 3.6.2
14721508

14731509
.. deprecated:: 3.9
1474-
:class:`contextlib.AbstractAsyncContextManager` now supports ``[]``. See :pep:`585`.
1510+
:class:`contextlib.AbstractAsyncContextManager` now supports ``[]``. See
1511+
:pep:`585` and :ref:`types-genericalias`.
14751512

14761513
Protocols
14771514
---------

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)