TYPE002infoPro

naked-dict-for-structured-data

Using plain dict for structured data instead of dataclass/TypedDict.

Applies to: Python

Why this matters

Plain dicts with string keys like data['user_name'] have no type checking. Typos cause KeyError at runtime instead of being caught by your IDE. Use dataclass, TypedDict, or Pydantic models for structured data.

Catch it before it ships

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

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