[ty] Fix bug where ty would think that a Callable with a variadic positional parameter could be a subtype of a Callable with a positional-or-keyword parameter#23610
Merged
AlexWaygood merged 2 commits intomainfrom Feb 27, 2026
Conversation
…rd params When a variadic (`*args`) parameter was matched against positional-or-keyword parameters from the supertype, those parameters were collected for keyword checking later. However, if both parameter iterators were exhausted simultaneously, the loop returned early without verifying that the keyword portion of those parameters could also be satisfied. This caused `(*args: int)` to incorrectly be considered a subtype of `(a: int)`, even though `a` can be passed as a keyword argument which `*args` cannot accept. The fix ensures that when unmatched keyword parameters exist, the loop breaks to the keyword-matching code instead of returning early. https://claude.ai/code/session_015KWJHraC4EMq4ruyp78ESc
Typing conformance results improved 🎉The percentage of diagnostics emitted that were expected errors increased from 85.39% to 85.40%. The percentage of expected errors that received a diagnostic increased from 75.46% to 75.55%. Summary
True positives addedDetails
|
Memory usage reportMemory usage unchanged ✅ |
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-method-override |
28 | 0 | 0 |
invalid-argument-type |
0 | 1 | 0 |
invalid-return-type |
1 | 0 | 0 |
| Total | 29 | 1 | 0 |
Member
Author
|
The new diagnostics are almost all |
carljm
added a commit
that referenced
this pull request
Feb 27, 2026
* main: [ty] Take myself out of the reviewer pool for the next few days (#23618) [ty] Fix bug where ty would think that a `Callable` with a variadic positional parameter could be a subtype of a `Callable` with a positional-or-keyword parameter (#23610) [`ruff`] Add fix for `none-not-at-end-of-union` (`RUF036`) (#22829) Bump cargo dist to 0.31 (#23614) [`pyflakes`] Fix false positive for names shadowing re-exports (`F811`) (#23356) [`fastapi`] Handle callable class dependencies with `__call__` method (`FAST003`) (#23553) [ty] Recurse into tuples and nested tuples when applying special-cased validation of `isinstance()` and `issubclass()` (#23607) Update typing conformance suite commit (#23606) [ty] Detect invalid uses of `@final` on non-methods (#23604) [ty] Move the type hierarchy request handlers to individual modules [ty] Wire up the type hierarchy implementation with the LSP [ty] Add routine for mapping from system path to vendored path [ty] Implement internal routines for providing the LSP "type hierarchy" feature [ty] Add some helper methods on `ClassLiteral` [ty] Move some module name helper routines to methods on `ModuleName` [ty] Bump version of `lsp-types` [ty] Refactor to support building constraint sets differently (#23600) [ty] Dataclass transform: neither frozen nor non-frozen (#23366) [ty] Add snapshot tests for advanced `invalid-assignment` scenarios (#23581) [ty] disallow negative narrowing on SubclassOf types (#23598)
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
On
main, this assertion fails, but it should pass:A variadic positional parameter can never satisfy a positional-or-keyword parameter, because the former can never be passed a keyword argument, whereas the latter can.
This fixes the only remaining conformance-suite failure on
callables_subtyping.py.Test Plan
mdtests