ruff
df33c17f - [ty] Preserve uncertain branches during quantification (#28211)

Commit
75 days ago
[ty] Preserve uncertain branches during quantification (#28211) Quantification distributes a constraint node's uncertain branch into its true and false branches when rebuilding retained nodes. Although this preserves the Boolean result, it can introduce irrelevant positive constraints into solution paths and make inferred solutions depend on constraint ordering. Rebuild these nodes with the existing TDD-aware `ite_uncertain` helper so that the uncertain branch is preserved, and remove the now-unused binary `ite` helper. This follows up on #28042. Two constraint-ordering unit tests now produce the same expected solutions for every permutation. The existing TypedDict protocol-inference case also becomes stable, but consistently selects the broader `object` constraint instead of alternating between `int` and `object`; the mdtests document that remaining inference limitation. Overall this significantly reduces wobble (total wobbling tests go from 36 to 23); unfortunately in some cases visible in mdtests that resolves the wobble in the wrong direction for the normal constraint ordering, but those look like cases where we need an orthogonal fix. ## Test plan Strengthen the existing permutation tests for nested transitive constraints and negated alternatives to reject irrelevant bindings. Update the two existing TypedDict mdtest assertions to document the stable result; no new mdtest scenarios are added. The semantic suite passes. A comparison against the base revision across nine constraint orders finds no new wobbling assertion sites or checker panics, with wobbling sites decreasing from 36 to 23. The descriptor mdtests also pass for both revisions under all masks from 0 through 31 and reversed ordering.
Author
Parents
Loading