Skip to content

Commit 17cd07c

Browse files
fixing pypy errors.
1 parent a133e8d commit 17cd07c

1 file changed

Lines changed: 15 additions & 3 deletions

File tree

  • util/opentelemetry-util-genai/src/opentelemetry/util/genai

util/opentelemetry-util-genai/src/opentelemetry/util/genai/stream.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
from __future__ import annotations
1616

1717
import logging
18-
from abc import ABC, abstractmethod
18+
from abc import ABCMeta, abstractmethod
1919
from types import TracebackType
2020
from typing import (
2121
AsyncIterable,
@@ -41,6 +41,10 @@ def __init__(self, wrapped: object) -> None: ...
4141
_logger = logging.getLogger(__name__)
4242

4343

44+
class _StreamWrapperMeta(ABCMeta, type(_ObjectProxy)):
45+
"""Metaclass compatible with wrapt's proxy type and ABC hooks."""
46+
47+
4448
class _SyncStream(Iterable[_ChunkT_co], Protocol[_ChunkT_co]):
4549
"""Structural type for streams accepted by ``SyncStreamWrapper``."""
4650

@@ -53,7 +57,11 @@ class _AsyncStream(AsyncIterable[_ChunkT_co], Protocol[_ChunkT_co]):
5357
async def close(self) -> None: ...
5458

5559

56-
class SyncStreamWrapper(_ObjectProxy, ABC, Generic[ChunkT]):
60+
class SyncStreamWrapper(
61+
_ObjectProxy,
62+
Generic[ChunkT],
63+
metaclass=_StreamWrapperMeta,
64+
):
5765
"""Base class for synchronous instrumented stream wrappers.
5866
5967
Subclass this when wrapping a provider SDK stream that is consumed with
@@ -175,7 +183,11 @@ def _handle_process_chunk_error(_error: Exception) -> None:
175183
)
176184

177185

178-
class AsyncStreamWrapper(_ObjectProxy, ABC, Generic[ChunkT]):
186+
class AsyncStreamWrapper(
187+
_ObjectProxy,
188+
Generic[ChunkT],
189+
metaclass=_StreamWrapperMeta,
190+
):
179191
"""Base class for asynchronous instrumented stream wrappers.
180192
181193
Subclass this when wrapping a provider SDK stream that is consumed with

0 commit comments

Comments
 (0)