Skip to content

Commit 35787d4

Browse files
committed
fix: Silence pyright unknown type errors for APIError details (#3088)
1 parent 7362aea commit 35787d4

File tree

2 files changed

+4
-5
lines changed

2 files changed

+4
-5
lines changed

pydantic_ai_slim/pydantic_ai/models/google.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -397,9 +397,9 @@ async def _generate_content(
397397
try:
398398
return await func(model=self._model_name, contents=contents, config=config) # type: ignore
399399
except errors.APIError as e:
400-
if (status_code := e.code) >= 400:
401-
raise ModelHTTPError(status_code=status_code, model_name=self._model_name, body=e.details) from e
402-
raise # pragma: lax no cover
400+
if (status_code := e.code) >= 400:
401+
raise ModelHTTPError(status_code=status_code, model_name=self._model_name, body=e.details) from e # pyright: ignore[reportUnknownArgumentType, reportUnknownMemberType]
402+
raise # pragma: lax no cover
403403

404404
async def _build_content_and_config(
405405
self,

tests/models/test_google.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3221,7 +3221,6 @@ async def test_cache_point_filtering():
32213221
assert content[1] == {'text': 'text after'}
32223222

32233223

3224-
# API 에러 테스트 데이터
32253224
@pytest.mark.parametrize(
32263225
'error_class,error_response,expected_status',
32273226
[
@@ -3260,4 +3259,4 @@ async def test_google_api_errors_are_handled(
32603259
await agent.run('This prompt will trigger the mocked error.')
32613260

32623261
assert exc_info.value.status_code == expected_status
3263-
assert error_response['error']['message'] in str(exc_info.value.body)
3262+
assert error_response['error']['message'] in str(exc_info.value.body)

0 commit comments

Comments
 (0)