ruff/crates/red_knot_python_semantic/resources/mdtest/generics
Carl Meyer bf0306887a
[red-knot] don't remove negations when simplifying constrained typevars (#17189)
For two non-disjoint types `P` and `Q`, the simplification of `(P | Q) &
~Q` is not `P`, but `P & ~Q`. In other words, the non-empty set `P & Q`
is also excluded from the type.

The same applies for a constrained typevar `[T: (P, Q)]`: `T & ~Q`
should simplify to `P & ~Q`, not just `P`.

Implementing this is actually purely a matter of removing code from the
constrained typevar simplification logic; we just need to not bother
removing the negations. If the negations are actually redundant (because
the constraint types are disjoint), normal intersection simplification
will already eliminate them (as shown in the added test.)
2025-04-03 16:30:57 -07:00
..
classes.md [red-knot] fix ordering of ClassDef semantic index building (#16915) 2025-03-23 13:23:12 +00:00
functions.md [red-knot] Add Type::TypeVar variant (#17102) 2025-04-03 14:36:29 -04:00
legacy.md [red-knot] Several failing tests for generics (#16509) 2025-03-05 17:21:19 -05:00
pep695.md [red-knot] don't remove negations when simplifying constrained typevars (#17189) 2025-04-03 16:30:57 -07:00
scoping.md [red-knot] Ban most Type::Instance types in type expressions (#16872) 2025-03-20 15:19:56 -07:00