4d70c8950d
`uv run pytest` reported 26 DeprecationWarnings, 20 of them raised by code we own. Two independent sources, both already renamed upstream. Starlette renamed HTTP_422_UNPROCESSABLE_ENTITY to HTTP_422_UNPROCESSABLE_CONTENT, matching the RFC 9110 name for the status. Rename all 21 call sites across the twelve routers that raise it. The numeric value is unchanged at 422, so the wire format and the frontend's error handling are untouched -- this is forward-compat debt only. The warnings attributed to fastapi/routing.py were these same handler frames raising through the dependency call, and go with them. Alembic >=1.16 supersedes `version_path_separator` with `path_separator`, which governs both `prepend_sys_path` and `version_locations`; its absence is what triggered the legacy-splitting warning on every config load. Swap the key in alembic.ini. Deliberately not fixing slowapi's `asyncio.iscoroutinefunction` warning (6 of the 26): it is upstream with no released fix, and no `filterwarnings` entry is added, so it stays visible as a reminder to drop the pin once one lands. Verified from backend/: ruff check and format clean, 893 passed with coverage at 92%, and the warnings summary is now exactly those 6 slowapi lines. `alembic upgrade head` runs 001 through 008 without the path_separator warning. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
36 lines
1.3 KiB
Python
36 lines
1.3 KiB
Python
"""HTTP routes for the Swedish calendar (röda dagar / klämdagar).
|
|
|
|
Routers stay thin: validate via Pydantic/query params, call the service, map
|
|
domain errors to HTTP. Serves both §3.4 (Kalender shading) and §3.8 (Settings
|
|
red-days list) from one endpoint — see `app.services.calendar_service`.
|
|
"""
|
|
|
|
from uuid import UUID
|
|
|
|
from fastapi import APIRouter, HTTPException, Query, status
|
|
|
|
from app.dependencies import CalendarServiceDep, WorkspaceScopeDep
|
|
from app.models.calendar import CalendarDaysResponse
|
|
from app.services.calendar_service import MAX_WINDOW_YEARS
|
|
from app.utils.errors import ValidationError
|
|
|
|
router = APIRouter(prefix="/api/calendar", tags=["calendar"])
|
|
|
|
|
|
@router.get("/days", response_model=CalendarDaysResponse)
|
|
async def get_calendar_days(
|
|
workspace_id: UUID,
|
|
start_year: int,
|
|
service: CalendarServiceDep,
|
|
scope: WorkspaceScopeDep,
|
|
years: int = Query(default=MAX_WINDOW_YEARS, ge=1, le=MAX_WINDOW_YEARS),
|
|
) -> CalendarDaysResponse:
|
|
scope.check_workspace(workspace_id)
|
|
try:
|
|
window = await service.get_calendar_window(
|
|
workspace_id=workspace_id, start_year=start_year, years=years
|
|
)
|
|
except ValidationError as exc:
|
|
raise HTTPException(status.HTTP_422_UNPROCESSABLE_CONTENT, str(exc)) from exc
|
|
return CalendarDaysResponse.from_domain(window)
|