From 0b9f6944f10c6b195d3a66d624006d085be366a2 Mon Sep 17 00:00:00 2001 From: David Froger Date: Fri, 31 Aug 2018 22:08:30 +0200 Subject: [PATCH] fix iter_chunks type hint (#3230) --- aiohttp/streams.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/aiohttp/streams.py b/aiohttp/streams.py index 6f9931c46b9..1f4e37bbeab 100644 --- a/aiohttp/streams.py +++ b/aiohttp/streams.py @@ -37,8 +37,15 @@ async def __anext__(self) -> bytes: return rv -class ChunkTupleAsyncStreamIterator(AsyncStreamIterator): - async def __anext__(self) -> bytes: +class ChunkTupleAsyncStreamIterator: + + def __init__(self, read_func: Callable[[], Awaitable[Tuple[bytes, bool]]]) -> None: + self.read_func = read_func + + def __aiter__(self) -> 'ChunkTupleAsyncStreamIterator': + return self + + async def __anext__(self) -> Tuple[bytes, bool]: rv = await self.read_func() if rv == (b'', False): raise StopAsyncIteration # NOQA