Skip to content
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

add async cluster redis stubs #13110

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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
10 changes: 4 additions & 6 deletions stubs/redis/redis/asyncio/cluster.pyi
Original file line number Diff line number Diff line change
@@ -1,17 +1,15 @@
from _typeshed import Incomplete
from collections.abc import Awaitable, Callable, Mapping
from types import TracebackType
from typing import Any, Generic, TypeVar
from typing import Any, TypeVar
from typing_extensions import Self

from redis.asyncio.client import ResponseCallbackT
from redis.asyncio.connection import AbstractConnection, 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.cluster import AsyncRedisClusterCommands
from redis.commands.core import _StrType
from redis.credentials import CredentialProvider
from redis.exceptions import ResponseError
Expand All @@ -27,7 +25,7 @@ class ClusterParser(BaseParser):
async def can_read_destructive(self) -> bool: ...
async def read_response(self, disable_decoding: bool = False) -> EncodableT | ResponseError | list[EncodableT] | None: ...

class RedisCluster(AbstractRedis, AbstractRedisCluster, Generic[_StrType]): # TODO: AsyncRedisClusterCommands
class RedisCluster(AbstractRedis, AbstractRedisCluster, AsyncRedisClusterCommands[_StrType]):
@classmethod
def from_url(
cls,
Expand Down Expand Up @@ -203,7 +201,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]):
def __init__(self, client: RedisCluster[_StrType]) -> None: ...
async def initialize(self) -> Self: ...
async def __aenter__(self) -> Self: ...
Expand Down
44 changes: 42 additions & 2 deletions stubs/redis/redis/commands/cluster.pyi
Original file line number Diff line number Diff line change
@@ -1,7 +1,23 @@
from _typeshed import Incomplete
from typing import NoReturn
from collections.abc import AsyncIterator
from typing import Any, NoReturn

from .core import ACLCommands, DataAccessCommands, ManagementCommands, PubSubCommands, _StrType
from redis.commands.redismodules import RedisModuleCommands

from .core import (
ACLCommands,
AsyncACLCommands,
AsyncDataAccessCommands,
AsyncFunctionCommands,
AsyncGeoCommands,
AsyncManagementCommands,
AsyncModuleCommands,
AsyncScriptCommands,
DataAccessCommands,
ManagementCommands,
PubSubCommands,
_StrType,
)

class ClusterMultiKeyCommands:
def mget_nonatomic(self, keys, *args): ...
Expand Down Expand Up @@ -30,6 +46,11 @@ class ClusterDataAccessCommands(DataAccessCommands[_StrType]):
**kwargs,
): ...

class AsyncClusterDataAccessCommands(ClusterDataAccessCommands[_StrType], AsyncDataAccessCommands[_StrType]):
async def scan_iter(
self, match: str | bytes | None = None, count: int | None = None, _type: str | None = None, **kwargs
) -> AsyncIterator[_StrType]: ...

class RedisClusterCommands(
ClusterMultiKeyCommands, ClusterManagementCommands, ACLCommands[_StrType], PubSubCommands, ClusterDataAccessCommands[_StrType]
):
Expand Down Expand Up @@ -58,3 +79,22 @@ class RedisClusterCommands(
read_from_replicas: bool
def readonly(self, target_nodes: Incomplete | None = None): ...
def readwrite(self, target_nodes: Incomplete | None = None): ...

class AsyncClusterMultiKeyCommands(ClusterMultiKeyCommands):
async def mget_nonatomic(self, keys, *args) -> list[Any]: ...
async def mset_nonatomic(self, mapping): ...

class AsyncClusterManagementCommands(ClusterManagementCommands, AsyncManagementCommands):
async def cluster_delslots(self, *slots): ...

class AsyncRedisClusterCommands(
AsyncClusterMultiKeyCommands,
AsyncClusterManagementCommands,
AsyncACLCommands[_StrType],
AsyncClusterDataAccessCommands[_StrType],
AsyncScriptCommands[_StrType],
AsyncFunctionCommands,
AsyncGeoCommands,
AsyncModuleCommands,
RedisModuleCommands,
): ...
Loading