← All recipes
Moderne licensed

Guard mutable default arguments with None sentinel

Recipe IDorg.openrewrite.python.cleanup.DefaultMutableArgArtifactopenrewrite-static-analysis

Change mutable default values ([], {}, set()) to None and prepend an if arg is None: arg = <original> guard so each call gets its own fresh instance.

Single recipeProprietary

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.DefaultMutableArg

If the recipe isn’t available locally, install it with:

mod config recipes pip install openrewrite-static-analysis