Skip to content

bpo-28556: Clarify that Type[SomeTypeVar] is legal in typing docs #9585

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

Merged
Merged
Changes from all commits
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
9 changes: 6 additions & 3 deletions Doc/library/typing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,8 @@ It is possible to declare the return type of a callable without specifying
the call signature by substituting a literal ellipsis
for the list of arguments in the type hint: ``Callable[..., ReturnType]``.

.. _generics:

Generics
--------

Expand All @@ -183,7 +185,7 @@ subscription to denote expected types for container elements.
def notify_by_email(employees: Sequence[Employee],
overrides: Mapping[str, str]) -> None: ...

Generics can be parametrized by using a new factory available in typing
Generics can be parameterized by using a new factory available in typing
called :class:`TypeVar`.

::
Expand Down Expand Up @@ -488,8 +490,9 @@ The module defines the following classes, functions and decorators:
required to handle this particular case may change in future revisions of
:pep:`484`.

The only legal parameters for :class:`Type` are classes, unions of classes, and
:data:`Any`. For example::
The only legal parameters for :class:`Type` are classes, :data:`Any`,
:ref:`type variables <generics>`, and unions of any of these types.
For example::

def new_non_team_user(user_class: Type[Union[BaseUser, ProUser]]): ...

Expand Down