Skip to content

Commit 3eced24

Browse files
committed
mypy
1 parent ac60719 commit 3eced24

File tree

3 files changed

+12
-7
lines changed

3 files changed

+12
-7
lines changed

sentry_sdk/integrations/django/tasks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
# django.tasks were added in Django 6.0
99
from django.tasks.base import Task
1010
except ImportError:
11-
Task = None
11+
Task = None # type: ignore[misc, assignment]
1212

1313
from typing import TYPE_CHECKING
1414

@@ -22,7 +22,7 @@ def patch_tasks() -> None:
2222

2323
old_task_enqueue = Task.enqueue
2424

25-
@wraps(old_task_enqueue)
25+
@wraps(old_task_enqueue) # type: ignore[arg-type]
2626
def _sentry_enqueue(self: "Any", *args: "Any", **kwargs: "Any") -> "Any":
2727
from sentry_sdk.integrations.django import DjangoIntegration
2828

@@ -37,4 +37,4 @@ def _sentry_enqueue(self: "Any", *args: "Any", **kwargs: "Any") -> "Any":
3737
):
3838
return old_task_enqueue(self, *args, **kwargs)
3939

40-
Task.enqueue = _sentry_enqueue
40+
Task.enqueue = _sentry_enqueue # type: ignore[method-assign]

sentry_sdk/integrations/httpx.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,8 @@
2222
if TYPE_CHECKING:
2323
from typing import Any, Optional, Union
2424

25+
from sentry_sdk._types import Attributes
26+
2527

2628
try:
2729
from httpx import AsyncClient, Client, Request, Response
@@ -61,7 +63,7 @@ def send(self: "Client", request: "Request", **kwargs: "Any") -> "Response":
6163

6264
span_ctx: "Optional[Union[Span, StreamedSpan]]" = None
6365
if span_streaming:
64-
attributes = {
66+
attributes: "Attributes" = {
6567
"sentry.op": OP.HTTP_CLIENT,
6668
"sentry.origin": HttpxIntegration.origin,
6769
SPANDATA.HTTP_METHOD: request.method,
@@ -145,7 +147,7 @@ async def send(
145147

146148
span_ctx: "Optional[Union[Span, StreamedSpan]]" = None
147149
if span_streaming:
148-
attributes = {
150+
attributes: "Attributes" = {
149151
"sentry.op": OP.HTTP_CLIENT,
150152
"sentry.origin": HttpxIntegration.origin,
151153
SPANDATA.HTTP_METHOD: request.method,

sentry_sdk/integrations/rust_tracing.py

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@
3232

3333
import json
3434
from enum import Enum, auto
35-
from typing import Any, Callable, Dict, Optional
35+
from typing import Any, Callable, Dict, Optional, Union
3636

3737
import sentry_sdk
3838
from sentry_sdk.integrations import Integration
@@ -184,7 +184,9 @@ def on_event(self, event: str, sentry_span: "Span") -> None:
184184
elif event_type == EventTypeMapping.Event:
185185
process_event(deserialized_event)
186186

187-
def on_new_span(self, attrs: str, span_id: str) -> "Optional[Span]":
187+
def on_new_span(
188+
self, attrs: str, span_id: str
189+
) -> "Union[Span, StreamedSpan, None]":
188190
attrs = json.loads(attrs)
189191
metadata = attrs.get("metadata", {})
190192

@@ -206,6 +208,7 @@ def on_new_span(self, attrs: str, span_id: str) -> "Optional[Span]":
206208

207209
client = sentry_sdk.get_client()
208210

211+
sentry_span: "Union[Span, StreamedSpan]"
209212
if has_span_streaming_enabled(client.options):
210213
sentry_span = sentry_sdk.traces.start_span(
211214
name=sentry_span_name,

0 commit comments

Comments
 (0)