- Fix 71 invalid-syntax files (class-body newline-broken assignments) - Add from/None chain to 307 B904 raise-without-from sites - Add B008 ignore to ruff.toml (already in pyproject.toml) - Noqa F401 on __init__.py re-exports (137 sites) - Noqa E402 on deferred imports (63 sites) - Bulk-add stdlib/FastAPI/project imports for F821 (127 sites) - Replace ×→x, –→-, …→... in docstrings (4093 chars) - Manual refactor of 5 SIM103/SIM116 patterns Tests: 791 passed (66 deselected due to pre-existing Redis issues in test_rag.py) Co-authored-by: opencode <opencode@rugmunch.io>
33 lines
1.2 KiB
Python
33 lines
1.2 KiB
Python
"""Shared Pydantic v2 models used across modules.
|
|
|
|
Prefer domain-local models in `app/domain/<name>/models.py` - this module
|
|
is only for cross-domain shared types (e.g., pagination envelope, error body).
|
|
"""
|
|
|
|
from __future__ import annotations
|
|
|
|
from pydantic import BaseModel, Field
|
|
|
|
|
|
class ErrorResponse(BaseModel):
|
|
"""Standard error envelope returned by all endpoints."""
|
|
|
|
code: str = Field(..., description="Machine-readable error code")
|
|
message: str = Field(..., description="Human-readable message")
|
|
details: dict | None = Field(default=None, description="Optional context")
|
|
correlation_id: str | None = Field(default=None, description="Request ID for tracing")
|
|
|
|
|
|
class PaginationParams(BaseModel):
|
|
"""Cursor-based pagination (preferred over offset/limit at scale)."""
|
|
|
|
cursor: str | None = Field(default=None, description="Opaque pagination cursor")
|
|
limit: int = Field(default=50, ge=1, le=200, description="Max items per page")
|
|
|
|
|
|
class Page(BaseModel):
|
|
"""Paginated response envelope."""
|
|
|
|
items: list = Field(default_factory=list)
|
|
next_cursor: str | None = None
|
|
total: int | None = Field(default=None, description="Total if known, None otherwise")
|