@@ -147,7 +147,7 @@ async def group_by_temporal(
147147 aiterable: The async iterable to group.
148148 soft_max_interval: Maximum interval over which to group items, this should avoid a trickle of items causing
149149 a group to never be yielded. It's a soft max in the sense that once we're over this time, we yield items
150- as soon as `aiter.__anext__( )` returns. If `None`, no grouping/debouncing is performed
150+ as soon as `anext(aiter )` returns. If `None`, no grouping/debouncing is performed
151151
152152 Returns:
153153 A context manager usable as an async iterable of lists of items produced by the input async iterable.
@@ -171,7 +171,7 @@ async def async_iter_groups() -> AsyncIterator[list[T]]:
171171 buffer : list [T ] = []
172172 group_start_time = time .monotonic ()
173173
174- aiterator = aiterable . __aiter__ ( )
174+ aiterator = aiter ( aiterable )
175175 while True :
176176 if group_start_time is None :
177177 # group hasn't started, we just wait for the maximum interval
@@ -182,9 +182,9 @@ async def async_iter_groups() -> AsyncIterator[list[T]]:
182182
183183 # if there's no current task, we get the next one
184184 if task is None :
185- # aiter.__anext__( ) returns an Awaitable[T], not a Coroutine which asyncio.create_task expects
185+ # anext(aiter ) returns an Awaitable[T], not a Coroutine which asyncio.create_task expects
186186 # so far, this doesn't seem to be a problem
187- task = asyncio .create_task (aiterator . __anext__ ( )) # pyright: ignore[reportArgumentType]
187+ task = asyncio .create_task (anext ( aiterator )) # pyright: ignore[reportArgumentType]
188188
189189 # we use asyncio.wait to avoid cancelling the coroutine if it's not done
190190 done , _ = await asyncio .wait ((task ,), timeout = wait_time )
@@ -284,10 +284,10 @@ async def peek(self) -> T | Unset:
284284
285285 # Otherwise, we need to fetch the next item from the underlying iterator.
286286 if self ._source_iter is None :
287- self ._source_iter = self ._source . __aiter__ ( )
287+ self ._source_iter = aiter ( self ._source )
288288
289289 try :
290- self ._buffer = await self ._source_iter . __anext__ ( )
290+ self ._buffer = await anext ( self ._source_iter )
291291 except StopAsyncIteration :
292292 self ._exhausted = True
293293 return UNSET
@@ -318,10 +318,10 @@ async def __anext__(self) -> T:
318318
319319 # Otherwise, fetch the next item from the source.
320320 if self ._source_iter is None :
321- self ._source_iter = self ._source . __aiter__ ( )
321+ self ._source_iter = aiter ( self ._source )
322322
323323 try :
324- return await self ._source_iter . __anext__ ( )
324+ return await anext ( self ._source_iter )
325325 except StopAsyncIteration :
326326 self ._exhausted = True
327327 raise
0 commit comments