Use chained comparison syntax

Proprietary

Merge two relational tests that share a middle operand into a single chained comparison, e.g. 0 < idx and idx < size becomes 0 < idx < size. It declines a middle operand with side effects, which the chained form evaluates only once, and a second test whose dropped operand holds comments.

org.openrewrite.python.cleanup.ChainCompares
mod run . --recipe=org.openrewrite.python.cleanup.ChainCompares

Install it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.