1515from __future__ import annotations
1616
1717import logging
18- from abc import ABC , abstractmethod
18+ from abc import ABCMeta , abstractmethod
1919from types import TracebackType
2020from 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+
4448class _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