Skip to content

refactor(schemas): type _pydantic_field_default's model param as type[BaseModel] - #296

Merged
dhruvbatra merged 1 commit into
mainfrom
claude/admiring-hawking-1p68kz
Aug 24, 2026
Merged

refactor(schemas): type _pydantic_field_default's model param as type[BaseModel]#296
dhruvbatra merged 1 commit into
mainfrom
claude/admiring-hawking-1p68kz

Conversation

@dhruvbatra

@dhruvbatra dhruvbatra commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

_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.

Safe: annotation-only, and Python does not enforce type hints at runtime, so no execution path changes.

Verification:

  • uv run ruff check src/ tests/ — clean
  • uv 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 model parameter on _pydantic_field_default from type[Any] to type[BaseModel], matching how callers (CLI, runner, MCP, overlay) always pass Pydantic model classes and how the helper uses model.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 remains Any because 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

  • Refactor
    • Improved internal type clarity for model field defaults without changing runtime behavior or user-facing functionality.

…[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>
@coderabbitai

coderabbitai Bot commented Aug 24, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 6e737b53-9c26-453d-ab14-79f8f4ffefbe

📥 Commits

Reviewing files that changed from the base of the PR and between fc17344 and 62290dc.

📒 Files selected for processing (1)
  • src/frontend_visualqa/schemas.py

Included review availability: Your plan provides up to 1 included review per hour; 0 remain after this review.


📝 Walkthrough

Walkthrough

The schema helper now annotates its model parameter as type[BaseModel]. Runtime behavior and the return type remain unchanged.

Changes

Schema typing

Layer / File(s) Summary
Narrow model annotation
src/frontend_visualqa/schemas.py
The helper’s model parameter uses type[BaseModel] instead of type[Any].

Estimated code review effort: 1 (Trivial) | ~2 minutes

Merge Risk: ⚪ Minimal · up to 62290

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)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely describes the annotation change to the model parameter in _pydantic_field_default.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 2 functions across 1 files.
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.
✨ 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 claude/admiring-hawking-1p68kz

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.

@dhruvbatra
dhruvbatra merged commit 4c4132e into main Aug 24, 2026
4 checks passed
dhruvbatra added a commit that referenced this pull request Aug 25, 2026
…| 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>
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