TYPE017warningPro

unstructured-dict-access-where-model-exists

Function reads a value via string-key subscript / .get(...) chains whose key set matches a Pydantic / dataclass / TypedDict already defined in this project.

Applies to: Python

Why this matters

When the canonical shape for a value already exists as a typed model in the repo, accessing it through `d['key']` and `d.get('key')` throws away every guarantee the model provides. A typo in the key string is silent until runtime; a field rename in the model leaves the dict-access callers stale; pyright / IDE rename / find-references all stop working at the boundary. Validate the dict at the boundary (`Model.model_validate(raw)` for Pydantic, `Model(**raw)` for dataclass) and use attribute access downstream.

Catch it before it ships

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

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