Skip to content

named-record-at-boundaries

Public Python API returns an unnamed fixed-shape record.

Why

A named record makes field types and required keys explicit to callers and static tooling.

Fix

Define and return a TypedDict, Pydantic model, or frozen dataclass for the fixed record shape.

Examples

Before — flagged Public API returns an unnamed record
service.py
def build_payload(call) -> dict[str, object]:
return {"id": call.id}
After — preferred TypedDict names the returned record
service.py
from typing import TypedDict
class CallPayload(TypedDict):
id: str
def build_payload(call) -> CallPayload:
return {"id": call.id}

Formerly: named-fixed-record-return, pydantic-at-boundaries