[ty] Add basic support for overloads in ParamSpec#21946
Merged
dhruvmanila merged 5 commits intomainfrom Jan 20, 2026
Merged
Conversation
Typing conformance resultsNo changes detected ✅ |
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
2 | 14 | 6 |
invalid-parameter-default |
0 | 0 | 7 |
invalid-assignment |
0 | 0 | 5 |
invalid-return-type |
0 | 0 | 5 |
unused-ignore-comment |
0 | 2 | 0 |
| Total | 2 | 16 | 23 |
Contributor
charliermarsh
approved these changes
Jan 19, 2026
Member
|
This looks reasonable to me. (I also tried to fix this at #22692 before seeing this PR.) |
76ffc56 to
2015999
Compare
AlexWaygood
approved these changes
Jan 19, 2026
Comment on lines
+691
to
+694
| def foo(int_or_str: int | str): | ||
| # Argument type expansion leads to matching both overloads. | ||
| # TODO: Should this be an error instead? | ||
| reveal_type(with_parameters(int_int, int_or_str)) # revealed: Overload[(x: int) -> str, (x: str) -> str] |
Member
Member
Author
There was a problem hiding this comment.
Yeah, I couldn't come up with a reason on why this should be an error but I also noticed that other type checkers do reject this which is why I've added a TODO for now.
38c97f7 to
35c7404
Compare
carljm
added a commit
that referenced
this pull request
Jan 20, 2026
* main: (149 commits) Preserve required parentheses in lambda bodies (#22747) [`flake8-simplify`] Make fix unsafe if it deletes comments (`SIM911`) (#22661) [`refurb`] Make fix unsafe if it deletes comments (`FURB145`) (#22670) [`ruff`] Make fix unsafe if it deletes comments (`RUF020`) (#22664) [ty] Add README for `ty_completion_bench` CLI tool [ty] Update completion eval [ty] Collect completions into a max-heap [ty] Truncate imports and qualifications derived from completions [ty] Get rid of high-level completion deduplication [ty] Refactor how we sort completions [ty] Optimize collection of "all symbols" [ty] Speed up completions by tweaking sorts [ty] Add new `ty_completion_bench` for ad hoc benchmarking gitignore: ignore scratch directories in completion eval truth directory [`pyupgrade`] Allow shadowing non-builtin bindings (`UP029`) (#22749) [ty] Emit invalid type form for stringified annotations (#22752) [ty] Allow `if type(x) is Y` narrowing for types other than class-literal types (#22729) [ty] Add basic support for overloads in `ParamSpec` (#21946) [`ruff`] Make fix unsafe if it deletes comments (`RUF019`) (#22663) [`flake8-bugbear`] Make fix unsafe if it deletes comments (`B014`) (#22659) ...
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
fixes: astral-sh/ty#1838
This PR adds basic support for overloaded function when used to specialize a
ParamSpectype variable.Following cases are still remaining:
Both of these cases are present in the mdtest file.
Test Plan
Update mdtest with new cases.