QUAL004errorPro

mutable-default-argument

Mutable default arguments are shared between calls and cause bugs

Applies to: Python

Why this matters

When you use a mutable default like `def foo(items=[])`, the same list is reused for every call. Adding to it in one call affects all future calls! This is one of Python's most famous gotchas.

Catch it before it ships

pip install stablestack # or: npx stablestackstablestack # scans your project, QUAL004 includedstablestack explain QUAL004

QUAL004 is part of the Pro rule set. See pricing — the free tier ships 24 checks with no signup.

False positive in your codebase? Suppress a single line with # noqa: QUAL004