[ty] Support ParamSpecs in ConstraintSet - #28028
Open
dhruvmanila wants to merge 15 commits into
Open
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 97.79%. The percentage of expected errors that received a diagnostic held steady at 94.33%. The number of fully passing files held steady at 112/136. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdowntrio
sphinx
flake8
prefect
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-return-type |
0 | 1 | 0 |
unsound-return-statement |
1 | 0 | 0 |
| Total | 1 | 1 | 0 |
Raw diff:
prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/task_runners.py:436:16 error[invalid-return-type] Return type does not match returned value: expected `PrefectConcurrentFuture[R@ThreadPoolTaskRunner]`, found `PrefectConcurrentFuture[_T@run]`
+ src/prefect/task_runners.py:436:16 warning[unsound-return-statement] Unsound return statement: `PrefectConcurrentFuture[Unknown]` is not a subtype of `PrefectConcurrentFuture[R@ThreadPoolTaskRunner]`ConstraintSet.range
ConstraintSet.rangeConstraintSet
dhruvmanila
force-pushed
the
dhruv/paramspec-constraint-range
branch
from
August 27, 2026 09:05
d68f81c to
adc2681
Compare
dhruvmanila
changed the base branch from
main
to
dhruv/refactor-constraint-bounds
August 27, 2026 09:06
Merging this PR will not alter performance
Comparing Footnotes
|
dhruvmanila
force-pushed
the
dhruv/paramspec-constraint-range
branch
from
August 27, 2026 15:39
adc2681 to
abb795c
Compare
Allow the three required arguments to be passed by keyword, matching the existing internal stub.
Accept bare ParamSpec subjects in the internal range constructor and normalize callable bounds to parameter-list values. Preserve full signatures and overloads while erasing returns, and keep ordinary bounds and type-form validation unchanged. Cover concrete, aliased, gradual, and overloaded bounds, including invalid forms and a computed-receiver validation regression.
Permit bare ParamSpec endpoints only for a bare ParamSpec subject. Normalize unprefixed callable references to their bound ParamSpec while retaining callable-owned generic binders and Concatenate prefixes. Cover mixed and symbolic ranges, callable equivalence, and generic-binder preservation.
Remove duplicate keyword-call variants while retaining positional lower- and upper-bound TypeVarTuple rejection coverage.
Revert the synthetic range signature change at review request. Keyword-call support and alignment with the stub are outside this ParamSpec change.
Supply parameter-list bottom/top for missing ParamSpec endpoints through Constraint's effective accessors. Keep absent stored bounds separate from inference evidence and preserve ordinary TypeVar behavior.
dhruvmanila
force-pushed
the
dhruv/paramspec-constraint-range
branch
from
August 27, 2026 16:00
abb795c to
a1a8ab9
Compare
dhruvmanila
marked this pull request as ready for review
August 27, 2026 16:04
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
Part of astral-sh/ty#3555. Depends on #28094.
Support ParamSpecs in the internal
ConstraintSet.range,lower_bound,upper_bound, andequalityconstructors. Share normalization for concrete and symbolic parameter-list bounds, preserving full signatures, overloads, and generic binders while erasing callable return types.Use parameter-list bottom/top as the effective defaults for missing ParamSpec endpoints, while keeping absent and explicitly supplied bounds distinct in storage. Recognize unrestricted ParamSpec ranges without discarding supplied bounds as inference evidence. Allow bare ParamSpecs during argument inference for these four internal constructors.
Solution extraction and specialization inference remain out of scope.
Test Plan