Skip to content

chore(#148): FastAPIの型/スタイル規約をruff・mypy・CIで機械的に強制する - #214

Open
bobtaroh wants to merge 1 commit into
developfrom
chore/fastapi-lint-mypy-ci-harness
Open

chore(#148): FastAPIの型/スタイル規約をruff・mypy・CIで機械的に強制する#214
bobtaroh wants to merge 1 commit into
developfrom
chore/fastapi-lint-mypy-ci-harness

Conversation

@bobtaroh

@bobtaroh bobtaroh commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator

概要

FastAPIの型/スタイル規約(Annotated形式)を ruff・mypy・CI で機械的に強制するハーネスを整備する。

詳細

  • ruff の FAST002 を有効化し、今後 Depends(...) 等を旧形式で書くと自動検出されるようにする(refactor(#148): FastAPI の依存/パラメータを Annotated 形式に統一 #213 のAnnotated化を継続的に強制するハーネス)
  • mypy / ruff format のエラー・差分をゼロにし、server/scripts/verify.sh を新規追加してゲート化(ruff check / ruff format / mypy / FastAPI import+OpenAPI生成スモークを一括実行)
  • CI (ci_server.yml) は従来 uv sync のみで lint/型チェックが一切実行されていなかったため、verify.sh 実行ステップを追加
  • .claude/rules/backend.md に Annotated化・DI引数の並び順・検証方法のルールを明文化

mypy修正の内訳:

  • firebase_admin: 型スタブ未配布のため ignore_missing_imports を設定
  • nanoid: types-nanoid を dev 依存に追加
  • notification.py: ループ変数名の使い回し(RowMapping/dictr を共用)を item にリネームして解消
  • trips.py/pages.py/blocks.py の一覧取得系: list[Model]list[Schema] として返す不変性エラーを mypy 推奨の Sequence に変更して解消(response_model がシリアライズを担うため実行時挙動は変化なし)

Base ブランチは #213 です。#213 マージ後に develop へのdiffのみになります。

動作確認

  • server/scripts/verify.sh — 全項目 (ruff check / ruff format / mypy / smoke) パス

確認項目

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

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

- ruff: FAST002 を有効化し、Annotated形式を今後も強制する
- mypy: firebase_admin(型スタブ未配布)をignore_missing_imports、
  types-nanoidを追加、list[Model]→list[Schema]の不変性エラーを
  Sequence化で解消、notification.pyの変数名衝突を解消
- ruff format による既存ファイルの整形差分を解消
- server/scripts/verify.sh を新規追加し、ruff check/format・mypy・
  FastAPIのimport+OpenAPI生成スモークテストを一括実行できるようにする
  (DB起動不要でリファクタの回帰を検知できる)
- CI (ci_server.yml) に verify.sh 実行ステップを追加。従来 uv sync の
  みでlint/型チェックが一切実行されていなかったギャップを埋める
- .claude/rules/backend.md にAnnotated化・DI引数の並び順・検証方法を明文化

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:15
@bobtaroh
bobtaroh requested review from koki-fore and kuu13580 and removed request for a team August 1, 2026 01:15
@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

Warning

Review limit reached

@bobtaroh, you've reached your PR review limit, so we couldn't start this review.

Next review available in: 46 minutes

Enable usage-based reviews in Billing to review now. Otherwise, wait until the next included review is available.
You're only billed for reviews past your plan's rate limits ($0.25/file).

How can I continue?

After more reviews become available, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

To avoid repeated limits, reduce automatic review volume by pausing incremental auto-reviews earlier, using label-based review opt-in, excluding WIP or generated PR titles, or requesting reviews manually when the PR is ready. If your team needs uninterrupted high-volume reviews, an organization admin can enable usage-based reviews.

How do review limits work?

CodeRabbit enforces per-developer PR review limits for each organization. Most developers receive the normal plan review availability.

For paid Pro and Pro+ PR reviews, CodeRabbit uses adaptive limits for sustained high-volume activity. When a developer's recent PR review activity reaches the 95th percentile or higher among CodeRabbit users, additional reviews become available more gradually as earlier reviews age out of the rolling window.

Please refer docs for additional details.

Review details
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: CHILL

Plan: Pro Plus

Run ID: 072fd17a-76ac-44e8-bf68-2a7ae8f0ea6e

📥 Commits

Reviewing files that changed from the base of the PR and between 030e744 and 8d0c994.

⛔ Files ignored due to path filters (1)
  • server/uv.lock is excluded by !**/*.lock
📒 Files selected for processing (15)
  • .claude/rules/backend.md
  • .github/workflows/ci_server.yml
  • server/app/cruds/blocks.py
  • server/app/cruds/notification.py
  • server/app/cruds/pages.py
  • server/app/cruds/trips.py
  • server/app/notification_content.py
  • server/app/oidc.py
  • server/app/routers/blocks.py
  • server/app/routers/pages.py
  • server/app/routers/trips.py
  • server/app/schemas/location.py
  • server/app/schemas/trip.py
  • server/pyproject.toml
  • server/scripts/verify.sh

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 8d0c994):

https://tabi-share-8ef6b--pr214-chore-fastapi-lint-m-al0lo0wh.web.app

(expires Sat, 08 Aug 2026 01:29:23 GMT)

🔥 via Firebase Hosting GitHub Action 🌎

Sign: 9f2a87ede127df7673322845e34cf22c1372d720

Base automatically changed from refactor/fastapi-annotated-di to develop August 1, 2026 01:19
@kuu13580

kuu13580 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai approve

@tabi-bit tabi-bit deleted a comment from coderabbitai Bot Aug 1, 2026
@tabi-bit tabi-bit deleted a comment from coderabbitai Bot Aug 1, 2026
@kuu13580

kuu13580 commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

@coderabbitai re-review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown

@kuu13580: I will re-review the changes in #214.

✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@bobtaroh

bobtaroh commented Aug 1, 2026

Copy link
Copy Markdown
Collaborator Author

@coderabbitai review

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
✅ Action performed

Review finished.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

@bobtaroh bobtaroh closed this Aug 1, 2026
@bobtaroh bobtaroh reopened this Aug 1, 2026
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