Skip to content

Commit 0da85b4

Browse files
committed
Use Union
1 parent 4ddce98 commit 0da85b4

File tree

6 files changed

+17
-17
lines changed

6 files changed

+17
-17
lines changed

util/opentelemetry-util-genai-dev/src/opentelemetry/util/genai/emitters/composite.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,10 @@ class CompositeEmitter(EmitterMeta):
3737
def __init__(
3838
self,
3939
*,
40-
span_emitters: Iterable[EmitterProtocol] | None = None,
41-
metrics_emitters: Iterable[EmitterProtocol] | None = None,
42-
content_event_emitters: Iterable[EmitterProtocol] | None = None,
43-
evaluation_emitters: Iterable[EmitterProtocol] | None = None,
40+
span_emitters: Union[Iterable[EmitterProtocol], None] = None,
41+
metrics_emitters: Union[Iterable[EmitterProtocol], None] = None,
42+
content_event_emitters: Union[Iterable[EmitterProtocol], None] = None,
43+
evaluation_emitters: Union[Iterable[EmitterProtocol], None] = None,
4444
) -> None:
4545
self._categories: dict[str, list[EmitterProtocol]] = {
4646
"span": list(span_emitters or []),
@@ -79,7 +79,7 @@ def on_evaluation_results(
7979
# Introspection helpers used during configuration refresh
8080

8181
def iter_emitters(
82-
self, categories: Sequence[str] | None = None
82+
self, categories: Union[Sequence[str], None] = None
8383
) -> Iterator[EmitterProtocol]:
8484
names = categories or (
8585
"span",
@@ -110,7 +110,7 @@ def _dispatch(
110110
*,
111111
obj: Union[Any, None] = None,
112112
error: Union[Error, None] = None,
113-
results: Sequence[EvaluationResult] | None = None,
113+
results: Union[Sequence[EvaluationResult], None] = None,
114114
) -> None:
115115
for category in categories:
116116
emitters = self._categories.get(category)

util/opentelemetry-util-genai-dev/src/opentelemetry/util/genai/emitters/spec.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
from dataclasses import dataclass, field
4-
from typing import Any, Callable, Mapping, Sequence
4+
from typing import Any, Callable, Mapping, Sequence, Union
55

66
from ..interfaces import EmitterProtocol
77

@@ -30,7 +30,7 @@ class EmitterSpec:
3030
mode: str = "append"
3131
after: Sequence[str] = field(default_factory=tuple)
3232
before: Sequence[str] = field(default_factory=tuple)
33-
invocation_types: Sequence[str] | None = None
33+
invocation_types: Union[Sequence[str], None] = None
3434

3535

3636
@dataclass(frozen=True)

util/opentelemetry-util-genai-dev/src/opentelemetry/util/genai/emitters/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@
5656

5757

5858
def filter_semconv_gen_ai_attributes(
59-
attributes: Mapping[str, Any] | None,
59+
attributes: Union[Mapping[str, Any], None],
6060
*,
6161
extras: Iterable[str] = (),
6262
) -> dict[str, Any]:

util/opentelemetry-util-genai-dev/src/opentelemetry/util/genai/evaluators/base.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@ class Evaluator(ABC):
3535

3636
def __init__(
3737
self,
38-
metrics: Iterable[str] | None = None,
38+
metrics: Union[Iterable[str], None] = None,
3939
*,
4040
invocation_type: Union[str, None] = None,
41-
options: Mapping[str, str] | None = None,
41+
options: Union[Mapping[str, str], None] = None,
4242
) -> None:
4343
default_metrics = (
4444
self.default_metrics_for(invocation_type)

util/opentelemetry-util-genai-dev/src/opentelemetry/util/genai/evaluators/registry.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ class EvaluatorRegistration:
4545
def _call_with_optional_params(
4646
target: EvaluatorFactory,
4747
*,
48-
metrics: Sequence[str] | None = None,
48+
metrics: Union[Sequence[str], None] = None,
4949
invocation_type: Union[str, None] = None,
50-
options: Mapping[str, str] | None = None,
50+
options: Union[Mapping[str, str], None] = None,
5151
) -> Evaluator:
5252
"""Call a factory/constructor handling optional ``metrics`` gracefully."""
5353

@@ -204,10 +204,10 @@ def _load_entry_points() -> None:
204204

205205
def get_evaluator(
206206
name: str,
207-
metrics: Sequence[str] | None = None,
207+
metrics: Union[Sequence[str], None] = None,
208208
*,
209209
invocation_type: Union[str, None] = None,
210-
options: Mapping[str, str] | None = None,
210+
options: Union[Mapping[str, str], None] = None,
211211
) -> Evaluator:
212212
_load_entry_points()
213213
key = name.lower()

util/opentelemetry-util-genai-dev/src/opentelemetry/util/genai/plugins.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from __future__ import annotations
22

33
import logging
4-
from typing import Iterable, Mapping, Sequence
4+
from typing import Iterable, Mapping, Sequence, Union
55

66
from opentelemetry.util._importlib_metadata import (
77
entry_points, # pyright: ignore[reportUnknownVariableType]
@@ -13,7 +13,7 @@
1313

1414

1515
def load_emitter_specs(
16-
names: Sequence[str] | None = None,
16+
names: Union[Sequence[str], None] = None,
1717
) -> list[EmitterSpec]:
1818
"""Load emitter specs declared under the ``opentelemetry_util_genai_emitters`` entry point.
1919

0 commit comments

Comments
 (0)