Replace getattr(x, 'attr') with x.attr
ProprietaryReplace getattr(x, "attr") calls with x.attr when the attribute name is a constant string that is a valid Python identifier. It leaves alone a shadowed getattr, a non-ASCII or name-mangled name, an object that would need parentheses, and a call holding comments.
org. openrewrite. python. cleanup. ReplaceGetAttrWithConstantmod run . --recipe= org. openrewrite. python. cleanup. ReplaceGetAttrWithConstantInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.