Skip to content

refactor(#148): FastAPI の依存/パラメータを Annotated 形式に統一 - #213

Merged
bobtaroh merged 1 commit into
developfrom
refactor/fastapi-annotated-di
Aug 1, 2026
Merged

refactor(#148): FastAPI の依存/パラメータを Annotated 形式に統一#213
bobtaroh merged 1 commit into
developfrom
refactor/fastapi-annotated-di

Conversation

@bobtaroh

@bobtaroh bobtaroh commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

概要

FastAPI の依存/パラメータをすべて Annotated 形式に統一する。

詳細

  • Depends/Query/Header をデフォルト値へ直接代入する旧形式(x: T = Depends(...))を廃止し、x: Annotated[T, Depends(...)] 形式に統一(main.py / auth.py / routers/*.py
  • DI (Depends) 系の引数は関数シグネチャの先頭に配置し、依存関係が一目で分かるように並び替え
  • 挙動・OpenAPIスキーマへの影響なし(純粋なシグネチャの書き方変更)
  • ruff/mypyの体制強化(FAST002ルール追加・検証スクリプト・CI変更)は別PR chore(#148): FastAPIの型/スタイル規約をruff・mypy・CIで機械的に強制する #214 に分離

動作確認

  • uv run ruff check app/ — pass
  • アプリ import + app.openapi() によるスモークテスト(DIグラフ・引数順の破綻を検出)— 11 paths, 25 routes で成功

確認項目

  • 動作確認を実施している
  • issueはPRページ右下のDevelopmentからissueが紐づいている

Co-Authored-By: Claude Sonnet 5 noreply@anthropic.com

- Depends/Query/Header をデフォルト値へ直接代入する旧形式を廃止し、
  Annotated[T, ...] 形式に統一
- DI (Depends) 系の引数は関数シグネチャの先頭に配置し、依存関係が
  一目で分かるように並び替え

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
@bobtaroh
bobtaroh requested a review from a team as a code owner August 1, 2026 01:13
@bobtaroh
bobtaroh requested review from koki-fore and kuu13580 and removed request for a team August 1, 2026 01:13
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Review Change Stack

📝 Walkthrough

Walkthrough

Changes

Annotated依存性注入への移行

Layer / File(s) Summary
認証と共通エンドポイントの宣言変更
server/app/auth.py, server/app/main.py
認証依存関数、Swagger UI、ReDoc、OpenAPI、ヘルスチェックのパラメータをAnnotated形式へ変更しました。認証処理、制約、遅延の既定値は維持しています。
旅行、ページ、ブロックAPIの依存性変更
server/app/routers/trips.py, server/app/routers/pages.py, server/app/routers/blocks.py
各APIの認証認可依存性とDBセッション依存性をAnnotated形式へ変更しました。CRUD処理とアクセス制御は維持しています。
通知APIの依存性とヘッダー宣言
server/app/routers/notification.py
FCMヘッダー、旅行認証、DBセッションの宣言をAnnotated形式へ変更しました。通知処理と環境別URLの値は維持しています。
内部通知エンドポイントのDB依存性変更
server/app/routers/notification_internal.py
tickのDBセッション依存性をAnnotated形式へ変更しました。処理と戻り値の型は維持しています。

Estimated code review effort: 2 (Simple) | ~10 minutes

Suggested reviewers: koki-fore, kuu13580

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed タイトルは、FastAPIの依存関係とパラメータをAnnotated形式へ統一する主要な変更を明確に示しています。
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch refactor/fastapi-annotated-di

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@github-actions

github-actions Bot commented Aug 1, 2026

Copy link
Copy Markdown

Visit the preview URL for this PR (updated for commit a7d7273):

https://tabi-share-8ef6b--pr213-refactor-fastapi-ann-negupvgg.web.app

(expires Sat, 08 Aug 2026 01:14:40 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 9f2a87ede127df7673322845e34cf22c1372d720

@bobtaroh
bobtaroh merged commit 030e744 into develop Aug 1, 2026
8 checks passed
@bobtaroh
bobtaroh deleted the refactor/fastapi-annotated-di branch August 1, 2026 01:19
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