Skip to content

Fix "indented block" linter error #3468

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Aug 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 8 additions & 4 deletions sentry_sdk/integrations/opentelemetry/potel_span_processor.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from collections import deque, defaultdict
from typing import cast

from opentelemetry.trace import format_trace_id, format_span_id
from opentelemetry.context import Context
Expand Down Expand Up @@ -145,7 +146,7 @@ def _root_span_to_transaction_event(self, span):
"transaction_info": {"source": "custom"},
"contexts": contexts,
}
) # type: Event
)

return event

Expand All @@ -154,7 +155,10 @@ def _span_to_json(self, span):
if not span.context:
return None

span_json = self._common_span_transaction_attributes_as_json(span)
# This is a safe cast because dict[str, Any] is a superset of Event
span_json = cast(
"dict[str, Any]", self._common_span_transaction_attributes_as_json(span)
)
if span_json is None:
return None

Expand Down Expand Up @@ -184,14 +188,14 @@ def _span_to_json(self, span):
return span_json

def _common_span_transaction_attributes_as_json(self, span):
# type: (ReadableSpan) -> Optional[dict[str, Any]]
# type: (ReadableSpan) -> Optional[Event]
if not span.start_time or not span.end_time:
return None

common_json = {
"start_timestamp": convert_from_otel_timestamp(span.start_time),
"timestamp": convert_from_otel_timestamp(span.end_time),
} # type: dict[str, Any]
} # type: Event

measurements = extract_span_attributes(span, SentrySpanAttribute.MEASUREMENT)
if measurements:
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/integrations/opentelemetry/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,10 @@ def _get_current_scope(cls):

@classmethod
def get_isolation_scope(cls):
# type: () -> Scope
"""
Returns the isolation scope.
"""
# type: () -> Scope
return cls._get_isolation_scope() or _INITIAL_ISOLATION_SCOPE

@classmethod
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/scope.py
Original file line number Diff line number Diff line change
Expand Up @@ -769,8 +769,8 @@ def span(self):

@span.setter
def span(self, span):
"""Set current tracing span."""
# type: (Optional[Span]) -> None
"""Set current tracing span."""
self._span = span
# XXX: this differs from the implementation in JS, there Scope.setSpan
# does not set Scope._transactionName.
Expand Down
2 changes: 1 addition & 1 deletion sentry_sdk/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -1363,7 +1363,7 @@ def sampled(self):

@sampled.setter
def sampled(self, value):
# type: () -> Optional[bool]
# type: (Optional[bool]) -> None
pass

@property
Expand Down
Loading