Skip to content

Commit dc0a147

Browse files
committed
mypy fixes
1 parent e003535 commit dc0a147

File tree

2 files changed

+10
-13
lines changed

2 files changed

+10
-13
lines changed

sentry_sdk/integrations/google_genai/streaming.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,10 @@ def accumulate_streaming_response(chunks):
8787
output_tokens_reasoning=total_reasoning_tokens,
8888
total_tokens=total_tokens,
8989
),
90+
id=response_id,
91+
model=model,
9092
)
9193

92-
if response_id:
93-
accumulated_response["id"] = response_id
94-
if model:
95-
accumulated_response["model"] = model
96-
9794
return accumulated_response
9895

9996

sentry_sdk/integrations/google_genai/utils.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ def extract_contents_text(contents):
171171

172172
# Content object with parts - recurse into parts
173173
if getattr(contents, "parts", None):
174-
return extract_contents_text(contents.parts)
174+
return extract_contents_text(contents.parts) # type: ignore
175175

176176
# Direct text attribute
177177
if hasattr(contents, "text"):
@@ -228,14 +228,14 @@ def extract_tool_calls(response):
228228
tool_calls = []
229229

230230
# Extract from candidates, sometimes tool calls are nested under the content.parts object
231-
if hasattr(response, "candidates"):
232-
for candidate in response.candidates:
233-
if not hasattr(candidate, "content") or not hasattr(
234-
candidate.content, "parts"
231+
if getattr(response, "candidates", []):
232+
for candidate in response.candidates: # type: ignore
233+
if not hasattr(candidate, "content") or not getattr(
234+
candidate.content, "parts", []
235235
):
236236
continue
237237

238-
for part in candidate.content.parts:
238+
for part in candidate.content.parts: # type: ignore
239239
if getattr(part, "function_call", None):
240240
function_call = part.function_call
241241
tool_call = {
@@ -244,8 +244,8 @@ def extract_tool_calls(response):
244244
}
245245

246246
# Extract arguments if available
247-
if hasattr(function_call, "args"):
248-
tool_call["arguments"] = safe_serialize(function_call.args)
247+
if getattr(function_call, "args", None):
248+
tool_call["arguments"] = safe_serialize(function_call.args) # type: ignore
249249

250250
tool_calls.append(tool_call)
251251

0 commit comments

Comments
 (0)