Drop else after an early-exit if branch

Proprietary

When the if body ends in return, raise, continue or break, remove the else and dedent its contents. An else whose line, or the line before it, ends in a comment is left alone, as is an elif.

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

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