|
19 | 19 |
|
20 | 20 | This module provides runtime support for type hints. The most fundamental
|
21 | 21 | 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 |
23 | 23 | :pep:`484`. For a simplified introduction to type hints, see :pep:`483`.
|
24 | 24 |
|
25 | 25 |
|
@@ -587,7 +587,7 @@ The module defines the following classes, functions and decorators.
|
587 | 587 | when the checked program targets Python 3.9 or newer.
|
588 | 588 |
|
589 | 589 | 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. |
591 | 591 | See details in :pep:`585`—*Type Hinting Generics In Standard Collections*.
|
592 | 592 |
|
593 | 593 |
|
@@ -1286,6 +1286,8 @@ These are not used in annotations. They are building blocks for creating generic
|
1286 | 1286 | U = TypeVar('U', bound=str|bytes) # Can be any subtype of the union str|bytes
|
1287 | 1287 | V = TypeVar('V', bound=SupportsAbs) # Can be anything with an __abs__ method
|
1288 | 1288 |
|
| 1289 | +.. _typing-constrained-typevar: |
| 1290 | + |
1289 | 1291 | Using a *constrained* type variable, however, means that the ``TypeVar``
|
1290 | 1292 | can only ever be solved as being exactly one of the constraints given::
|
1291 | 1293 |
|
@@ -1528,7 +1530,7 @@ These are not used in annotations. They are building blocks for creating generic
|
1528 | 1530 |
|
1529 | 1531 | .. data:: AnyStr
|
1530 | 1532 |
|
1531 |
| - ``AnyStr`` is a :class:`constrained type variable <TypeVar>` defined as |
| 1533 | + ``AnyStr`` is a :ref:`constrained type variable <typing-constrained-typevar>` defined as |
1532 | 1534 | ``AnyStr = TypeVar('AnyStr', str, bytes)``.
|
1533 | 1535 |
|
1534 | 1536 | It is meant to be used for functions that may accept any kind of string
|
@@ -2072,7 +2074,7 @@ Other concrete types
|
2072 | 2074 | Python 2 is no longer supported, and most type checkers also no longer
|
2073 | 2075 | support type checking Python 2 code. Removal of the alias is not
|
2074 | 2076 | currently planned, but users are encouraged to use
|
2075 |
| - :class:`str` instead of ``Text`` wherever possible. |
| 2077 | + :class:`str` instead of ``Text``. |
2076 | 2078 |
|
2077 | 2079 | Abstract Base Classes
|
2078 | 2080 | ---------------------
|
|
0 commit comments