Skip to content
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
13 changes: 11 additions & 2 deletions docs/spec/callables.rst
Original file line number Diff line number Diff line change
Expand Up @@ -453,8 +453,8 @@ a function within a type expression. The syntax is

Parameters specified using ``Callable`` are assumed to be positional-only.
The ``Callable`` form provides no way to specify keyword-only parameters,
variadic parameters, or default argument values. For these use cases, see
the section on `Callback protocols`_.
or default argument values. For these use cases, see the section on
`Callback protocols`_.

Meaning of ``...`` in ``Callable``
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
Expand Down Expand Up @@ -535,6 +535,15 @@ to be :term:`consistent` with any input parameters::
f3: CallbackWithInt[...] = cb # OK
f4: CallbackWithStr[...] = cb # Error


Variadic positional parameter types can be defined with with an unpacked tuple
of the form ``*tuple[int, ...]`` in the parameter list. The first argument
specifies the type of the variadic parameters.
For example, the following defines a callable that accepts any number of integer
arguments::

type VarCallback = Callable[[*tuple[int, ...]], None]

.. _`callback-protocols`:

Callback protocols
Expand Down