Skip to content

[redis] Stubs for AsyncRedisClusterCommands #9837

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 3 additions & 5 deletions stubs/redis/redis/asyncio/cluster.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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: ...
Expand Down
3 changes: 2 additions & 1 deletion stubs/redis/redis/commands/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -14,4 +14,5 @@ __all__ = [
"RedisModuleCommands",
"AsyncSentinelCommands",
"SentinelCommands",
"AsyncRedisClusterCommands",
]
32 changes: 29 additions & 3 deletions stubs/redis/redis/commands/cluster.pyi
Original file line number Diff line number Diff line change
@@ -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): ...
Expand All @@ -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,
Expand All @@ -30,6 +45,8 @@ class ClusterDataAccessCommands(DataAccessCommands[_StrType]):
**kwargs,
): ...

class AsyncClusterDataAccessCommands(ClusterDataAccessCommands[_StrType], AsyncDataAccessCommands[_StrType]): ...

class RedisClusterCommands(
ClusterMultiKeyCommands, ClusterManagementCommands, ACLCommands[_StrType], PubSubCommands, ClusterDataAccessCommands[_StrType]
):
Expand All @@ -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,
): ...