mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-28 04:45:01 +00:00
![]() ## 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. |
||
---|---|---|
.. | ||
bytes.md | ||
class.md | ||
instance.md | ||
lists.md | ||
stepsize_zero.md | ||
string.md | ||
tuple.md |