Skip to content

fix(solver): keep explicit positional params under gradual *args/**kwargs - #5424

Open
mangeshraut712 wants to merge 6 commits into
meta:mainfrom
mangeshraut712:fix/callable-gradual-variadic-prefix-5194
Open

mangeshraut712 wants to merge 6 commits into
meta:mainfrom
mangeshraut712:fix/callable-gradual-variadic-prefix-5194

Conversation

@mangeshraut712

Copy link
Copy Markdown
Contributor

Summary

Callables that end in *args: Any, **kwargs: Any but also declare an explicit positional prefix were still treated as fully gradual. Soft gradual subtyping swallowed every SubsetError from the positional prefix check, so a Prefixed protocol/function with value: str, /, *args: Any, **kwargs: Any was accepted as Callable[[int], None].

Only SubsetError::Other is softened under non-strict gradual callable subtyping. Positional prefix mismatches now use a dedicated error that still fails the check.

Fixes #5194

  • I am a human, and I fully understand the code I am submitting.

Test Plan

Added test_gradual_variadic_params_keep_explicit_prefix in test/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

…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
@meta-codesync

meta-codesync Bot commented Oct 28, 2026

Copy link
Copy Markdown
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.)

@github-actions github-actions Bot added size/s and removed size/s labels Oct 28, 2026
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).
@github-actions github-actions Bot added size/s and removed size/s labels Oct 28, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added size/s and removed size/s labels Nov 1, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added size/s and removed size/s labels Nov 2, 2026
@github-actions

This comment has been minimized.

@github-actions github-actions Bot added size/s and removed size/s labels Nov 2, 2026
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown

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

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Callable assignability ignores explicit positional parameters when the signature ends in *args: Any, **kwargs: Any

2 participants