Skip to content

Commit 9f510ad

Browse files
committed
happy mypy
1 parent 8756e11 commit 9f510ad

File tree

2 files changed

+5
-9
lines changed

2 files changed

+5
-9
lines changed

langfuse/_client/constants.py

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
This module defines constants used throughout the Langfuse OpenTelemetry integration.
44
"""
55

6-
from typing import Literal, List, get_args, Union
6+
from typing import Literal, List, get_args, Union, Any
77
from typing_extensions import TypeAlias
88

99
LANGFUSE_TRACER_NAME = "langfuse-sdk"
@@ -39,16 +39,12 @@
3939

4040

4141
def get_observation_types_list(
42-
literal_type: Union[
43-
ObservationTypeGenerationLike,
44-
ObservationTypeLiteralNoEvent,
45-
ObservationTypeLiteral,
46-
],
42+
literal_type: Any,
4743
) -> List[str]:
4844
"""Flattens the Literal type to provide a list of strings.
4945
5046
Args:
51-
literal_type: A Literal type or union of Literals to flatten
47+
literal_type: A Literal type, TypeAlias, or union of Literals to flatten
5248
5349
Returns:
5450
Flat list of all string values contained in the Literal type

langfuse/_client/observe.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
Union,
1717
cast,
1818
overload,
19-
get_args,
2019
)
2120

2221
from opentelemetry.util._decorator import _AgnosticContextManager
@@ -28,6 +27,7 @@
2827

2928
from langfuse._client.constants import (
3029
ObservationTypeLiteralNoEvent,
30+
get_observation_types_list,
3131
)
3232
from langfuse._client.get_client import _set_current_public_key, get_client
3333
from langfuse._client.span import (
@@ -169,7 +169,7 @@ def sub_process():
169169
- For async functions, the decorator returns an async function wrapper.
170170
- For sync functions, the decorator returns a synchronous wrapper.
171171
"""
172-
valid_types = set(get_args(ObservationTypeLiteralNoEvent))
172+
valid_types = set(get_observation_types_list(ObservationTypeLiteralNoEvent))
173173
if as_type is not None and as_type not in valid_types:
174174
self._log.warning(
175175
f"Invalid as_type '{as_type}'. Valid types are: {', '.join(sorted(valid_types))}. Defaulting to 'span'."

0 commit comments

Comments
 (0)