Skip to content

refactor(navigator_client): type HTTP/2 swap params as AsyncYutoriClient - #295

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

refactor(navigator_client): type HTTP/2 swap params as AsyncYutoriClient#295
dhruvbatra merged 1 commit into
mainfrom
claude/admiring-hawking-gvho01

Conversation

@dhruvbatra

@dhruvbatra dhruvbatra commented Aug 24, 2026

Copy link
Copy Markdown
Contributor

What

enable_http2_on_yutori_client, _swap_chat_openai_to_http2, _swap_yutori_httpx_to_http2, and NavigatorClient._enable_http2 in src/frontend_visualqa/navigator_client.py all annotated their yclient parameter as Any, even though every real call site passes an AsyncYutoriClient:

  • cli.py's auth preflight constructs client = AsyncYutoriClient(api_key=api_key) and passes it straight into enable_http2_on_yutori_client.
  • NavigatorClient._ensure_client constructs self._client = AsyncYutoriClient(...) and passes it into self._enable_http2.

The module already imports AsyncYutoriClient from yutori at the top of the file. Tightened all four parameters to the concrete type, continuing the same "replace leftover Any with the concrete type the value actually is" pattern already applied and merged repeatedly in this repo (runner.py #281/#290, mcp_server.py #283/#290, actions.py #284, overlay.py #289, navigator_client.py itself #292).

_schedule_close's client parameter was deliberately left as Any — it's genuinely duck-typed, called with two different underlying client types (the old AsyncOpenAI instance and the old httpx.AsyncClient instance) and only needs a close/aclose method via resolve_optional_method.

Why it's safe

  • Annotation-only change; Python doesn't enforce type hints at runtime, so no execution path changes.
  • Any is still used elsewhere in the file (dict payloads, SDK response types, _schedule_close), so the import stays necessary.
  • Full suite: 322 passed / 21 pre-existing environment-only Chromium-sandbox failures — identical before and after (git stash A/B).
  • tests/test_navigator_client.py: 18/18 passed unchanged (its enable_http2_on_yutori_client test still passes a duck-typed SimpleNamespace stand-in for yclient, since Python doesn't enforce annotations at call time).
  • ruff check src/ tests/: clean.

Scope

1 file changed (src/frontend_visualqa/navigator_client.py), 4 lines.


Generated by Claude Code


Note

Low Risk
Type-hint-only change with no runtime or behavioral impact on HTTP/2 patching or Navigator requests.

Overview
Annotation-only tightening in navigator_client.py: the yclient argument on enable_http2_on_yutori_client, _swap_chat_openai_to_http2, _swap_yutori_httpx_to_http2, and NavigatorClient._enable_http2 is now AsyncYutoriClient instead of Any, matching real call sites (NavigatorClient._ensure_client, CLI auth preflight).

HTTP/2 swap behavior is unchanged. _schedule_close still uses Any because it accepts both AsyncOpenAI and httpx.AsyncClient duck-typed clients.

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

Summary by CodeRabbit

  • Refactor
    • Improved type accuracy for HTTP/2 client configuration interfaces.
    • No user-visible behavior or functionality changes.

enable_http2_on_yutori_client, _swap_chat_openai_to_http2,
_swap_yutori_httpx_to_http2, and NavigatorClient._enable_http2 all
annotated their yclient parameter as Any, even though every real call
site passes an AsyncYutoriClient (constructed in cli.py's auth
preflight and in NavigatorClient._ensure_client) and the module
already imports AsyncYutoriClient from yutori. Tightened all four to
the concrete type, continuing the same Any-to-concrete-type vein
already applied repeatedly elsewhere in this repo (runner.py,
mcp_server.py, actions.py, overlay.py).

Safe: annotation-only, and Python does not enforce type hints at
runtime, so no execution path changes. _schedule_close's client
parameter is left as Any since it is genuinely duck-typed across two
different client types (AsyncOpenAI and httpx.AsyncClient). Verified
with the existing test suite passing unchanged: 322 passed / 21
pre-existing environment-only Chromium-sandbox failures (identical
before/after), tests/test_navigator_client.py 18/18, ruff check clean.

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: 718abc72-f09f-4dc1-b823-68dc6b474180

📥 Commits

Reviewing files that changed from the base of the PR and between d22c45d and 8bd4d2f.

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

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


📝 Walkthrough

Walkthrough

The change narrows four yclient parameter annotations from Any to AsyncYutoriClient in the HTTP/2 client-swapping code. Runtime behavior, control flow, and error handling remain unchanged.

Changes

HTTP/2 client typing

Layer / File(s) Summary
Narrow HTTP/2 client parameter types
src/frontend_visualqa/navigator_client.py
The public helper, private swap helpers, and NavigatorClient._enable_http2 now annotate yclient as AsyncYutoriClient instead of Any.

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

Merge Risk: ⚪ Minimal · up to 8bd4d

This change only tightens type annotations without altering HTTP/2 behavior or runtime execution, so no actionable merge-blocking risk remains after normal checks and review.

Suggested reviewers: juanpin

🚥 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: narrowing HTTP/2 swap parameter types to AsyncYutoriClient.
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-gvho01

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 fc17344 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