refactor(schemas): type _pydantic_field_default's model param as type[BaseModel] - #296
Conversation
…[BaseModel] _pydantic_field_default annotated its model parameter as type[Any], even though every call site (cli.py, runner.py, mcp_server.py, overlay.py) passes a pydantic model class (VerifyVisualClaimsInput or ViewportConfig), and the function reads model.model_fields, a BaseModel classvar. Tightened to type[BaseModel], continuing the same Any-to-concrete-type vein already applied repeatedly elsewhere in this repo (navigator_client.py, runner.py, mcp_server.py, actions.py, overlay.py). The return type stays Any since a field's declared default can genuinely be any type. Co-authored-by: Claude <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 (1)
Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review. 📝 WalkthroughWalkthroughThe schema helper now annotates its ChangesSchema typing
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to This localized annotation-only change does not alter runtime behavior or user-facing functionality, and no actionable merge-blocking risk remains beyond normal checks and review. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 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 |
…| type[ClaimVerifier] (#297) _load_class returned Any even though _DEFERRED_IMPORTS only ever names NavigatorClient or ClaimVerifier, both already imported under TYPE_CHECKING in this file, and both call sites immediately instantiate the result. Continuing the same Any/type[Any]-to-concrete-type vein as PRs #290-#296. Claude-Session: https://claude.ai/code/session_01UNp1qd4G67kz4mMxt5Z6u3 Co-authored-by: Claude <noreply@anthropic.com>
_pydantic_field_defaultannotated itsmodelparameter astype[Any], even though every call site (cli.py,runner.py,mcp_server.py,overlay.py) passes a pydantic model class (VerifyVisualClaimsInputorViewportConfig), and the function readsmodel.model_fields, aBaseModelclassvar. Tightened totype[BaseModel], continuing the same Any-to-concrete-type vein already applied repeatedly elsewhere in this repo (navigator_client.py,runner.py,mcp_server.py,actions.py,overlay.py). The return type staysAnysince a field's declared default can genuinely be any type.Safe: annotation-only, and Python does not enforce type hints at runtime, so no execution path changes.
Verification:
uv run ruff check src/ tests/— cleanuv run pytest tests/— 322 passed, 21 failed (identical pre-existing environment-only Chromium-sandbox failures, same set as before this change)Generated by Claude Code
Note
Low Risk
Annotation-only change with no runtime or behavioral impact.
Overview
Narrows the
modelparameter on_pydantic_field_defaultfromtype[Any]totype[BaseModel], matching how callers (CLI, runner, MCP, overlay) always pass Pydantic model classes and how the helper usesmodel.model_fields.Runtime behavior is unchanged; this is a static typing refinement aligned with similar
Any→ concrete type cleanups elsewhere in the repo. The return type remainsAnybecause field defaults can be arbitrary values.Reviewed by Cursor Bugbot for commit 62290dc. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit