-
Notifications
You must be signed in to change notification settings - Fork 1.6k
[ty] WIP: sort union types during cycle recovery to stabilize output #21722
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Diagnostic diff on typing conformance testsNo changes detected when running ty on typing conformance tests ✅ |
|
|
|
Hmm, at least, this approach alone doesn't seem to eliminate the instability of the diagnostic itself, rather than the instability of the output type. 1st: https://github.com/astral-sh/ruff/actions/runs/19820273428/job/56780817916?pr=21722 scikit-build-core (https://github.com/scikit-build/scikit-build-core)
+ src/scikit_build_core/_logging.py:153:13: warning[unsupported-base] Unsupported class base with type `<class 'Mapping[str, Style]'> | <class 'Mapping[str, Divergent]'>`
- Found 41 diagnostics
+ Found 42 diagnostics2nd: https://github.com/astral-sh/ruff/actions/runs/19820836584/job/56782606719?pr=21722 scikit-build-core (https://github.com/scikit-build/scikit-build-core)
- src/scikit_build_core/_logging.py:153:13: warning[unsupported-base] Unsupported class base with type `<class 'Mapping[str, Style]'> | <class 'Mapping[str, Divergent]'>`
- Found 42 diagnostics
+ Found 41 diagnostics |
I think you need to create a PR targeting this PR to verify your change because mypy primer compares main vs this branch. What you want is to compare the branch to itself to see if there are any remaining instabilities |
Ah, I see, main is unstable, so it can't be used for comparison. |
…cycle recovery functions
Summary
Fixes astral-sh/ty#1670
This PR addresses the issue of non-deterministic execution order of salsa queries causing the order of elements in union types in the output to fluctuate randomly.
We already have a comparison function for sorting union types,
union_or_intersection_elements_ordering, but this probably won't solve the problem, since it compares based on salsa IDs rather than the contents of the interned structs.Instead, we use the
structural_type_orderingfunction, which performs comparisons by deep traversing the type's contents.Test Plan