Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minor improvements to typing docs #104465

Merged
merged 2 commits into from
May 14, 2023
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 6 additions & 4 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@

This module provides runtime support for type hints. The most fundamental
support consists of the types :data:`Any`, :data:`Union`, :data:`Callable`,
:class:`TypeVar`, and :class:`Generic`. For a full specification, please see
:class:`TypeVar`, and :class:`Generic`. For a specification, please see
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not a full specification any more, considering how much we've added since.

:pep:`484`. For a simplified introduction to type hints, see :pep:`483`.


Expand Down Expand Up @@ -592,7 +592,7 @@ The module defines the following classes, functions and decorators.
when the checked program targets Python 3.9 or newer.

The deprecated types will be removed from the :mod:`typing` module
in the first Python version released 5 years after the release of Python 3.9.0.
no sooner than the first Python version released 5 years after the release of Python 3.9.0.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This would be 3.13 I believe, and I don't think we're going to remove them in 3.13.

See details in :pep:`585`—*Type Hinting Generics In Standard Collections*.


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

.. _typing-constrained-typevar:

Using a *constrained* type variable, however, means that the ``TypeVar``
can only ever be solved as being exactly one of the constraints given::

Expand Down Expand Up @@ -1550,7 +1552,7 @@ These are not used in annotations. They are building blocks for creating generic

.. data:: AnyStr

``AnyStr`` is a :class:`constrained type variable <TypeVar>` defined as
``AnyStr`` is a :ref:`constrained type variable <_typing-constrained-typevar>` defined as
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This link was incorrectly shown in monospace font. I took the opportunity to link to a more specific place.

``AnyStr = TypeVar('AnyStr', str, bytes)``.

It is meant to be used for functions that may accept any kind of string
Expand Down Expand Up @@ -2112,7 +2114,7 @@ Other concrete types
Python 2 is no longer supported, and most type checkers also no longer
support type checking Python 2 code. Removal of the alias is not
currently planned, but users are encouraged to use
:class:`str` instead of ``Text`` wherever possible.
:class:`str` instead of ``Text``.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The only reason I can think of why it wouldn't be possible is that you're still supporting Python 2, and we don't need to care about that.


Abstract Base Classes
---------------------
Expand Down