mirror of
https://github.com/astral-sh/ruff.git
synced 2025-09-29 21:35:58 +00:00
![]() ## Summary This PR enables red-knot to support type narrowing based on `and` and `or` conditionals, including nested combinations and their negation (for `elif` / `else` blocks and for `not` operator). Part of #13694. In order to address this properly (hopefully 😅), I had to run `NarrowingConstraintsBuilder` functions recursively. In the first commit I introduced a minor refactor - instead of mutating `self.constraints`, the new constraints are now returned as function return values. I also modified the constraints map to be optional, preventing unnecessary hashmap allocations. Thanks @carljm for your support on this :) The second commit contains the logic and tests for handling boolean ops, with improvements to intersections handling in `is_subtype_of` . As I'm still new to Rust and the internals of type checkers, I’d be more than happy to hear any insights or suggestions. Thank you! --------- Co-authored-by: Carl Meyer <carl@astral.sh> |
||
---|---|---|
.. | ||
annotations | ||
assignment | ||
binary | ||
boolean | ||
call | ||
comparison | ||
conditional | ||
declaration | ||
exception | ||
expression | ||
import | ||
literal | ||
loops | ||
narrow | ||
scopes | ||
shadowing | ||
stubs | ||
subscript | ||
unary | ||
with | ||
.mdformat.toml | ||
attributes.md | ||
generics.md | ||
mro.md | ||
unpacking.md |