Use augmented assignment
ProprietaryRewrite x = x op y as x op= y for +, -, *, / and %. It only fires where x is a side-effect-free name whose type resolves to an immutable builtin such as int or str, since op= mutates a list in place. A walrus (x := x + y) is left alone.
org. openrewrite. python. cleanup. AugAssignmod run . --recipe= org. openrewrite. python. cleanup. AugAssignInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.