Skip to content

Commit 48af290

Browse files
committed
fix: mypy issues
1 parent b9f3357 commit 48af290

File tree

3 files changed

+10
-10
lines changed

3 files changed

+10
-10
lines changed

sentry_sdk/integrations/pydantic_ai/patches/agent_run.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import TYPE_CHECKING
1010

1111
if TYPE_CHECKING:
12-
from typing import Any, Callable
12+
from typing import Any, Callable, Optional
1313

1414
try:
1515
import pydantic_ai
@@ -25,8 +25,8 @@ def __init__(self, agent, original_ctx_manager, is_streaming=True):
2525
self.agent = agent
2626
self.original_ctx_manager = original_ctx_manager
2727
self.is_streaming = is_streaming
28-
self._isolation_scope = None
29-
self._workflow_span = None
28+
self._isolation_scope = None # type: Any
29+
self._workflow_span = None # type: Optional[sentry_sdk.tracing.Span]
3030

3131
async def __aenter__(self):
3232
# type: () -> Any
@@ -217,6 +217,6 @@ def _patch_agent_run():
217217

218218
# Wrap and apply patches for streaming methods
219219
Agent.run_stream = _create_streaming_wrapper(original_run_stream) # type: ignore
220-
Agent.run_stream_events = _create_streaming_events_wrapper(
220+
Agent.run_stream_events = _create_streaming_events_wrapper( # type: ignore[method-assign]
221221
original_run_stream_events
222-
) # type: ignore
222+
)

sentry_sdk/integrations/pydantic_ai/patches/graph_nodes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,12 @@ async def wrapped_user_prompt_run(self, ctx):
8383
span = invoke_agent_span(user_prompt, agent, model, model_settings)
8484
# Store span in context for later use
8585
if hasattr(ctx, "state"):
86-
ctx.state._sentry_invoke_span = span # type: ignore
86+
ctx.state._sentry_invoke_span = span
8787

8888
result = await original_user_prompt_run(self, ctx)
8989
return result
9090

91-
UserPromptNode.run = wrapped_user_prompt_run # type: ignore
91+
UserPromptNode.run = wrapped_user_prompt_run # type: ignore[method-assign]
9292

9393
# Patch ModelRequestNode to create ai_client spans
9494
original_model_request_run = ModelRequestNode.run

sentry_sdk/integrations/pydantic_ai/utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from typing import TYPE_CHECKING
1010

1111
if TYPE_CHECKING:
12-
from typing import Any
12+
from typing import Any, List, Dict
1313
from pydantic_ai.usage import RequestUsage
1414

1515
try:
@@ -213,7 +213,7 @@ def _set_input_messages(span, messages):
213213
elif "ToolReturn" in part.__class__.__name__:
214214
role = "tool"
215215

216-
content = []
216+
content = [] # type: List[Dict[str, Any] | str]
217217
tool_calls = None
218218
tool_call_id = None
219219

@@ -247,7 +247,7 @@ def _set_input_messages(span, messages):
247247

248248
# Add message if we have content or tool calls
249249
if content or tool_calls:
250-
message = {"role": role}
250+
message = {"role": role} # type: Dict[str, Any]
251251
if content:
252252
message["content"] = content
253253
if tool_calls:

0 commit comments

Comments
 (0)