Will It Vibe logoWill It Vibe?
PY-005Medium severity-8 points

Mutable class attribute shared across instances

Part of Code Quality & Syntax, which counts for 20% of the overall score. When this check fires it deducts 8 points from that category, once per scan, no matter how many places it turns up.

What it detects

A list or dict literal assigned directly in the class body (not inside __init__) is one object shared by every instance of the class.

Why it matters

A list or dict assigned directly in the class body (items = [], not inside __init__) is a class attribute, so every instance shares the exact same object until an instance explicitly reassigns it. Code that expects each instance to have its own independent list ends up silently sharing state across every instance, which shows up as one request's data leaking into another's, or a test polluting the next test that runs after it. This is a close cousin of the mutable-default-argument bug and just as easy to miss in review.

How to fix it

Move the initialization into __init__ so each instance gets its own object, for example self.items = [] inside def __init__(self):. If the class is a dataclass, use field(default_factory=list) (or dict/set) instead of a bare class-level default so each instance still gets an independent object.

The paid report includes a ready-to-paste prompt for your AI coding agent for every check it finds, pointed at the exact findings from your scan. See pricing

Does your repo trip this check?

Paste a GitHub URL or drop a project folder. Scans run in your browser and take seconds.

Scan your repo

Related Code Quality & Syntax checks