Clarify callable assignability to require consistent parameter mapping#2247
Open
BHUVANSH855 wants to merge 4 commits intopython:mainfrom
Open
Clarify callable assignability to require consistent parameter mapping#2247BHUVANSH855 wants to merge 4 commits intopython:mainfrom
BHUVANSH855 wants to merge 4 commits intopython:mainfrom
Conversation
carljm
requested changes
Apr 7, 2026
Member
carljm
left a comment
There was a problem hiding this comment.
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.
…r mapping" This reverts commit e01d065.
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. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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.