From 25810e1b115673062199c6179c5a765357a780e7 Mon Sep 17 00:00:00 2001 From: Peter Schutt Date: Sat, 22 Oct 2022 02:44:51 +1000 Subject: [PATCH] Fixes redis.asyncio.client: `AsyncIterator` cannot be `async def` in stubs. (#8961) Without the `yield` statement in the method body, these are interpreted by mypy as coroutines that return an `AsyncIterator`. Closes #8960 --- stubs/redis/redis/asyncio/client.pyi | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/stubs/redis/redis/asyncio/client.pyi b/stubs/redis/redis/asyncio/client.pyi index a841469d2..3aa9d0bd6 100644 --- a/stubs/redis/redis/asyncio/client.pyi +++ b/stubs/redis/redis/asyncio/client.pyi @@ -116,7 +116,7 @@ class Monitor: async def __aenter__(self): ... async def __aexit__(self, *args) -> None: ... async def next_command(self) -> MonitorCommandInfo: ... - async def listen(self) -> AsyncIterator[MonitorCommandInfo]: ... + def listen(self) -> AsyncIterator[MonitorCommandInfo]: ... class PubSub: PUBLISH_MESSAGE_TYPES: ClassVar[tuple[str, ...]] @@ -154,7 +154,7 @@ class PubSub: def punsubscribe(self, *args: ChannelT) -> Awaitable[Any]: ... async def subscribe(self, *args: ChannelT, **kwargs: Callable[..., Any]): ... def unsubscribe(self, *args) -> Awaitable[Any]: ... - async def listen(self) -> AsyncIterator[Any]: ... + def listen(self) -> AsyncIterator[Any]: ... async def get_message(self, ignore_subscribe_messages: bool = ..., timeout: float = ...): ... def ping(self, message: Any | None = ...) -> Awaitable[Any]: ... async def handle_message(self, response, ignore_subscribe_messages: bool = ...): ...