Python Mutable Default Arguments Fix for Openclaw

A specialized tool for identifying and remediating Python functions that use mutable objects as default arguments to prevent silent state sharing.

mvogt99
v1.0.0
Apr 28, 2026
0
759
0

Install & Download

1. ClawHub CLI

The fastest way to install a skill directly from the registry.

npx clawhub@latest install python-mutable-default-args

2. Manual Installation

Copy the skill folder to one of these locations

Global
~/.openclaw/skills/
Workspace
<project>/skills/

Priority: Workspace > Local > Bundled

3. Prompt Installation

Copy this prompt to OpenClaw to install it automatically.

Help me install python-mutable-default-args using Clawhub. If Clawhub is not installed, install it first (npm i -g clawhub).

Prefer to download?

Get the raw skill files in a ZIP archive.

What is Python Mutable Default Arguments Fix?

The Python Mutable Default Arguments skill addresses a notorious technical debt issue where Python evaluates default argument values only once at function definition. When a list, dictionary, or set is used as a default, that specific object is shared across all function calls, leading to data leakage and unpredictable behavior.

Integrating this into your Openclaw Skills workflow ensures that these silent bugs are caught before they reach production. By replacing mutable defaults with the canonical None-check pattern, this skill maintains function purity and ensures that every invocation starts with a fresh, empty state as intended by the developer.

Python Mutable Default Arguments Fix Use Cases

  • Fixing functions where lists or dictionaries grow unexpectedly across multiple calls.
  • Debugging unit tests that pass individually but fail when executed in a suite due to shared state.
  • Automated code reviews to scan for dangerous function signatures like items=[] or data={}.
  • Refactoring legacy Python codebases to comply with modern linting standards (Pylint W0102 or Ruff B006).

How Python Mutable Default Arguments Fix Works

  1. The skill scans Python function signatures for the use of mutable types (list, dict, set) as default arguments.
  2. It identifies instances where these default objects are mutated within the function body (e.g., .append(), .update()).
  3. The skill transforms the signature to use None as the default value.
  4. It injects a conditional check at the beginning of the function body to initialize a new instance of the mutable object if the argument remains None.

Python Mutable Default Arguments Fix Setup

To enable this capability within your Openclaw Skills environment, ensure your workspace is configured for Python analysis. You can trigger the remediation flow via CLI:

# Install the skill package
claw-cli install python-mutable-default-args

# Run a scan on your local Python files
claw-cli scan --skill python-mutable-default-args ./src

Python Mutable Default Arguments Fix Data Schema & Taxonomy

The skill analyzes function metadata and applies transformations based on the following taxonomy:

Attribute Description
Language Python (3.x recommended)
Detected Patterns =[], ={}, =set(), =[]
Remediation Pattern arg=None with if arg is None: arg = []
Metadata Compatible with macOS, Linux, and Windows environments

Python Mutable Default Arguments Fix Advanced Features

  • Multi-agent support: Works in tandem with other Openclaw Skills to perform wide-scale refactoring.
  • Linter integration: Automatically maps findings to Pylint and Ruff rule IDs for reporting.
  • Heuristic scanning: Deep-scans nested function definitions and class methods for shared state patterns.

SKILL.md


Loading

Related Openclaw Skills

METADATA

Github Stars: 0
forks: 0

Featured*