[ty] Use assignability for divergent constraints#26334
Merged
Merged
Conversation
Typing conformance resultsNo changes detected ✅Current numbersThe percentage of diagnostics emitted that were expected errors held steady at 94.47%. The percentage of expected errors that received a diagnostic held steady at 89.10%. The number of fully passing files held steady at 95/134. |
Memory usage reportSummary
Significant changesClick to expand detailed breakdownflake8
trio
prefect
sphinx
|
|
| Lint rule | Added | Removed | Changed |
|---|---|---|---|
invalid-argument-type |
0 | 1 | 3 |
unresolved-attribute |
0 | 0 | 2 |
| Total | 0 | 1 | 5 |
Flaky changes detected. This PR summary excludes flaky changes; see the HTML report for details.
Raw diff:
jax (https://github.com/google/jax)
- jax/experimental/mosaic/gpu/fragmented_array.py:3050:17 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: SupportsIndex, /) -> bool | (Unknown & ~AlwaysFalsy), (index: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> tuple[bool | (Unknown & ~AlwaysFalsy), ...]]` cannot be called with key of type `Replicated` on object of type `tuple[bool | (Unknown & ~AlwaysFalsy), ...]`
+ jax/experimental/mosaic/gpu/fragmented_array.py:3050:17 error[invalid-argument-type] Method `__getitem__` of type `Overload[(index: SupportsIndex, /) -> bool, (index: slice[SupportsIndex | None, SupportsIndex | None, SupportsIndex | None], /) -> tuple[bool, ...]]` cannot be called with key of type `Replicated` on object of type `tuple[bool, ...]`
spark (https://github.com/apache/spark)
- python/pyspark/pandas/series.py:2765:53 error[invalid-argument-type] Argument to bound method `InternalFrame.with_filter` is incorrect: Expected `Column | Series[Unknown]`, found `Unknown | Column | int`
sympy (https://github.com/sympy/sympy)
- sympy/printing/c.py:259:60 error[unresolved-attribute] Attribute `decimal_dig` is not defined on `IntBaseType` in union `FloatType | IntBaseType | Unknown`
+ sympy/printing/c.py:259:60 error[unresolved-attribute] Attribute `decimal_dig` is not defined on `IntBaseType` in union `FloatType | IntBaseType`
- sympy/printing/c.py:518:29 error[unresolved-attribute] Attribute `decimal_dig` is not defined on `FloatBaseType`, `IntBaseType` in union `FloatBaseType | IntBaseType | Unknown`
+ sympy/printing/c.py:518:29 error[unresolved-attribute] Object of type `FloatBaseType | IntBaseType` has no attribute `decimal_dig`
xarray (https://github.com/pydata/xarray)
- xarray/tests/test_interp.py:958:51 error[invalid-argument-type] Argument expression after ** must be a mapping with `str` key type: Found `Hashable`
+ xarray/tests/test_interp.py:958:51 error[invalid-argument-type] Argument expression after ** must be a mapping with `str` key type: Found `Hashable | DataArray`
- xarray/tests/test_interp.py:959:63 error[invalid-argument-type] Argument expression after ** must be a mapping with `str` key type: Found `Hashable`
+ xarray/tests/test_interp.py:959:63 error[invalid-argument-type] Argument expression after ** must be a mapping with `str` key type: Found `Hashable | DataArray`f803e7e to
b81d4f5
Compare
charliermarsh
approved these changes
Jun 24, 2026
charliermarsh
added a commit
that referenced
this pull request
Jun 24, 2026
## Summary This reverts #26163 and its follow-up changes in #26230, #26246, #26274, #26275, and #26316. The recursive nominal-growth recovery replaces a previous cycle result nested inside a specialization with `Divergent`. The follow-up regressions show that this local replacement is not structurally safe: multi-arm union recovery can lose stable arms, and variadic tuple growth can continue after replacement. Addressing those cases required increasingly shape-specific alignment and guards without a general way to establish correspondence between fixed-point iterations. This restores the cycle-recovery behavior from before #26163. The direct self-referential `TypeOf` case and the regression coverage for astral-sh/ty#3835 and astral-sh/ty#3838 continue to pass without the heuristic and are retained. We remove only the cases that no longer converge: `TypeOf` references nested in nominal specializations and the nested-iterable case from astral-sh/ty#3827. The independent `Divergent` constraint fixes from #26288 and #26334, including the regression coverage for astral-sh/ty#3836, are also retained.
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
#26288 fixed a crash by preventing
when_constraint_set_assignable_to_ownedfrom returning a trivial
alwaysresult for top-levelDivergentpairs. Theunderlying issue was that the owned fast path and the lazy relation checker
could disagree: the fast path treated some
Divergentassignability checks asalways satisfied, while the lazy relation checker treated top-level
Divergentas never assignable.
This patch resolves the inconsistency in the relation checker instead.
Unmaterialized
Divergentis assignability-compatible in both eager and lazyassignability, while it is still not a subtype of arbitrary types and still must
not be eliminated by redundancy/union simplification.
With the lazy relation checker aligned with the fast path, we no longer need the
top-level
Divergentexclusion inis_trivially_constraint_set_assignable_to.The regression test from #26288 still passes, and the unit test now asserts that
constraint-set assignability treats
Divergentconsistently.Test Plan
unit test updated