refactor(navigator_client): type HTTP/2 swap params as AsyncYutoriClient - #295
Conversation
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>
|
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 change narrows four ChangesHTTP/2 client typing
Estimated code review effort: 1 (Trivial) | ~2 minutes Merge Risk: ⚪ Minimal · up to 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: 🚥 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 |
What
enable_http2_on_yutori_client,_swap_chat_openai_to_http2,_swap_yutori_httpx_to_http2, andNavigatorClient._enable_http2insrc/frontend_visualqa/navigator_client.pyall annotated theiryclientparameter asAny, even though every real call site passes anAsyncYutoriClient:cli.py's auth preflight constructsclient = AsyncYutoriClient(api_key=api_key)and passes it straight intoenable_http2_on_yutori_client.NavigatorClient._ensure_clientconstructsself._client = AsyncYutoriClient(...)and passes it intoself._enable_http2.The module already imports
AsyncYutoriClientfromyutoriat the top of the file. Tightened all four parameters to the concrete type, continuing the same "replace leftoverAnywith 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.pyitself #292)._schedule_close'sclientparameter was deliberately left asAny— it's genuinely duck-typed, called with two different underlying client types (the oldAsyncOpenAIinstance and the oldhttpx.AsyncClientinstance) and only needs aclose/aclosemethod viaresolve_optional_method.Why it's safe
Anyis still used elsewhere in the file (dict payloads, SDK response types,_schedule_close), so the import stays necessary.git stashA/B).tests/test_navigator_client.py: 18/18 passed unchanged (itsenable_http2_on_yutori_clienttest still passes a duck-typedSimpleNamespacestand-in foryclient, 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: theyclientargument onenable_http2_on_yutori_client,_swap_chat_openai_to_http2,_swap_yutori_httpx_to_http2, andNavigatorClient._enable_http2is nowAsyncYutoriClientinstead ofAny, matching real call sites (NavigatorClient._ensure_client, CLI auth preflight).HTTP/2 swap behavior is unchanged.
_schedule_closestill usesAnybecause it accepts bothAsyncOpenAIandhttpx.AsyncClientduck-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