typing: Improve documentation of generic classes and aliases (#105369)

This commit is contained in:
Alex Waygood 2023-06-07 15:02:40 +01:00 committed by GitHub
parent 76883af6bf
commit d63a7c3694
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 91 additions and 65 deletions

View file

@ -2543,11 +2543,13 @@ Callable = _CallableType(collections.abc.Callable, 2)
Callable.__doc__ = \
"""Deprecated alias to collections.abc.Callable.
Callable[[int], str] signifies a function of (int) -> str.
Callable[[int], str] signifies a function that takes a single
parameter of type int and returns a str.
The subscription syntax must always be used with exactly two
values: the argument list and the return type.
The argument list must be a list of types, a ParamSpec or ellipsis.
The return type must be a single type.
The argument list must be a list of types, a ParamSpec,
Concatenate or ellipsis. The return type must be a single type.
There is no syntax to indicate optional or keyword arguments;
such function types are rarely used as callback types.