Skip to content

Commit 44838e5

Browse files
authored
Correct "Annotating callable objects"
1 parent 0c29f83 commit 44838e5

File tree

1 file changed

+9
-11
lines changed

1 file changed

+9
-11
lines changed

Doc/library/typing.rst

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ Annotating callable objects
209209

210210
Functions -- or other :term:`callable` objects -- can be annotated using
211211
:class:`collections.abc.Callable` or deprecated :data:`typing.Callable`.
212-
``Callable[[int], str]`` signifies a function that takes a single parameter
212+
``Callable[[int], str]`` signifies a function that has a single parameter
213213
of type :class:`int` and returns a :class:`str`.
214214

215215
For example:
@@ -232,12 +232,11 @@ For example:
232232

233233
.. index:: single: ...; ellipsis literal
234234

235-
The subscription syntax must always be used with exactly two values: the
236-
argument list and the return type. The argument list must be a list of types,
237-
a :class:`ParamSpec`, :data:`Concatenate`, or an ellipsis (``...``). The return type must
238-
be a single type.
235+
The type specification `[]` must have two objects, a parameter type list and return type.
236+
The parameter type list must be a list of types, :class:`ParamSpec`, :data:`Concatenate`
237+
or ellipsis (``...``). The return type must be a single type.
239238

240-
If a literal ellipsis ``...`` is given as the argument list, it indicates that
239+
If a literal ellipsis ``...`` is given as the parameter type list, it indicates that
241240
a callable with any arbitrary parameter list would be acceptable:
242241

243242
.. testcode::
@@ -249,10 +248,9 @@ a callable with any arbitrary parameter list would be acceptable:
249248
x = str # OK
250249
x = concat # Also OK
251250

252-
``Callable`` cannot express complex signatures such as functions that take a
253-
variadic number of arguments, :ref:`overloaded functions <overload>`, or
254-
functions that have keyword-only parameters. However, these signatures can be
255-
expressed by defining a :class:`Protocol` class with a
251+
``Callable`` cannot express complex signatures such as functions that have
252+
keyword-only or var-positional parameters, or :ref:`overloaded functions <overload>`.
253+
However, these signatures can be expressed by defining a :class:`Protocol` class with a
256254
:meth:`~object.__call__` method:
257255

258256
.. testcode::
@@ -281,7 +279,7 @@ parameter types are dependent on each other using :class:`ParamSpec`.
281279
Additionally, if that callable adds or removes arguments from other
282280
callables, the :data:`Concatenate` operator may be used. They
283281
take the form ``Callable[ParamSpecVariable, ReturnType]`` and
284-
``Callable[Concatenate[Arg1Type, Arg2Type, ..., ParamSpecVariable], ReturnType]``
282+
``Callable[Concatenate[Param1Type, Arg2Type, ..., ParamSpecVariable], ReturnType]``
285283
respectively.
286284

287285
.. versionchanged:: 3.10

0 commit comments

Comments
 (0)