Skip to content

Commit 12ca4d9

Browse files
committed
Replace all documentation which says "See PEP 585"
The following classes in the stdlib get simple updates: - array.array - asyncio.Future - asyncio.Task - collections.defaultdict - collections.deque - contextvars.ContextVar - contextvars.Token - ctypes.Array - os.DirEntry - re.Match - re.Pattern - string.templatelib.Interpolation - string.templatelib.Template - types.MappingProxyType - queue.SimpleQueue - weakref.ref The following classes are documented publicly as functions, and are therefore updated internally (`__class_getitem__.__doc__`) but not in the public docs: - functools.partial - itertools.chain The following builtin types have updates to `__class_getitem__.__doc__` but not to any documentation pages: - BaseExceptionGroup - coroutines (from generators) - dict - enumerate - frozendict - frozenset - generators (and async generators) - list - memoryview - set - slice - tuple Special cases: - union objects are now documented as "supporting class-level []", rather than anything to do with generics. - Templates might be generic over a single type (union, in theory) or over a TypeVarTuple. As this is not currently fully settled, it is marked with a comment and a mild hint that it is a single type is used (namely, "type" is singular rather than "types", plural)
1 parent fad0674 commit 12ca4d9

38 files changed

Lines changed: 103 additions & 33 deletions

Doc/c-api/typehints.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ two types exist -- :ref:`GenericAlias <types-genericalias>` and
3131
static PyMethodDef my_obj_methods[] = {
3232
// Other methods.
3333
...
34-
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, "See PEP 585"}
34+
{"__class_getitem__", Py_GenericAlias, METH_O|METH_CLASS, "my_obj is generic over its contained type"}
3535
...
3636
}
3737

Doc/library/array.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,8 @@ The module defines the following type:
134134
:exc:`TypeError` is raised. Array objects also implement the buffer interface,
135135
and may be used wherever :term:`bytes-like objects <bytes-like object>` are supported.
136136

137+
Arrays are :ref:`generic <generics>` over the type of their contents.
138+
137139
.. audit-event:: array.__new__ typecode,initializer array.array
138140

139141

Doc/library/asyncio-future.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -101,6 +101,8 @@ Future Object
101101
implementations can inject their own optimized implementations
102102
of a Future object.
103103

104+
Futures are :ref:`generic <generics>` over the type of their return value.
105+
104106
.. versionchanged:: 3.7
105107
Added support for the :mod:`contextvars` module.
106108

Doc/library/asyncio-task.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1230,6 +1230,9 @@ Task object
12301230
blocks. If the coroutine returns or raises without blocking, the task
12311231
will be finished eagerly and will skip scheduling to the event loop.
12321232

1233+
Tasks are :ref:`generic <generics>` over the return type of their contained
1234+
coroutine.
1235+
12331236
.. versionchanged:: 3.7
12341237
Added support for the :mod:`contextvars` module.
12351238

Doc/library/collections.rst

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -485,6 +485,9 @@ or subtracting from an empty counter.
485485
where only the most recent activity is of interest.
486486

487487

488+
deques are :ref:`generic <generics>` over the type of their contents.
489+
490+
488491
Deque objects support the following methods:
489492

490493
.. method:: append(item, /)
@@ -740,6 +743,10 @@ stack manipulations such as ``dup``, ``drop``, ``swap``, ``over``, ``pick``,
740743
arguments.
741744

742745

746+
defaultdicts are :ref:`generic <generics>` over two types, for the types of
747+
keys and values, respectively.
748+
749+
743750
:class:`defaultdict` objects support the following method in addition to the
744751
standard :class:`dict` operations:
745752

Doc/library/contextvars.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@ Context Variables
4242
references to context variables which prevents context variables
4343
from being properly garbage collected.
4444

45+
Context Variables are :ref:`generic <generics>` over the type of their value.
46+
4547
.. attribute:: ContextVar.name
4648

4749
The name of the variable. This is a read-only property.
@@ -130,6 +132,9 @@ Context Variables
130132
Tokens support the :ref:`context manager protocol <context-managers>`
131133
to automatically reset context variables. See :meth:`ContextVar.set`.
132134

135+
Tokens are :ref:`generic <generics>` over the same type as the
136+
:class:`ContextVar` which created them.
137+
133138
.. versionadded:: 3.14
134139

135140
Added support for usage as a context manager.

Doc/library/ctypes.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3171,6 +3171,7 @@ Arrays and pointers
31713171
subscript and slice accesses; for slice reads, the resulting object is
31723172
*not* itself an :class:`Array`.
31733173

3174+
Arrays are :ref:`generic <generics>` over the type of their values.
31743175

31753176
.. attribute:: _length_
31763177

Doc/library/os.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2994,6 +2994,9 @@ features:
29942994
To be directly usable as a :term:`path-like object`, ``os.DirEntry``
29952995
implements the :class:`PathLike` interface.
29962996

2997+
DirEntry objects are :ref:`generic <generics>` over the type of the path (str
2998+
or bytes).
2999+
29973000
Attributes and methods on a ``os.DirEntry`` instance are as follows:
29983001

29993002
.. attribute:: name

Doc/library/queue.rst

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -76,6 +76,8 @@ The :mod:`!queue` module defines the following classes and exceptions:
7676
Constructor for an unbounded :abbr:`FIFO (first-in, first-out)` queue.
7777
Simple queues lack advanced functionality such as task tracking.
7878

79+
Simple queues are :ref:`generic <generics>` over the type of their contents.
80+
7981
.. versionadded:: 3.7
8082

8183

Doc/library/re.rst

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1257,6 +1257,8 @@ Regular expression objects
12571257

12581258
Compiled regular expression object returned by :func:`re.compile`.
12591259

1260+
Patterns are :ref:`generic <generics>` over the type of string they handle (str or bytes).
1261+
12601262
.. versionchanged:: 3.9
12611263
:py:class:`re.Pattern` supports ``[]`` to indicate a Unicode (str) or bytes pattern.
12621264
See :ref:`types-genericalias`.
@@ -1419,6 +1421,9 @@ when there is no match, you can test whether there was a match with a simple
14191421

14201422
Match object returned by successful ``match``\ es and ``search``\ es.
14211423

1424+
Matches are :ref:`generic <generics>` over the type of string which was
1425+
matched (str or bytes).
1426+
14221427
.. versionchanged:: 3.9
14231428
:py:class:`re.Match` supports ``[]`` to indicate a Unicode (str) or bytes match.
14241429
See :ref:`types-genericalias`.

0 commit comments

Comments
 (0)