mirror of
https://github.com/astral-sh/ruff.git
synced 2026-10-28 19:00:26 +08:00
## Summary We add accessors and iteration methods to `ExprCompare` and use them throughout AST visitors, formatting, lint rules, and type inference. For `a < b <= c`, `iter` yields `(a, Lt, b)` and `(b, LtE, c)`. `as_single` returns a triple only when there is exactly one operator and two operands, so callers can match an operator and both operands together while rejecting comparison chains. Rules that only inspect operands use the existing operand slice directly. The `first_operand`, `first_operator`, and `second_operand` accessors assert the parser's existing guarantee that a comparison has at least one operator and two operands. Error recovery synthesizes missing operands; manually constructed ASTs must uphold the same invariant.