1- from typing import Union , Any , Iterator , AsyncIterator
1+ from typing import Union , Any
22from json import dumps
33
44import httpcore
55
66
7- class ByteStream (httpcore .AsyncByteStream , httpcore .SyncByteStream ):
8- def __init__ (self , data : bytes ):
9- httpcore .AsyncByteStream .__init__ (self )
10- httpcore .SyncByteStream .__init__ (self )
11- self .data = data
12-
13- def __iter__ (self ) -> Iterator [bytes ]:
14- yield self .data
15-
16- async def __aiter__ (self ) -> AsyncIterator [bytes ]:
17- yield self .data
18-
19-
20- class IteratorStream (httpcore .AsyncByteStream , httpcore .SyncByteStream ):
7+ class IteratorStream (httpcore .AsyncIteratorByteStream , httpcore .IteratorByteStream ):
218 def __init__ (self , iterator ):
22- httpcore .AsyncByteStream .__init__ (self , aiterator = iterator )
23- httpcore .SyncByteStream .__init__ (self , iterator = iterator )
9+ httpcore .AsyncIteratorByteStream .__init__ (self , aiterator = iterator )
10+ httpcore .IteratorByteStream .__init__ (self , iterator = iterator )
2411
2512
2613def stream (
@@ -41,6 +28,6 @@ def stream(
4128 data = b""
4229
4330 if isinstance (data , bytes ):
44- return ByteStream (data )
31+ return httpcore . PlainByteStream (data )
4532
4633 return IteratorStream (data )
0 commit comments