Repository navigation
refactor: modern annotations (PEP 695, unions, Annotated dependencies) - #15
Merged
Merged
Conversation
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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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) becomesX | None; thetyping.Optionalimports go.SuccessResponseis a PEP 695 generic:class SuccessResponse[T](BaseModel), noTypeVarorGeneric. Verified against pydantic 2.13 (parameterised schema title unchanged) and mypy 2.4 (x.datatyped correctly).Annotated, through two aliases independencies.py:SessionDepandCurrentUserDep. The eight default-valueDepends,BodyandQueryparameters are gone;Body(...)on the registration body added nothing (a single pydantic-model parameter is the body)."id": 123from before UUIDv7 ids; it is now a UUID string.AGENTS.mdrecords the typing rules;CHANGELOG.mdhas 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