|
44 | 44 | except ImportError: |
45 | 45 | raise DidNotEnable("Anthropic not installed") |
46 | 46 |
|
| 47 | +from sentry_sdk.tracing import Span |
| 48 | + |
47 | 49 | if TYPE_CHECKING: |
48 | 50 | from typing import Any, AsyncIterator, Iterator, List, Optional, Union |
49 | | - from sentry_sdk.tracing import Span |
50 | 51 | from sentry_sdk._types import TextPart |
51 | 52 |
|
52 | 53 |
|
@@ -551,7 +552,7 @@ def _sentry_patched_create_sync(*args: "Any", **kwargs: "Any") -> "Any": |
551 | 552 | return _execute_sync(f, *args, **kwargs) |
552 | 553 | finally: |
553 | 554 | span = sentry_sdk.get_current_span() |
554 | | - if span is not None and span.status == SPANSTATUS.INTERNAL_ERROR: |
| 555 | + if isinstance(span, Span) and span.status == SPANSTATUS.INTERNAL_ERROR: |
555 | 556 | with capture_internal_exceptions(): |
556 | 557 | span.__exit__(None, None, None) |
557 | 558 |
|
@@ -589,7 +590,7 @@ async def _sentry_patched_create_async(*args: "Any", **kwargs: "Any") -> "Any": |
589 | 590 | return await _execute_async(f, *args, **kwargs) |
590 | 591 | finally: |
591 | 592 | span = sentry_sdk.get_current_span() |
592 | | - if span is not None and span.status == SPANSTATUS.INTERNAL_ERROR: |
| 593 | + if isinstance(span, Span) and span.status == SPANSTATUS.INTERNAL_ERROR: |
593 | 594 | with capture_internal_exceptions(): |
594 | 595 | span.__exit__(None, None, None) |
595 | 596 |
|
|
0 commit comments