mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 21:40:51 -05:00
## Summary This PR fixes https://github.com/astral-sh/ty/issues/1848. ```python T = tuple[int, 'U'] class C(set['U']): pass type U = T | C ``` The reason why the fixed point iteration did not converge was because the types stored in the implicit tuple type alias `Specialization` changed each time. ``` 1st: <class 'tuple[int, C]'> 2nd: <class 'tuple[int, tuple[int, C] | C]'> 3rd: <class 'tuple[int, tuple[int, tuple[int, C] | C] | C]'> ... ``` And this was because `UnionType::from_elements` was used when creating union types for tuple operations, which causes type aliases inside to be expanded. This PR replaces these with `UnionType::from_elements_leave_aliases`. ## Test Plan New corpus test
Markdown files within the mdtest/ subdirectory are tests of type inference and type checking;
executed by the tests/mdtest.rs integration test.
See crates/ty_test/README.md for documentation of this test format.