Rewrite self-multiplication as ** 2

Proprietary

When an expression is multiplied by itself, rewrite it using the exponentiation operator (** 2) for clarity. Only fires where the operand's type resolves to int and it has no side effects, since a large float overflows under **. A literal times itself, such as 60 * 60, or a product holding comments is left alone.

org.openrewrite.python.cleanup.SquareIdentity
mod run . --recipe=org.openrewrite.python.cleanup.SquareIdentity

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