@@ -577,7 +577,7 @@ async def maybe_step(self) -> None:
577577 await self .step ()
578578
579579 def consume_value (self ) -> T_co :
580- """Return the current value, after removing it from the current state"""
580+ """Return the current value after removing it from the current state"""
581581 value , self ._current_value = self ._current_value , self ._sentinel
582582 return value
583583
@@ -600,21 +600,21 @@ def __init__(self, target_key: R, state: "_GroupByState[R, T_co]") -> None:
600600
601601 async def __anext__ (self ) -> T_co :
602602 state = self ._state
603+ # the groupby already advanced to another group
603604 if state .current_group is not self :
604605 raise StopAsyncIteration
605-
606606 await state .maybe_step ()
607+ # the step advanced the iterator to another group
607608 if self ._target_key != state .current_key :
608609 raise StopAsyncIteration
609-
610610 return state .consume_value ()
611611
612612 async def aclose (self ) -> None :
613- """Close the group iterator
613+ """
614+ Close the group iterator
614615
615616 Note: this does _not_ close the underlying groupby managed iterator;
616617 closing a single group shouldn't affect other groups in the series.
617-
618618 """
619619 state = self ._state
620620 if state .current_group is not self :
@@ -662,8 +662,7 @@ def __init__(
662662
663663 async def __anext__ (self ) -> Tuple [R , AsyncIterator [T_co ]]:
664664 state = self ._state
665- # disable the last group to avoid concurrency
666- # issues.
665+ # already disable the current group to avoid concurrency issues
667666 state .current_group = None
668667 await state .maybe_step ()
669668 try :
0 commit comments