Skip to content

refactor: replace _ERROR_RESPONSES tuple-of-tuples with TypedDict in openapi.py #509

@Aureliolo

Description

@Aureliolo

Summary

src/synthorg/api/openapi.py defines _ERROR_RESPONSES as a tuple of 7-element tuples, which requires a noqa: PLR0913 suppression on _build_reusable_response (6 keyword-only parameters) and positional destructuring in the calling loop.

Proposed Change

Replace the tuple-of-tuples with a TypedDict (or NamedTuple):

class _ErrorResponseSpec(TypedDict):
    status: int
    key: str
    description: str
    error_code: ErrorCode
    error_category: ErrorCategory
    detail: str
    retryable: bool

Then _build_reusable_response accepts a single _ErrorResponseSpec parameter, eliminating the PLR0913 noqa and making the data structure harder to misorder.

Context

Found during pre-PR review of #506. Deferred as low-priority style improvement (scope:small, non-blocking).

Acceptance Criteria

  • _ERROR_RESPONSES uses a named type instead of bare tuples
  • noqa: PLR0913 removed from _build_reusable_response
  • All existing tests pass unchanged

Metadata

Metadata

Assignees

No one assigned

    Labels

    prio:lowNice to have, can deferscope:smallLess than 1 day of worktype:refactorCode restructuring, cleanup

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions