Skip to content

Clarify callable assignability to require consistent parameter mapping#2247

Open
BHUVANSH855 wants to merge 4 commits intopython:mainfrom
BHUVANSH855:fix-callable-parameter-mapping
Open

Clarify callable assignability to require consistent parameter mapping#2247
BHUVANSH855 wants to merge 4 commits intopython:mainfrom
BHUVANSH855:fix-callable-parameter-mapping

Conversation

@BHUVANSH855
Copy link
Copy Markdown

Fixes #2224

The current typing spec states that a callable type B is assignable to a callable type A if B accepts all possible combinations of arguments that A accepts. However, it does not explicitly define whether the mapping between parameters must remain consistent across different call patterns.

In practice, all major type checkers (mypy, pyright, etc.) reject cases where parameter mapping is non-constant, even if all valid calls are technically accepted.

This PR clarifies the spec by stating that callable assignability requires a consistent parameter mapping. If arguments map to different parameters depending on how they are passed (positional vs keyword), the callable is not considered assignable.

This aligns the spec with existing type checker behavior and resolves the ambiguity highlighted in the issue.

@srittau srittau added the topic: typing spec For improving the typing spec label Apr 7, 2026
Copy link
Copy Markdown
Member

@carljm carljm left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this is the direction we should go in the spec. It seems to me that the requirement for a constant mapping is a quality-of-implementation issue. What the spec already describes is the intended and desired behavior; implementations just aren't fully implementing it. The spec should not prohibit a type checker from attempting to do better.

@BHUVANSH855
Copy link
Copy Markdown
Author

Thanks for the feedback @carljm,

That makes sense — I understand that the spec describes the intended behavior, even if current type checkers don't fully support it.

I've updated the PR to remove the spec change and instead added a conformance test capturing this scenario, so the gap between the spec and current implementations is made explicit.

@BHUVANSH855 BHUVANSH855 requested a review from carljm April 8, 2026 06:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

topic: typing spec For improving the typing spec

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Spec/Conformance: subtyping callables with non-constant parameter mapping.

3 participants