diff --git a/asyncstdlib/__init__.py b/asyncstdlib/__init__.py index b9b4e9b..a4a1e89 100644 --- a/asyncstdlib/__init__.py +++ b/asyncstdlib/__init__.py @@ -45,7 +45,7 @@ from .asynctools import borrow, scoped_iter, await_each, any_iter, apply, sync from .heapq import merge, nlargest, nsmallest -__version__ = "3.12.4" +__version__ = "3.12.5" __all__ = [ "anext", diff --git a/asyncstdlib/_lrucache.py b/asyncstdlib/_lrucache.py index 58b20b3..15e2455 100644 --- a/asyncstdlib/_lrucache.py +++ b/asyncstdlib/_lrucache.py @@ -28,7 +28,9 @@ from ._utility import public_module -@public_module("asyncstdlib.functools") +@public_module( + "asyncstdlib.functools" +) # pyright: ignore[reportArgumentType,reportUntypedClassDecorator] class CacheInfo(NamedTuple): """ Metadata on the current state of a cache diff --git a/asyncstdlib/functools.py b/asyncstdlib/functools.py index 3362ae8..d1f9355 100644 --- a/asyncstdlib/functools.py +++ b/asyncstdlib/functools.py @@ -233,7 +233,7 @@ async def data(self): If the attribute is accessed by multiple tasks before a cached value has been produced, the getter can be run more than once. The final cached value is determined by the last getter coroutine to return. To enforce that the - getter is executed at most once, provide a ``lock`` type - e.g. the + getter is executed at most once, provide an appropriate lock type - e.g. the :py:class:`asyncio.Lock` class in an :py:mod:`asyncio` application - and access is automatically synchronised. diff --git a/asyncstdlib/itertools.py b/asyncstdlib/itertools.py index f00c196..cd737ba 100644 --- a/asyncstdlib/itertools.py +++ b/asyncstdlib/itertools.py @@ -577,7 +577,7 @@ async def maybe_step(self) -> None: await self.step() def consume_value(self) -> T_co: - """Return the current value, after removing it from the current state""" + """Return the current value after removing it from the current state""" value, self._current_value = self._current_value, self._sentinel return value @@ -600,21 +600,21 @@ def __init__(self, target_key: R, state: "_GroupByState[R, T_co]") -> None: async def __anext__(self) -> T_co: state = self._state + # the groupby already advanced to another group if state.current_group is not self: raise StopAsyncIteration - await state.maybe_step() + # the step advanced the iterator to another group if self._target_key != state.current_key: raise StopAsyncIteration - return state.consume_value() async def aclose(self) -> None: - """Close the group iterator + """ + Close the group iterator Note: this does _not_ close the underlying groupby managed iterator; closing a single group shouldn't affect other groups in the series. - """ state = self._state if state.current_group is not self: @@ -662,8 +662,7 @@ def __init__( async def __anext__(self) -> Tuple[R, AsyncIterator[T_co]]: state = self._state - # disable the last group to avoid concurrency - # issues. + # already disable the current group to avoid concurrency issues state.current_group = None await state.maybe_step() try: diff --git a/docs/source/api/functools.rst b/docs/source/api/functools.rst index 68aab0b..131ddfb 100644 --- a/docs/source/api/functools.rst +++ b/docs/source/api/functools.rst @@ -35,17 +35,17 @@ Attribute Caches This type of cache tracks ``await``\ ing an attribute. -.. py:function:: cached_property(getter: (Self) → await T, /) +.. py:function:: cached_property(getter: (Self) → await T, /) -> await T :decorator: -.. autofunction:: cached_property(asynccontextmanager_type: Type[AsyncContextManager], /)((Self) → await T) +.. autofunction:: cached_property(context_type: Type[AsyncContextManager], /)((Self) → await T) -> await T :decorator: :noindex: .. versionadded:: 1.1.0 - .. versionadded:: 3.13.0 + .. versionadded:: 3.12.5 - The ``asynccontextmanager_type`` decorator parameter. + The ``context_type`` decorator parameter. Callable Caches