Replace the and/or idiom with a conditional expression

Proprietary

Rewrite the legacy cond and val or fallback idiom as val if cond else fallback. It only fires where val is a literal that is always truthy, such as a non-empty string, since a falsy val makes the idiom yield fallback. An idiom holding comments is left alone.

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

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