Skip to content

Commit fb7bb14

Browse files
fix(OPEN-11891): satisfy pyright in both lint environments
CI's lint env has neither google-genai nor google-adk installed, so `from google import genai` resolves to an unknown attribute on the `google` namespace package (reportMissingTypeStubs + reportAttributeAccessIssue). Locally, where the package IS installed, pyright instead flags `inference_id` as an undeclared kwarg on generate_content -- which is the point, since the tracer pops it before calling through. Suppress those three at file level in both new test files, and fix a genuine typing slip: the async streaming comprehension yielded list[str | None] against a List[str] annotation. Verified against a venv with no google-* packages (matching CI) as well as the local env with both installed: 0 errors either way, and no pyright errors attributable to the new files repo-wide. Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01A8GauFiK5edFUfGnbjJrtz
1 parent e1e518e commit fb7bb14

2 files changed

Lines changed: 9 additions & 2 deletions

File tree

tests/test_google_genai_adk_dedup.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,10 @@
1616
class-init patch, so ADK's real call path is exercised end to end.
1717
"""
1818

19+
# Neither google-adk nor google-genai is installed in the lint env, so imports
20+
# from the `google` namespace package don't resolve there.
1921
# pyright: reportMissingImports=false, reportUnknownMemberType=false, reportUnknownVariableType=false, reportUnknownArgumentType=false, reportUnknownParameterType=false, reportMissingParameterType=false, reportUnusedFunction=false
22+
# pyright: reportMissingTypeStubs=false, reportAttributeAccessIssue=false, reportCallIssue=false
2023

2124
import asyncio
2225
from typing import Any, Dict, List

tests/test_google_genai_integration.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,12 @@
1111
"""
1212

1313
# google-genai isn't installed in the lint env, and pytest fixtures hide autouse
14-
# functions from static analysis.
14+
# functions from static analysis. The last two matter in BOTH directions: without
15+
# the package, `from google import genai` is an unresolved attribute on a
16+
# namespace package; with it, `inference_id` is an extra kwarg the SDK's own
17+
# signature doesn't declare (that's the whole point -- the tracer pops it).
1518
# pyright: reportMissingImports=false, reportUnknownMemberType=false, reportUnknownVariableType=false, reportUnknownArgumentType=false, reportUnknownParameterType=false, reportMissingParameterType=false, reportUnusedFunction=false
19+
# pyright: reportMissingTypeStubs=false, reportAttributeAccessIssue=false, reportCallIssue=false
1620

1721
import asyncio
1822
import contextvars
@@ -291,7 +295,7 @@ def test_streaming_async_is_await_then_async_for(self) -> None:
291295

292296
async def _drive() -> List[str]:
293297
stream = await client.aio.models.generate_content_stream(model="gemini-2.5-flash", contents="hi")
294-
return [chunk.text async for chunk in stream]
298+
return [chunk.text async for chunk in stream if chunk.text]
295299

296300
with patch.object(gg, "add_to_trace") as mock_add:
297301
texts = asyncio.run(_drive())

0 commit comments

Comments
 (0)