|
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 |
|
@@ -592,7 +592,7 @@ The module defines the following classes, functions and decorators.
|
592 | 592 | when the checked program targets Python 3.9 or newer.
|
593 | 593 |
|
594 | 594 | The deprecated types will be removed from the :mod:`typing` module
|
595 |
| - in the first Python version released 5 years after the release of Python 3.9.0. |
| 595 | + no sooner than the first Python version released 5 years after the release of Python 3.9.0. |
596 | 596 | See details in :pep:`585`—*Type Hinting Generics In Standard Collections*.
|
597 | 597 |
|
598 | 598 |
|
@@ -1291,6 +1291,8 @@ These are not used in annotations. They are building blocks for creating generic
|
1291 | 1291 | U = TypeVar('U', bound=str|bytes) # Can be any subtype of the union str|bytes
|
1292 | 1292 | V = TypeVar('V', bound=SupportsAbs) # Can be anything with an __abs__ method
|
1293 | 1293 |
|
| 1294 | +.. _typing-constrained-typevar: |
| 1295 | + |
1294 | 1296 | Using a *constrained* type variable, however, means that the ``TypeVar``
|
1295 | 1297 | can only ever be solved as being exactly one of the constraints given::
|
1296 | 1298 |
|
@@ -1550,7 +1552,7 @@ These are not used in annotations. They are building blocks for creating generic
|
1550 | 1552 |
|
1551 | 1553 | .. data:: AnyStr
|
1552 | 1554 |
|
1553 |
| - ``AnyStr`` is a :class:`constrained type variable <TypeVar>` defined as |
| 1555 | + ``AnyStr`` is a :ref:`constrained type variable <typing-constrained-typevar>` defined as |
1554 | 1556 | ``AnyStr = TypeVar('AnyStr', str, bytes)``.
|
1555 | 1557 |
|
1556 | 1558 | It is meant to be used for functions that may accept any kind of string
|
@@ -2112,7 +2114,7 @@ Other concrete types
|
2112 | 2114 | Python 2 is no longer supported, and most type checkers also no longer
|
2113 | 2115 | support type checking Python 2 code. Removal of the alias is not
|
2114 | 2116 | currently planned, but users are encouraged to use
|
2115 |
| - :class:`str` instead of ``Text`` wherever possible. |
| 2117 | + :class:`str` instead of ``Text``. |
2116 | 2118 |
|
2117 | 2119 | Abstract Base Classes
|
2118 | 2120 | ---------------------
|
|
0 commit comments