Skip to content
Critiq Docs

Search docs

Search documentation pages and rules

correctness.language

Avoid mutable default function arguments

Mutable defaults in function signatures retain state across calls.

#Metadata

Rule ID
py.correctness.dangerous-mutable-default
Severity
high
Confidence
0.96
Languages
python
Presets
recommended, strict
Stability
stable
Applies to
block
Tags
correctness, python, rules-catalog

#Why it matters

Reusing the same list, dict, or set instance can leak data between calls and produce non-deterministic behavior.

#Remediation

Use `None` as the default and construct a fresh mutable object inside the function.

#Repository path

The generated metadata points to critiq-rules/libs/rules/catalog/rules/python/py.correctness.dangerous-mutable-default.rule.yaml.