Flatten negated logic via De Morgan's identities

Proprietary

Use De Morgan's identities to distribute not into compound conditions, e.g. not (m and n) becomes not m or not n. Rewrites whose result need not be a bool, such as cancelling an inner not or turning == into !=, apply only where the result is read as a truth value. A chained comparison is negated as a whole, and a three-way and/or is left alone.

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

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