diff --git a/stubs/redis/redis/asyncio/cluster.pyi b/stubs/redis/redis/asyncio/cluster.pyi index 25d8f9dd143f..14e0d40ab54c 100644 --- a/stubs/redis/redis/asyncio/cluster.pyi +++ b/stubs/redis/redis/asyncio/cluster.pyi @@ -9,9 +9,7 @@ from redis.asyncio.connection import BaseParser, Connection, Encoder from redis.asyncio.parser import CommandsParser from redis.client import AbstractRedis from redis.cluster import AbstractRedisCluster, LoadBalancer - -# TODO: add AsyncRedisClusterCommands stubs -# from redis.commands import AsyncRedisClusterCommands +from redis.commands import AsyncRedisClusterCommands from redis.commands.core import _StrType from redis.credentials import CredentialProvider from redis.retry import Retry @@ -20,7 +18,7 @@ from redis.typing import AnyKeyT, EncodableT, KeyT # It uses `DefaultParser` in real life, but it is a dynamic base class. class ClusterParser(BaseParser): ... -class RedisCluster(AbstractRedis, AbstractRedisCluster, Generic[_StrType]): # TODO: AsyncRedisClusterCommands +class RedisCluster(AbstractRedis, AbstractRedisCluster, AsyncRedisClusterCommands[_StrType], Generic[_StrType]): retry: Retry | None connection_kwargs: dict[str, Any] nodes_manager: NodesManager @@ -152,7 +150,7 @@ class NodesManager: async def close(self, attr: str = "nodes_cache") -> None: ... def remap_host_port(self, host: str, port: int) -> tuple[str, int]: ... -class ClusterPipeline(AbstractRedis, AbstractRedisCluster, Generic[_StrType]): # TODO: AsyncRedisClusterCommands +class ClusterPipeline(AbstractRedis, AbstractRedisCluster, AsyncRedisClusterCommands[_StrType], Generic[_StrType]): def __init__(self, client: RedisCluster[_StrType]) -> None: ... async def initialize(self) -> Self: ... async def __aenter__(self) -> Self: ... diff --git a/stubs/redis/redis/commands/__init__.pyi b/stubs/redis/redis/commands/__init__.pyi index 4959ea0fdf15..eb9c75b6ccba 100644 --- a/stubs/redis/redis/commands/__init__.pyi +++ b/stubs/redis/redis/commands/__init__.pyi @@ -1,4 +1,4 @@ -from .cluster import RedisClusterCommands as RedisClusterCommands +from .cluster import AsyncRedisClusterCommands as AsyncRedisClusterCommands, RedisClusterCommands as RedisClusterCommands from .core import AsyncCoreCommands as AsyncCoreCommands, CoreCommands as CoreCommands from .helpers import list_or_args as list_or_args from .parser import CommandsParser as CommandsParser @@ -14,4 +14,5 @@ __all__ = [ "RedisModuleCommands", "AsyncSentinelCommands", "SentinelCommands", + "AsyncRedisClusterCommands", ] diff --git a/stubs/redis/redis/commands/cluster.pyi b/stubs/redis/redis/commands/cluster.pyi index ffcd4e1e41ab..a489442fbf8d 100644 --- a/stubs/redis/redis/commands/cluster.pyi +++ b/stubs/redis/redis/commands/cluster.pyi @@ -1,7 +1,18 @@ from _typeshed import Incomplete from typing import NoReturn -from .core import ACLCommands, DataAccessCommands, ManagementCommands, PubSubCommands, _StrType +from .core import ( + ACLCommands, + AsyncACLCommands, + AsyncDataAccessCommands, + AsyncFunctionCommands, + AsyncManagementCommands, + AsyncScriptCommands, + DataAccessCommands, + ManagementCommands, + PubSubCommands, + _StrType, +) class ClusterMultiKeyCommands: def mget_nonatomic(self, keys, *args): ... @@ -11,11 +22,15 @@ class ClusterMultiKeyCommands: def touch(self, *keys): ... def unlink(self, *keys): ... +class AsyncClusterMultiKeyCommands(ClusterMultiKeyCommands): ... + class ClusterManagementCommands(ManagementCommands): def slaveof(self, *args, **kwargs) -> None: ... def replicaof(self, *args, **kwargs) -> None: ... def swapdb(self, *args, **kwargs) -> None: ... +class AsyncClusterManagementCommands(ClusterManagementCommands, AsyncManagementCommands): ... + class ClusterDataAccessCommands(DataAccessCommands[_StrType]): def stralgo( self, @@ -30,6 +45,8 @@ class ClusterDataAccessCommands(DataAccessCommands[_StrType]): **kwargs, ): ... +class AsyncClusterDataAccessCommands(ClusterDataAccessCommands[_StrType], AsyncDataAccessCommands[_StrType]): ... + class RedisClusterCommands( ClusterMultiKeyCommands, ClusterManagementCommands, ACLCommands[_StrType], PubSubCommands, ClusterDataAccessCommands[_StrType] ): @@ -56,5 +73,14 @@ class RedisClusterCommands( def cluster_flushslots(self, target_nodes: Incomplete | None = None) -> NoReturn: ... def cluster_bumpepoch(self, target_nodes: Incomplete | None = None) -> NoReturn: ... read_from_replicas: bool - def readonly(self, target_nodes: Incomplete | None = None): ... - def readwrite(self, target_nodes: Incomplete | None = None): ... + def readonly(self, target_nodes: Incomplete | None = ...): ... + def readwrite(self, target_nodes: Incomplete | None = ...): ... + +class AsyncRedisClusterCommands( + AsyncClusterMultiKeyCommands, + AsyncClusterManagementCommands, + AsyncACLCommands[_StrType], + AsyncClusterDataAccessCommands[_StrType], + AsyncScriptCommands[_StrType], + AsyncFunctionCommands, +): ...