mirror of
https://github.com/astral-sh/ruff
synced 2026-01-21 13:30:49 -05:00
## Summary If we match on an `TestEnum | None`, then when adding a case like `~Literal[TestEnum.FOO]` (i.e., after `if value == TestEnum.FOO: return`), we'd distribute `Literal[TestEnum.BAR]` on the entire builder, creating `None & Literal[TestEnum.BAR]` which simplified to `Never`. Instead, we should only expand to the remaining members for pieces of the intersection that contain the enum. Now, `(TestEnum | None) & ~Literal[TestEnum.FOO] & ~Literal[TestEnum.BAR]` correctly simplifies to `None` instead of `Never`. Closes https://github.com/astral-sh/ty/issues/2260.