Substitute constant collection condition with boolean

Proprietary

When a list, tuple, dict, or set literal is used as an if or while condition, replace it with True (non-empty) or False (empty) to state the intent directly. A literal holding comments, unpacking, or an element that may run code or fail to hash is left alone.

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

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