ruff
f856ab0f - [ty] Fix invariant gradual tuple materialization ranges (#27946)

Commit
93 days ago
[ty] Fix invariant gradual tuple materialization ranges (#27946) `tuple[Any, ...]` can materialize to an exact built-in tuple of any length. Currently we bottom-materialize this type incorrectly. We give its bottom materialization as `tuple[Never, ...]`, which we currently simplify to `tuple[()]`, but neither of these types is a subtype of every possible tuple type, which the bottom materialization of `tuple[Any, ...]` should be. As a result, valid specializations can be rejected, and an exhaustive variadic-generic class pattern can appear non-exhaustive. The full fix here (a correct bottom materialization of `tuple[Any, ...]`) will be more invasive, and I prefer to delay that until we've made some more general decisions about how we want to treat bottom materializations and their (non-?)equivalence to `Never`, and fixed the property tests. This limited fix just special-cases `tuple[Any, ...]` inside invariant specialization type relations, avoiding using the bottom materialization of `tuple[Any, ...]` rather than fixing it. This is a pre-requisite to avoid regression in my next steps on fixing the property tests (and another fix I'm working on). The added tests here are correct, so at least this is moving us in the right direction and locking in some better behaviors, even if the implementation isn't what it should be yet. This is an independent prerequisite for both #27920 and #27943. It does not change `Never` tuple normalization or static tuple disjointness. ## Test plan - Add mdtests for empty, nonempty, and symbolic tuple specializations; top and bottom bounds; symmetric overlap; aliases; and tuple-subclass, static-tuple, and mixed-prefix exclusions. - Verify class-pattern exhaustiveness for empty, nonempty, and symbolic variadic specializations, including the minimized regression exposed by #27943. Check the combined changes against #27943's fixed-tuple rejection tests. - Cover union simplification with nested cycle-recovery approximations and ensure unresolved divergence markers do not count as unrestricted gradual elements. The stable property suite has two existing failures involving `tuple[Never]` disjointness, reproduced both with and without this change. Those are addressed by the separate tuple-disjointness work in #27920.
Author
Parents
Loading