Repository navigation
fix(solver): keep explicit positional params under gradual *args/**kwargs - #5424
Open
mangeshraut712 wants to merge 4 commits into
Open
mangeshraut712 wants to merge 4 commits into
mangeshraut712 wants to merge 4 commits into
Conversation
…args When a callable ends in *args: Any, **kwargs: Any but also has an explicit positional prefix, assignability still has to check that prefix. Soft gradual subtyping was swallowing SubsetError from those positional checks; only SubsetError::Other should be softened. Fixes meta#5194
Contributor
|
This pull request has been imported. If you are a Meta employee, you can view this in D127980703. (Because this pull request was imported automatically, there will not be any future comments.) |
Soft-match: u_gradual (want/base) softens all param-list errors under non-strict callable subtyping so Child.method1() subtypes GradualBase ending in *args: Any, **kwargs: Any. Keep l_gradual limited to Other so explicit positional-prefix mismatches still fail (meta#5194).
This comment has been minimized.
This comment has been minimized.
|
According to mypy_primer, this change doesn't affect type check results on a corpus of open source code. ✅ |
This branch has not been deployed
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.
Summary
Callables that end in
*args: Any, **kwargs: Anybut also declare an explicit positional prefix were still treated as fully gradual. Soft gradual subtyping swallowed everySubsetErrorfrom the positional prefix check, so aPrefixedprotocol/function withvalue: str, /, *args: Any, **kwargs: Anywas accepted asCallable[[int], None].Only
SubsetError::Otheris softened under non-strict gradual callable subtyping. Positional prefix mismatches now use a dedicated error that still fails the check.Fixes #5194
Test Plan
Added
test_gradual_variadic_params_keep_explicit_prefixintest/callable.rs.cargo test -p pyrefly --lib -- test::callable::(154 passed)cargo test -p pyrefly --lib -- test::callable::test_gradual_variadic_params_keep_explicit_prefix