feat(ci): backend に pyright 型チェックを hard gate として導入#446
Conversation
CI(test-backend)とローカル(make typecheck-backend / make lint)に pyright を 追加し、Python の型エラーをビルドで検知する。TS は既に tsc -b で型チェック済みの ため、BE/FE 両方が型チェックされる対称な状態にする。 - CI: test.yml の test-backend に uvx pyright@1.1.411 ステップを追加 (deploy-gate は test-backend を見るため自動的にゲート対象に入る) - ローカル: Makefile に typecheck-backend を追加し make lint に組込み。docs 更新 - 既存の型エラー 93 件を 0 に修正 - resume.py の payload を dict[str, Any] 化、get_cookie_samesite を Literal 化 - テストの None narrowing(assert is not None)/ Project.model_validate 置換 - LLM SDK 境界の cast、notification の CursorResult cast 等 - 到達不能だった blog/accounts.py の except BlogAccountNotFoundError を削除(挙動等価) - test_pdf_generator の契約違反(format_period に None)をテスト側で修正 pyright のバージョンは CI と Makefile でピン留めを揃える(drift 防止)。 スキル manifest/import スキャナの tuple/str 注釈も取り込み registry の型を解決。 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Plus Run ID: 📒 Files selected for processing (36)
💤 Files with no reviewable changes (1)
📝 WalkthroughWalkthroughAdds a pinned pyright (1.1.411) type-check step to CI and a new ChangesBackend pyright type-checking rollout
Estimated code review effort🎯 2 (Simple) | ⏱️ ~20 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 passed)
✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
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. Comment |
概要
backend に pyright 型チェックを CI の必須チェック(hard gate)として導入する。TS は既に
tsc -b(npm run build)で CI 型チェック済みのため、これにより BE/FE 両方が型チェックされる対称な状態になる。導入にあたり既存の型エラー 93 件 → 0 件 を修正した。
変更点
CI / ツール
.github/workflows/test.ymlのtest-backendにuvx pyright@1.1.411ステップを追加(Lint backend の直後)。deploy-gateはtest-backendの結果を見るため自動的にゲート対象に入る。Makefileにtypecheck-backendを追加しlint(=make ci)に組込み。docs/development.md/CLAUDE.mdを更新。1.1.411)。更新時は 2 箇所同期。uvx pyright@<ver>で統一。型エラー 93→0 の主な修正
repositories/resume.py: 動的 payload 引数をdict[str, object]→dict[str, Any]化(22 件)core/settings.py:get_cookie_samesiteの戻り値をLiteral["lax","strict","none"]にassert ... is not Noneによる None narrowing /Project.model_validate({...})置換(test_schemas.py17 件)cast、notificationのCursorResultcast挙動・契約に関わる修正(レビュー注目点)
routers/blog/accounts.py: 到達不能だったexcept BlogAccountNotFoundError(ValueErrorサブクラスで先行 catch 済み・同じ 404/account_not_found)を削除。挙動は等価。tests/test_pdf_generator.py:format_period(..., None, True)は docstring 契約(在籍中はend_date="")違反。本番は常に""を渡すためテスト側を""に修正(実装は不変)。検証
make cigreen: pyright 0 errors / backend 648 passed / web 365 passed + build 成功。🤖 Generated with Claude Code
Summary by CodeRabbit
Bug Fixes
Chores