ruff/crates/red_knot_python_semantic/resources/mdtest/subscript
Carl Meyer 2a478ce1b2
[red-knot] simplify gradually-equivalent types out of unions and intersections (#17467)
## Summary

If two types are gradually-equivalent, that means they share the same
set of possible materializations. There's no need to keep two such types
in the same union or intersection; we should simplify them.

Fixes https://github.com/astral-sh/ruff/issues/17465

The one downside here is that now we will simplify e.g. `Unknown |
Todo(...)` to just `Unknown`, if `Unknown` was added to the union first.
This is correct from a type perspective (they are equivalent types), but
it can mean we lose visibility into part of the cause for the type
inferring as unknown. I think this is OK, but if we think it's important
to avoid this, I can add a special case to try to preserve `Todo` over
`Unknown`, if we see them both in the same union or intersection.

## Test Plan

Added and updated mdtests.
2025-04-18 15:08:57 -07:00
..
bytes.md [red-knot] Add support for overloaded functions (#17366) 2025-04-18 09:57:40 +05:30
class.md [red-knot] detect invalid return type (#16540) 2025-03-12 01:58:59 +00:00
instance.md [red-knot] Use Unknown | T_inferred for undeclared public symbols (#15674) 2025-01-24 12:47:48 +01:00
lists.md [red-knot] simplify gradually-equivalent types out of unions and intersections (#17467) 2025-04-18 15:08:57 -07:00
stepsize_zero.md [red-knot] have mdformat wrap mdtest files to 100 columns (#14020) 2024-10-31 21:00:51 +00:00
string.md [red-knot] Add support for overloaded functions (#17366) 2025-04-18 09:57:40 +05:30
tuple.md [red-knot] Fix MRO inference for protocol classes; allow inheritance from subscripted Generic[]; forbid subclassing unsubscripted Generic (#17452) 2025-04-18 19:55:53 +00:00