Skip to content

refactor: modern annotations (PEP 695, unions, Annotated dependencies) - #15

Merged
JsNcAr merged 1 commit into
mainfrom
refactor/modern-annotations
Oct 9, 2026
Merged

JsNcAr merged 1 commit into
mainfrom
refactor/modern-annotations

Conversation

@JsNcAr

@JsNcAr JsNcAr commented Oct 9, 2026

Copy link
Copy Markdown
Owner

Summary

Second pass over what Python 3.14 and the updated libraries allow, after #12 to #14. This PR is the typing half: no behaviour change.

  • Optional[X] (16 sites) becomes X | None; the typing.Optional imports go.
  • SuccessResponse is a PEP 695 generic: class SuccessResponse[T](BaseModel), no TypeVar or Generic. Verified against pydantic 2.13 (parameterised schema title unchanged) and mypy 2.4 (x.data typed correctly).
  • Every route dependency is Annotated, through two aliases in dependencies.py: SessionDep and CurrentUserDep. The eight default-value Depends, Body and Query parameters are gone; Body(...) on the registration body added nothing (a single pydantic-model parameter is the body).
  • The envelope's OpenAPI example still showed "id": 123 from before UUIDv7 ids; it is now a UUID string.
  • AGENTS.md records the typing rules; CHANGELOG.md has the entry.

Verification

  • app.openapi() dumped before and after: the only difference is the example id (two occurrences).
  • black --check, flake8, mypy (zero errors), the pure tests (--noconftest, 40 passed) locally on Python 3.14.7. CI runs the database tests.

🤖 Generated with Claude Code

Replace the 16 Optional[X] annotations with X | None, declare the response
envelope as a PEP 695 generic (class SuccessResponse[T](BaseModel), which
pydantic 2.13 and mypy 2.4 handle), and move the eight default-value
dependency parameters to Annotated through two aliases in dependencies.py:
SessionDep and CurrentUserDep. Body(...) on the registration body is dropped;
a single pydantic-model parameter is the body already.

No behaviour change. The OpenAPI document before and after differs only in
the envelope example's id, which was still an integer from before UUIDv7 ids.

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
@JsNcAr
JsNcAr merged commit b6b518a into main Oct 9, 2026
2 checks passed
@JsNcAr
JsNcAr deleted the refactor/modern-annotations branch October 9, 2026 15:56
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.

2 participants