Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit cbce9ed

Browse filesBrowse files
ref(scope): Properly type Scope.root_span
Currently, this property has type `Any`, but it can now be changed to `Optional[Span]` Depends on: - #4263
1 parent 7f14b64 commit cbce9ed
Copy full SHA for cbce9ed

File tree

Expand file treeCollapse file tree

2 files changed

+11
-8
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+11
-8
lines changed

‎sentry_sdk/integrations/huey.py

Copy file name to clipboardExpand all lines: sentry_sdk/integrations/huey.py
+10-6Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,11 +110,13 @@ def _capture_exception(exc_info):
110110
# type: (ExcInfo) -> None
111111
scope = sentry_sdk.get_current_scope()
112112

113-
if exc_info[0] in HUEY_CONTROL_FLOW_EXCEPTIONS:
114-
scope.root_span.set_status(SPANSTATUS.ABORTED)
115-
return
113+
if scope.root_span is not None:
114+
if exc_info[0] in HUEY_CONTROL_FLOW_EXCEPTIONS:
115+
scope.root_span.set_status(SPANSTATUS.ABORTED)
116+
return
117+
118+
scope.root_span.set_status(SPANSTATUS.INTERNAL_ERROR)
116119

117-
scope.root_span.set_status(SPANSTATUS.INTERNAL_ERROR)
118120
event, hint = event_from_exception(
119121
exc_info,
120122
client_options=sentry_sdk.get_client().options,
@@ -135,8 +137,10 @@ def _sentry_execute(*args, **kwargs):
135137
exc_info = sys.exc_info()
136138
_capture_exception(exc_info)
137139
reraise(*exc_info)
138-
else:
139-
sentry_sdk.get_current_scope().root_span.set_status(SPANSTATUS.OK)
140+
141+
root_span = sentry_sdk.get_current_scope().root_span
142+
if root_span is not None:
143+
root_span.set_status(SPANSTATUS.OK)
140144

141145
return result
142146

‎sentry_sdk/scope.py

Copy file name to clipboardExpand all lines: sentry_sdk/scope.py
+1-2Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -689,8 +689,7 @@ def fingerprint(self, value):
689689

690690
@property
691691
def root_span(self):
692-
# type: () -> Any
693-
# would be type: () -> Optional[Span], see https://github.com/python/mypy/issues/3004
692+
# type: () -> Optional[Span]
694693
"""Return the root span in the scope, if any."""
695694

696695
# there is no span/transaction on the scope

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.