Skip to content

refactor(cli): type _progress_complete's result param as ClaimResult - #294

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

refactor(cli): type _progress_complete's result param as ClaimResult#294
dhruvbatra merged 1 commit into
mainfrom
claude/admiring-hawking-n05tbc

Conversation

@dhruvbatra

@dhruvbatra dhruvbatra commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What

cli.py::_run_verify's local _progress_complete(index, claim, result) callback typed result: Any, even though it's passed directly as runner.py::VisualQARunner.run_request's on_claim_complete parameter, which already declares the exact signature Callable[[int, str, ClaimResult], None]. tests/test_runner.py's own _build_progress_recorders() helper types the equivalent callback's third parameter as ClaimResult too. Tightened the CLI's local callback to match.

Why it's an improvement

This is the same Any -> concrete-type tightening already applied across this repo to actions.py, overlay.py, runner.py, mcp_server.py, and claim_verifier.py (#281, #283, #284, #285, #289, #290): a real caller-declared type existed one call away, and the loose Any here just meant readers/tooling couldn't see that result.status/result.finding (both accessed inside the function) are guaranteed attributes.

Why it's safe

  • Annotation-only — Python does not enforce type hints at runtime, so this cannot change behavior.
  • ClaimResult is imported under TYPE_CHECKING (the file already does this for VisualQARunner) and the module has from __future__ import annotations, so there's no runtime import-cycle risk.
  • Verified the annotation is accurate: result is only ever passed in by VisualQARunner.run_request's on_claim_complete call site, which is typed and populated with real ClaimResult instances.
  • uv run pytest tests/ -> 322 passed / 21 pre-existing environment-only Chromium-sandbox failures (missing browser binary in sandbox), identical before and after.
  • tests/test_cli.py (23/23) passes directly.
  • uv run ruff check src/ tests/ clean. uv run ruff format --check flags cli.py, but that's pre-existing on main (unrelated lines ~L275/L469) — confirmed via ruff format --diff that no reformat touches this diff's lines.

1 file changed, +2/-1.


Generated by Claude Code


Note

Low Risk
Type-hint-only change in a local CLI callback; Python does not enforce it at runtime.

Overview
Types _progress_complete's third argument as ClaimResult instead of Any, matching VisualQARunner.run_request's on_claim_complete callback.

ClaimResult is imported under TYPE_CHECKING only. Annotation-only; no runtime behavior change.

Reviewed by Cursor Bugbot for commit d12b832. Bugbot is set up for automated code reviews on this repo. Configure here.

Summary by CodeRabbit

  • Refactor
    • Improved internal type annotations for verification progress reporting.
    • No user-visible behavior changes.

runner.py's run_request already declares on_claim_complete as
Callable[[int, str, ClaimResult], None], and the callback only reads
result.status/result.finding, so the Any here was strictly looser than
every real caller. Continues the Any->concrete-type vein already
applied to actions.py/overlay.py/runner.py/mcp_server.py/claim_verifier.py.

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: 8d6ca06d-2a1b-4492-a6e0-6a4dbba6a443

📥 Commits

Reviewing files that changed from the base of the PR and between b922973 and d12b832.

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

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


📝 Walkthrough

Walkthrough

The CLI now imports ClaimResult during type checking and uses it to annotate the verify progress-completion callback. Runtime behavior remains unchanged.

Changes

CLI typing

Layer / File(s) Summary
Narrow the progress callback type
src/frontend_visualqa/cli.py
The CLI imports ClaimResult for type checking and replaces the callback result annotation from Any with ClaimResult.

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

Merge Risk: ⚪ Minimal · up to d12b8

This is a localized type-hint-only change with no behavioral impact; no actionable merge-blocking risk remains after 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 main change: typing the _progress_complete result parameter as ClaimResult.
Docstring Coverage ✅ Passed Docstring check was indeterminate for this PR — some files could not be analyzed in time. Not blocking.
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-n05tbc

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 d22c45d into main Aug 24, 2026
4 checks passed
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