Skip to content

Commit

Permalink
fix iter_chunks type hint (#3230) (#3232)
Browse files Browse the repository at this point in the history
  • Loading branch information
Froger David authored and asvetlov committed Sep 1, 2018
1 parent 06438b0 commit 29e3662
Showing 1 changed file with 11 additions and 4 deletions.
15 changes: 11 additions & 4 deletions aiohttp/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,9 +37,16 @@ async def __anext__(self) -> bytes:
return rv


class ChunkTupleAsyncStreamIterator(AsyncStreamIterator):
async def __anext__(self) -> bytes:
rv = await self.read_func()
class ChunkTupleAsyncStreamIterator:

def __init__(self, stream: 'StreamReader') -> None:
self._stream = stream

def __aiter__(self) -> 'ChunkTupleAsyncStreamIterator':
return self

async def __anext__(self) -> Tuple[bytes, bool]:
rv = await self._stream.readchunk()
if rv == (b'', False):
raise StopAsyncIteration # NOQA
return rv
Expand Down Expand Up @@ -72,7 +79,7 @@ def iter_chunks(self) -> ChunkTupleAsyncStreamIterator:
Python-3.5 available for Python 3.5+ only
"""
return ChunkTupleAsyncStreamIterator(self.readchunk) # type: ignore
return ChunkTupleAsyncStreamIterator(self) # type: ignore


class StreamReader(AsyncStreamReaderMixin):
Expand Down

0 comments on commit 29e3662

Please sign in to comment.