Skip to content

Commit f5f9975

Browse files
[3.11] Minor improvements to typing docs (GH-104465) (#104475)
Minor improvements to typing docs (GH-104465) (cherry picked from commit 2f7b5e4) Co-authored-by: Jelle Zijlstra <[email protected]>
1 parent 03f0d75 commit f5f9975

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

Doc/library/typing.rst

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919

2020
This module provides runtime support for type hints. The most fundamental
2121
support consists of the types :data:`Any`, :data:`Union`, :data:`Callable`,
22-
:class:`TypeVar`, and :class:`Generic`. For a full specification, please see
22+
:class:`TypeVar`, and :class:`Generic`. For a specification, please see
2323
:pep:`484`. For a simplified introduction to type hints, see :pep:`483`.
2424

2525

@@ -587,7 +587,7 @@ The module defines the following classes, functions and decorators.
587587
when the checked program targets Python 3.9 or newer.
588588

589589
The deprecated types will be removed from the :mod:`typing` module
590-
in the first Python version released 5 years after the release of Python 3.9.0.
590+
no sooner than the first Python version released 5 years after the release of Python 3.9.0.
591591
See details in :pep:`585`—*Type Hinting Generics In Standard Collections*.
592592

593593

@@ -1286,6 +1286,8 @@ These are not used in annotations. They are building blocks for creating generic
12861286
U = TypeVar('U', bound=str|bytes) # Can be any subtype of the union str|bytes
12871287
V = TypeVar('V', bound=SupportsAbs) # Can be anything with an __abs__ method
12881288

1289+
.. _typing-constrained-typevar:
1290+
12891291
Using a *constrained* type variable, however, means that the ``TypeVar``
12901292
can only ever be solved as being exactly one of the constraints given::
12911293

@@ -1528,7 +1530,7 @@ These are not used in annotations. They are building blocks for creating generic
15281530

15291531
.. data:: AnyStr
15301532

1531-
``AnyStr`` is a :class:`constrained type variable <TypeVar>` defined as
1533+
``AnyStr`` is a :ref:`constrained type variable <typing-constrained-typevar>` defined as
15321534
``AnyStr = TypeVar('AnyStr', str, bytes)``.
15331535

15341536
It is meant to be used for functions that may accept any kind of string
@@ -2072,7 +2074,7 @@ Other concrete types
20722074
Python 2 is no longer supported, and most type checkers also no longer
20732075
support type checking Python 2 code. Removal of the alias is not
20742076
currently planned, but users are encouraged to use
2075-
:class:`str` instead of ``Text`` wherever possible.
2077+
:class:`str` instead of ``Text``.
20762078

20772079
Abstract Base Classes
20782080
---------------------

0 commit comments

Comments
 (0)