TYPE016infoPro

repeated-dict-key-assignment

Three or more consecutive string-key assignments to the same dict — the dict has structure that should be a typed shape.

Applies to: Python

Why this matters

A run of `d['name'] = name; d['email'] = email; d['age'] = age` treats the dict as if it were a struct, but with no type checking. Fat-finger any key (typo, copy-paste mistake, schema drift) and the bug is silent until runtime. A TypedDict, @dataclass, or Pydantic model gives the same shape with IDE / pyright support and a single named place to update when the shape changes.

Catch it before it ships

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

TYPE016 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: TYPE016