Skip to content

Commit 311c7ff

Browse files
committed
Clarify: variadic positional parameters can be expressed with Callable
1 parent b40321c commit 311c7ff

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

docs/spec/callables.rst

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -453,8 +453,8 @@ a function within a type expression. The syntax is
453453

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

459459
Meaning of ``...`` in ``Callable``
460460
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -535,6 +535,14 @@ to be :term:`consistent` with any input parameters::
535535
f3: CallbackWithInt[...] = cb # OK
536536
f4: CallbackWithStr[...] = cb # Error
537537

538+
539+
Variadic positional parameter types can be defined with ``...`` in combination
540+
with an unpacked tuple of the form ``tuple[int, ...]``. The first argument
541+
specifies the type of the variadic parameters. For example, the
542+
following defines a callable that accepts any amount of integer arguments::
543+
544+
type VarCallback = Callable[[*tuple[int, ...]], None]
545+
538546
.. _`callback-protocols`:
539547

540548
Callback protocols

0 commit comments

Comments
 (0)