Replace the and/or idiom with a conditional expression
ProprietaryRewrite 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. TernaryToIfExpressionmod run . --recipe= org. openrewrite. python. cleanup. TernaryToIfExpressionInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.