Remove self-assignments

Proprietary

Remove statements inside a function that assign a parameter to itself (x = x), since they have no effect. Any other local is left alone, since x = x raises UnboundLocalError where nothing bound x first. Class-body and module-level X = X bind a new name from an enclosing one and are left alone, as are attribute and subscript targets, which run __set__ and __setitem__.

org.openrewrite.python.codequality.RemoveSelfAssignment
mod run . --recipe=org.openrewrite.python.codequality.RemoveSelfAssignment

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