Skip to content

Upgrade toolchain and move to Python 3.14 - #54

Merged
amrtgaber merged 3 commits into
mainfrom
python-314-toolchain-refresh
Jul 28, 2026
Merged

Upgrade toolchain and move to Python 3.14#54
amrtgaber merged 3 commits into
mainfrom
python-314-toolchain-refresh

Conversation

@amrtgaber

Copy link
Copy Markdown
Contributor

Applies the dependency/toolchain refresh recently made to api-template, adapted to this service's divergences.

What changed

  • ruff pre-commit hook v0.8.6 → v0.16.0 (ruff-check id), with its autofixes applied
  • uv lock --upgrade: FastAPI 0.140.7, httpx-oauth 0.17.0, fastapi-users 15.0.5, OpenTelemetry 1.44/0.65b0, structlog 26, wrapt 2, and the rest of the floor-permitted refresh
  • Python 3.12 → 3.14 across .python-version, requires-python, ruff target-version, and the Docker base image — all compiled deps (cryptography, cffi, bcrypt, asyncpg, uvloop, greenlet, grpcio, pydantic-core, httptools, watchfiles) ship cp314 wheels; full suite green on 3.14.4
  • CI: checkout@v7, setup-uv pinned v9.0.0 (no v9 alias tag exists); Dockerfile uv stage pinned; weekly grouped Dependabot added

Why there is no fastapi<0.136 hold here (unlike the template)
FastAPI ≥0.137 breaks slowapi's SlowAPIMiddleware enforcement of default_limits (slowapi issue #281). This service never uses that path — rate limiting is the in-house rate_limit_auth http middleware calling limits directly with the Cloudflare-aware key — and the end-to-end limiter tests (test_client_ip.py) pass on the upgraded stack.

One test adapted, with cause
FastAPI ≥0.137 materializes included routers' routes lazily: routes are served correctly but no longer appear in app.routes at import time. Verified directly — GET /auth/google/authorize returns 200 while app.routes contains no provider paths. The OAuth-CSRF subprocess test asserted registration by scanning app.routes; it now treats the 200 response as the registration proof (same intent, behavioral evidence).

Deliberately not included

  • docker-compose Postgres stays on 16 — bumping dev while production runs its current major would create skew; coordinate a prod upgrade separately.

Deploy note: the Docker base moving to 3.14 ships a runtime change on next deploy; suggest deploying this service after a lower-stakes sibling has validated 3.14 in production.

Test results: 151 passed, 2 skipped on Python 3.14.4; ruff check/format and pre-commit all green.

The hook was pinned to v0.8.6 while the project's ruff is 0.15+, so the
hook and CI could disagree about the same code. Pin the hook to v0.16.0,
switch to the ruff-check hook id (ruff is now a legacy alias), and apply
the resulting annotation modernizations.
Refresh the lockfile across the board (FastAPI 0.140, httpx-oauth 0.17,
fastapi-users 15.0.5, OpenTelemetry 1.44/0.65b0, structlog 26, wrapt 2)
and move to Python 3.14 (.python-version, requires-python, ruff target,
Docker base image); every compiled dependency ships cp314 wheels. The uv
copy stage in the Dockerfile is pinned instead of floating on latest.

No FastAPI hold is needed here, unlike sibling services: rate limiting is
enforced by an in-house http middleware calling limits directly, not by
slowapi's SlowAPIMiddleware default_limits path that FastAPI >=0.137
breaks, and the end-to-end limiter tests pass on the new stack.

FastAPI >=0.137 materializes included routers' routes lazily, so the
OAuth registration subprocess test no longer scans app.routes (empty at
import time despite routes being served) and instead treats the 200
response itself as the registration proof.
Bump actions/checkout to v7 and pin astral-sh/setup-uv to v9.0.0 (no v9
major alias tag exists yet), and add weekly grouped Dependabot updates
for the uv, github-actions, and docker ecosystems.
@amrtgaber
amrtgaber merged commit b5ad132 into main Jul 28, 2026
3 checks passed
@amrtgaber
amrtgaber deleted the python-314-toolchain-refresh branch July 28, 2026 03:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant