Skip to content

Commit e01d065

Browse files
committed
Clarify callable assignability to require consistent parameter mapping
1 parent 9ba065d commit e01d065

File tree

1 file changed

+19
-1
lines changed

1 file changed

+19
-1
lines changed

docs/spec/callables.rst

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ 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-
or default argument values. For these use cases, see the section on
456+
or default argument values. For these use cases, see the section on
457457
`Callback protocols`_.
458458

459459
Meaning of ``...`` in ``Callable``
@@ -581,6 +581,24 @@ signature of ``B`` accepts all possible combinations of arguments that the
581581
input signature of ``A`` accepts. All of the specific assignability rules
582582
described below derive from this general rule.
583583

584+
Parameter Mapping Consistency
585+
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
586+
587+
For a callable type ``B`` to be :term:`assignable` to a callable type ``A``,
588+
the mapping between parameters in ``A`` and ``B`` should be
589+
consistent across all valid call signatures.
590+
591+
In particular, each argument accepted by ``A`` should correspond
592+
to a single, well-defined parameter in ``B``, regardless of whether
593+
arguments are passed positionally or by keyword.
594+
595+
If the correspondence between parameters in ``A`` and ``B`` varies depending
596+
on how arguments are provided, then the callable types are not considered
597+
assignable.
598+
599+
For example, if different valid call patterns for ``A`` result in arguments
600+
being mapped to different parameters in ``B``, this constitutes a
601+
non-constant parameter mapping and is not assignable.
584602

585603
Parameter types
586604
^^^^^^^^^^^^^^^

0 commit comments

Comments
 (0)