[ty] Require subtyping for transitive constraint pivots#25778
Open
charliermarsh wants to merge 2 commits into
Open
[ty] Require subtyping for transitive constraint pivots#25778charliermarsh wants to merge 2 commits into
charliermarsh wants to merge 2 commits into
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 92.23%. The percentage of expected errors that received a diagnostic held steady at 87.42%. The number of fully passing files held steady at 92/134. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownsphinx
prefect
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-assignment |
0 | 1 | 0 |
invalid-return-type |
0 | 0 | 1 |
| Total | 0 | 1 | 1 |
Large timing changes:
| Project | Old Time | New Time | Change |
|---|---|---|---|
pytest-robotframework |
0.16s | 0.28s | +69% |
Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.
Raw diff:
paasta (https://github.com/yelp/paasta)
- paasta_tools/tron_tools.py:573:16 error[invalid-return-type] Return type does not match returned value: expected `dict[str, FieldSelectorConfig]`, found `dict[str | FieldSelectorConfig, FieldSelectorConfig | dict[str, str]]`
+ paasta_tools/tron_tools.py:573:16 error[invalid-return-type] Return type does not match returned value: expected `dict[str, FieldSelectorConfig]`, found `dict[str, FieldSelectorConfig | dict[str, str]]`
prefect (https://github.com/PrefectHQ/prefect)
- src/prefect/runtime/flow_run.py:70:5 error[invalid-assignment] Object of type `dict[<class 'bool'> | <class 'int'> | <class 'float'> | ... omitted 3 union elements, ((x) -> Unknown) | <class 'int'> | <class 'float'> | <class 'str'> | ((dt: str) -> datetime)]` is not assignable to `dict[type[int | float | str | Unknown] | <class 'NoneType'>, (Any, /) -> Any]`
Merging this PR will degrade performance by 4.22%
Warning Please fix the performance issues or acknowledge them on CodSpeed. Performance Changes
Tip Investigate this regression with the CodSpeed MCP and your agent. Comparing Footnotes
|
c433edc to
28d7fdb
Compare
Member
Author
|
I decided to fix the |
28d7fdb to
be0c908
Compare
dcreager
reviewed
Jun 9, 2026
be0c908 to
ab9db7e
Compare
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
When building sequent maps for constraints on different type variables, we use materialized bounds as pivots to derive transitive relationships. We previously accepted a pivot when those bounds were assignable. Unrelated classes with dynamic bases are mutually assignable, so this connected otherwise independent invariant type variables and caused the constraint set in the issue reproducer to grow combinatorially.
This changes those pivot checks to require subtyping. Because the bounds can themselves contain type variables, the new check uses constraint-set-aware subtyping rather than the ordinary subtype relation. Constraint-set type-variable handling is now an independent mode on
TypeRelationChecker, so it can be combined with either subtyping or assignability; the mode is also included in relation and signature recursion keys so cached results are not shared across comparison modes.In a local benchmark of the issue reproducer, check time fell from 14.5 seconds with constraint-set assignability to 46 milliseconds with constraint-set subtyping.
Closes astral-sh/ty#3607.