Collapse if/else returning boolean literals

Proprietary

Replace if cond: return True / else: return False with return cond and the inverse with return not cond, including the fallthrough variant without an explicit else. A condition other than a comparison, a not, or an and/or of those is returned as bool(cond). The rewrite is declined on an elif, where bool is not the builtin, or where the removed statements hold comments.

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

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