Collapse if/else returning boolean literals
Recipe ID
org.openrewrite.python.cleanup.SimplifyBooleanReturnArtifactopenrewrite-migrate-pythonReplace 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 where bool is not the builtin or the removed statements hold comments.
Single recipepythoncleanupruffSIM103Proprietary
Usage
This recipe has no required configuration options. You’ll need the Moderne CLI configured before running the command below.
mod run . --recipe org.openrewrite.python.cleanup.SimplifyBooleanReturnIf the recipe isn’t available locally, install it with:
mod config recipes pip install openrewrite-migrate-python
mod config recipes jar install org.openrewrite.recipe:rewrite-migrate-python:RELEASE
mod config recipes jar install org.openrewrite:rewrite-python:RELEASE