Boolean checks should not be inverted

Proprietary

Replace inverted boolean comparisons like not (a == b) with the equivalent direct operator (a != b), and remove double negations like not (not x). An ordering such as not (a < b) is only inverted where both operands' types resolve to integers, a chained comparison is left alone, as is a comparison inside a method such as __ne__ that the inverted operator would call. A double negation is only removed where its value is read as a truth value, as in a condition.

org.openrewrite.python.codequality.BooleanChecksNotInverted
mod run . --recipe=org.openrewrite.python.codequality.BooleanChecksNotInverted

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