@@ -59,15 +59,19 @@ def internal_method(self):
5959import logging
6060
6161from collections .abc import Callable
62- from typing import Any
62+ from typing import TYPE_CHECKING , Any
6363
6464
65+ if TYPE_CHECKING :
66+ from opentelemetry .trace import SpanKind as SpanKindType
67+ else :
68+ SpanKindType = object
69+
6570logger = logging .getLogger (__name__ )
6671
6772try :
6873 from opentelemetry import trace
69- from opentelemetry .trace import SpanKind as _SpanKind
70- from opentelemetry .trace import StatusCode
74+ from opentelemetry .trace import SpanKind , StatusCode
7175
7276except ImportError :
7377 logger .debug (
@@ -91,12 +95,9 @@ def __getattr__(self, name: str) -> '_NoOp':
9195 return self
9296
9397 trace = _NoOp ()
94- _SpanKind = _NoOp ()
98+ SpanKind = _NoOp ()
9599 StatusCode = _NoOp ()
96100
97- SpanKind = _SpanKind
98- __all__ = ['SpanKind' ]
99-
100101INSTRUMENTING_MODULE_NAME = 'a2a-python-sdk'
101102INSTRUMENTING_MODULE_VERSION = '1.0.0'
102103
@@ -105,7 +106,7 @@ def trace_function( # noqa: PLR0915
105106 func : Callable | None = None ,
106107 * ,
107108 span_name : str | None = None ,
108- kind : SpanKind = SpanKind .INTERNAL ,
109+ kind : SpanKindType = SpanKind .INTERNAL ,
109110 attributes : dict [str , Any ] | None = None ,
110111 attribute_extractor : Callable | None = None ,
111112) -> Callable :
@@ -252,7 +253,7 @@ def sync_wrapper(*args, **kwargs) -> Any:
252253def trace_class (
253254 include_list : list [str ] | None = None ,
254255 exclude_list : list [str ] | None = None ,
255- kind : SpanKind = SpanKind .INTERNAL ,
256+ kind : SpanKindType = SpanKind .INTERNAL ,
256257) -> Callable :
257258 """A class decorator to automatically trace specified methods of a class.
258259
0 commit comments