Use a conditional expression for a simple if/else assignment
ProprietaryWhen an if/else pair each assign a single value to the same variable, rewrite them as one assignment of a conditional expression. An if with comments inside, an elif, tuple targets, a condition or value spanning several lines, and values that are a yield, a lambda or already a conditional are left alone.
org. openrewrite. python. cleanup. AssignIfExpmod run . --recipe= org. openrewrite. python. cleanup. AssignIfExpInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.