Simplify sum(1 for x in items if cond) to sum(bool(cond) for x in items)
ProprietaryReplace sum(1 for x in items if cond) with sum(bool(cond) for x in items) by moving the filter condition into a bool() wrapper. It only fires for the integer literal 1 and where sum and bool resolve to the builtins.
org. openrewrite. python. cleanup. SimplifyConstantSummod run . --recipe= org. openrewrite. python. cleanup. SimplifyConstantSumInstall it once, then run it on every repository under the current directory. New to the Moderne CLI? Set it up.