diff --git a/stubs/redis/@tests/stubtest_allowlist.txt b/stubs/redis/@tests/stubtest_allowlist.txt index 14e9a2059..380970ad8 100644 --- a/stubs/redis/@tests/stubtest_allowlist.txt +++ b/stubs/redis/@tests/stubtest_allowlist.txt @@ -1 +1,2 @@ redis.client.Pipeline.transaction # instance attribute has same name as superclass method +redis.ocsp # requires cryptography to be installed diff --git a/stubs/redis/METADATA.toml b/stubs/redis/METADATA.toml index 0ca63cc11..bb8cc449b 100644 --- a/stubs/redis/METADATA.toml +++ b/stubs/redis/METADATA.toml @@ -1,2 +1 @@ -version = "4.0.*" -requires = [] +version = "4.1.*" diff --git a/stubs/redis/redis/__init__.pyi b/stubs/redis/redis/__init__.pyi index 6d3cdcc9a..184e7dadf 100644 --- a/stubs/redis/redis/__init__.pyi +++ b/stubs/redis/redis/__init__.pyi @@ -1,5 +1,34 @@ from . import client, connection, exceptions, sentinel, utils +__all__ = [ + "AuthenticationError", + "AuthenticationWrongNumberOfArgsError", + "BlockingConnectionPool", + "BusyLoadingError", + "ChildDeadlockedError", + "Connection", + "ConnectionError", + "ConnectionPool", + "DataError", + "from_url", + "InvalidResponse", + "PubSubError", + "ReadOnlyError", + "Redis", + "RedisCluster", + "RedisError", + "ResponseError", + "Sentinel", + "SentinelConnectionPool", + "SentinelManagedConnection", + "SentinelManagedSSLConnection", + "SSLConnection", + "StrictRedis", + "TimeoutError", + "UnixDomainSocketConnection", + "WatchError", +] + Redis = client.Redis BlockingConnectionPool = connection.BlockingConnectionPool diff --git a/stubs/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index 05cdaaec3..187a24d99 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -1,4 +1,3 @@ -import builtins import threading from _typeshed import Self, SupportsItems from datetime import datetime, timedelta @@ -36,6 +35,10 @@ _StrType = TypeVar("_StrType", bound=Union[str, bytes]) _VT = TypeVar("_VT") _T = TypeVar("_T") +SYM_EMPTY: bytes +EMPTY_RESPONSE: str +NEVER_DECODE: str + class CaseInsensitiveDict(Dict[_StrType, _VT]): def __init__(self, data: SupportsItems[_StrType, _VT]) -> None: ... def update(self, data: SupportsItems[_StrType, _VT]) -> None: ... # type: ignore[override] @@ -45,15 +48,15 @@ class CaseInsensitiveDict(Dict[_StrType, _VT]): def get(self, k: _StrType, default: _VT | _T) -> _VT | _T: ... # Overrides many other methods too, but without changing signature -SYM_EMPTY: Any -SENTINEL_STATE_TYPES: Any - def list_or_args(keys, args): ... def timestamp_to_datetime(response): ... def string_keys_to_dict(key_string, callback): ... def parse_debug_object(response): ... def parse_object(response, infotype): ... def parse_info(response): ... + +SENTINEL_STATE_TYPES: dict[str, type[int]] + def parse_sentinel_state(item): ... def parse_sentinel_master(response): ... def parse_sentinel_masters(response): ... @@ -166,18 +169,23 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener errors: str | None, decode_responses: Literal[True], retry_on_timeout: bool = ..., + retry_on_error=..., ssl: bool = ..., ssl_keyfile: str | None = ..., ssl_certfile: str | None = ..., ssl_cert_reqs: str | int | None = ..., ssl_ca_certs: str | None = ..., + ssl_ca_path: Any | None = ..., ssl_check_hostname: bool = ..., + ssl_password: Any | None = ..., + ssl_validate_ocsp: bool = ..., max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., client_name: str | None = ..., username: str | None = ..., retry: Retry | None = ..., + redis_connect_func: Any | None = ..., ) -> None: ... @overload def __init__( @@ -211,6 +219,7 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener client_name: str | None = ..., username: str | None = ..., retry: Retry | None = ..., + redis_connect_func: Any | None = ..., ) -> None: ... @overload def __init__( @@ -243,7 +252,10 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener client_name: str | None = ..., username: str | None = ..., retry: Retry | None = ..., + redis_connect_func: Any | None = ..., ) -> None: ... + def get_encoder(self): ... + def get_connection_kwargs(self): ... def set_response_callback(self, command, callback): ... def pipeline(self, transaction: bool = ..., shard_hint: Any = ...) -> Pipeline[_StrType]: ... def transaction(self, func, *watches, **kwargs): ... @@ -281,179 +293,7 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener def pubsub(self, *, shard_hint: Any = ..., ignore_subscribe_messages: bool = ...) -> PubSub: ... def execute_command(self, *args, **options): ... def parse_response(self, connection, command_name, **options): ... - # TODO: Most of the following methods must be moved to the command classes. - def readwrite(self) -> bool: ... - def readonly(self) -> bool: ... - def config_get(self, pattern=...): ... - def config_set(self, name, value): ... - def config_resetstat(self): ... - def config_rewrite(self): ... - def dbsize(self) -> int: ... - def debug_object(self, key): ... - def echo(self, value: _Value) -> bytes: ... - def info(self, section: _Key | None = ...) -> Mapping[str, Any]: ... - def lastsave(self): ... - def object(self, infotype, key): ... - def ping(self) -> bool: ... - def save(self) -> bool: ... - def shutdown(self, save: bool = ..., nosave: bool = ...) -> None: ... - def slaveof(self, host=..., port=...): ... - def slowlog_get(self, num=...): ... - def slowlog_len(self): ... - def slowlog_reset(self): ... - def time(self): ... - def decr(self, name, amount=...) -> int: ... - def decrby(self, name, amount=...) -> int: ... - def delete(self, *names: _Key) -> int: ... - def __delitem__(self, _Key): ... - def dump(self, name): ... - def exists(self, *names: _Key) -> int: ... - __contains__: Any - def expire(self, name: _Key, time: int | timedelta) -> bool: ... - def expireat(self, name, when): ... - def get(self, name: _Key) -> _StrType | None: ... - def __getitem__(self, name): ... - def getbit(self, name: _Key, offset: int) -> int: ... - def getrange(self, key, start, end): ... - def getset(self, name, value) -> _StrType | None: ... - def incr(self, name: _Key, amount: int = ...) -> int: ... - def incrby(self, name: _Key, amount: int = ...) -> int: ... - def incrbyfloat(self, name: _Key, amount: float = ...) -> float: ... - def keys(self, pattern: _Key = ...) -> list[_StrType]: ... - def mget(self, keys: _Key | Iterable[_Key], *args: _Key) -> list[_StrType | None]: ... - def mset(self, mapping: Mapping[_Key, _Value]) -> Literal[True]: ... - def msetnx(self, mapping: Mapping[_Key, _Value]) -> bool: ... - def move(self, name: _Key, db: int) -> bool: ... - def persist(self, name: _Key) -> bool: ... - def pexpire(self, name: _Key, time: int | timedelta) -> Literal[1, 0]: ... - def pexpireat(self, name: _Key, when: int | datetime) -> Literal[1, 0]: ... - def psetex(self, name, time_ms, value): ... - def pttl(self, name): ... - def __setitem__(self, name, value): ... - def setbit(self, name: _Key, offset: int, value: int) -> int: ... - def setex(self, name: _Key, time: int | timedelta, value: _Value) -> bool: ... - def setnx(self, name: _Key, value: _Value) -> bool: ... - def setrange(self, name, offset, value): ... - def strlen(self, name): ... - def substr(self, name, start, end=...): ... - def ttl(self, name: _Key) -> int: ... - def type(self, name): ... - def watch(self, *names): ... - def unlink(self, *names: _Key) -> int: ... - def unwatch(self): ... - @overload - def blpop(self, keys: _Value | Iterable[_Value], timeout: Literal[0] = ...) -> tuple[_StrType, _StrType]: ... - @overload - def blpop(self, keys: _Value | Iterable[_Value], timeout: float) -> tuple[_StrType, _StrType] | None: ... - @overload - def brpop(self, keys: _Value | Iterable[_Value], timeout: Literal[0] = ...) -> tuple[_StrType, _StrType]: ... - @overload - def brpop(self, keys: _Value | Iterable[_Value], timeout: float) -> tuple[_StrType, _StrType] | None: ... - def brpoplpush(self, src, dst, timeout=...): ... - @overload - def sort( - self, - name: _Key, - start: int | None = ..., - num: int | None = ..., - by: _Key | None = ..., - get: _Key | Sequence[_Key] | None = ..., - desc: bool = ..., - alpha: bool = ..., - store: None = ..., - groups: bool = ..., - ) -> list[_StrType]: ... - @overload - def sort( - self, - name: _Key, - start: int | None = ..., - num: int | None = ..., - by: _Key | None = ..., - get: _Key | Sequence[_Key] | None = ..., - desc: bool = ..., - alpha: bool = ..., - *, - store: _Key, - groups: bool = ..., - ) -> int: ... - @overload - def sort( - self, - name: _Key, - start: int | None, - num: int | None, - by: _Key | None, - get: _Key | Sequence[_Key] | None, - desc: bool, - alpha: bool, - store: _Key, - groups: bool = ..., - ) -> int: ... - def scan( - self, cursor: int = ..., match: _Key | None = ..., count: int | None = ..., _type: str | None = ... - ) -> tuple[int, list[_StrType]]: ... - def scan_iter(self, match: str | None = ..., count: int | None = ..., _type: str | None = ...) -> Iterator[_StrType]: ... - def sscan( - self, name: _Key, cursor: int = ..., match: str | None = ..., count: int | None = ... - ) -> tuple[int, list[_StrType]]: ... - def sscan_iter(self, name: _Key, match: str | None = ..., count: int | None = ...): ... - def hscan( - self, name: _Key, cursor: int = ..., match: str | None = ..., count: int | None = ... - ) -> tuple[int, dict[_StrType, _StrType]]: ... - def hscan_iter(self, name: _Key, match: str | None = ..., count: int | None = ...): ... - def zscan(self, name, cursor=..., match=..., count=..., score_cast_func=...): ... - def zscan_iter(self, name, match=..., count=..., score_cast_func=...): ... - def sadd(self, name: _Key, *values: _Value) -> int: ... - def scard(self, name: _Key) -> int: ... - def sdiff(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ... - def sdiffstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ... - def sinter(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ... - def sinterstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ... - def sismember(self, name: _Key, value: _Value) -> bool: ... - def smembers(self, name: _Key) -> builtins.set[_StrType]: ... - def smove(self, src: _Key, dst: _Key, value: _Value) -> bool: ... - @overload - def spop(self, name: _Key, count: None = ...) -> _Value | None: ... - @overload - def spop(self, name: _Key, count: int) -> list[_Value]: ... - @overload - def srandmember(self, name: _Key, number: None = ...) -> _Value | None: ... - @overload - def srandmember(self, name: _Key, number: int) -> list[_Value]: ... - def srem(self, name: _Key, *values: _Value) -> int: ... - def sunion(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ... - def sunionstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ... - def pfadd(self, name: _Key, *values: _Value) -> int: ... - def pfcount(self, name: _Key) -> int: ... - def pfmerge(self, dest: _Key, *sources: _Key) -> bool: ... - def hdel(self, name: _Key, *keys: _Key) -> int: ... - def hexists(self, name: _Key, key: _Key) -> bool: ... - def hget(self, name: _Key, key: _Key) -> _StrType | None: ... - def hgetall(self, name: _Key) -> dict[_StrType, _StrType]: ... - def hincrby(self, name: _Key, key: _Key, amount: int = ...) -> int: ... - def hincrbyfloat(self, name: _Key, key: _Key, amount: float = ...) -> float: ... - def hkeys(self, name: _Key) -> list[_StrType]: ... - def hlen(self, name: _Key) -> int: ... - @overload - def hset(self, name: _Key, key: _Key, value: _Value, mapping: Mapping[_Key, _Value] | None = ...) -> int: ... - @overload - def hset(self, name: _Key, key: None, value: None, mapping: Mapping[_Key, _Value]) -> int: ... - @overload - def hset(self, name: _Key, *, mapping: Mapping[_Key, _Value]) -> int: ... - def hsetnx(self, name: _Key, key: _Key, value: _Value) -> int: ... - def hmset(self, name: _Key, mapping: Mapping[_Key, _Value]) -> bool: ... - def hmget(self, name: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> list[_StrType | None]: ... - def hvals(self, name: _Key) -> list[_StrType]: ... - def publish(self, channel: _Key, message: _Key) -> int: ... - def eval(self, script, numkeys, *keys_and_args): ... - def evalsha(self, sha, numkeys, *keys_and_args): ... - def pubsub_channels(self, pattern: _Key = ...) -> list[str]: ... - def pubsub_numsub(self, *args: _Key) -> list[tuple[str, int]]: ... - def pubsub_numpat(self) -> int: ... def monitor(self) -> Monitor: ... - def memory_stats(self) -> dict[str, Any]: ... - def memory_purge(self) -> bool: ... def cluster(self, cluster_arg: str, *args: Any) -> Any: ... def __enter__(self) -> Redis[_StrType]: ... def __exit__(self, exc_type, exc_value, traceback): ... @@ -471,9 +311,13 @@ class PubSub: shard_hint: Any ignore_subscribe_messages: Any connection: Any + subscribed_event: threading.Event encoder: Any - health_check_response: Any - def __init__(self, connection_pool, shard_hint=..., ignore_subscribe_messages: bool = ...) -> None: ... + health_check_response_b: bytes + health_check_response: list[str] | list[bytes] + def __init__( + self, connection_pool, shard_hint: Any | None = ..., ignore_subscribe_messages: bool = ..., encoder: Any | None = ... + ) -> None: ... def __enter__(self: Self) -> Self: ... def __exit__(self, exc_type: object, exc_value: object, traceback: object) -> None: ... def __del__(self): ... @@ -485,7 +329,10 @@ class PubSub: @property def subscribed(self): ... def execute_command(self, *args): ... + def clean_health_check_responses(self) -> None: ... def parse_response(self, block: bool = ..., timeout: float = ...): ... + def is_health_check_response(self, response) -> bool: ... + def check_health(self) -> None: ... def psubscribe(self, *args: _Key, **kwargs: Callable[[Any], None]): ... def punsubscribe(self, *args: _Key) -> None: ... def subscribe(self, *args: _Key, **kwargs: Callable[[Any], None]) -> None: ... @@ -698,7 +545,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): groups: bool = ..., ) -> Pipeline[_StrType]: ... def scan(self, cursor: int = ..., match: _Key | None = ..., count: int | None = ..., _type: str | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override] - def scan_iter(self, match: str | None = ..., count: int | None = ..., _type: str | None = ...) -> Iterator[Any]: ... + def scan_iter(self, match: str | None = ..., count: int | None = ..., _type: str | None = ...) -> Iterator[Any]: ... # type: ignore[override] def sscan(self, name: _Key, cursor: int = ..., match: str | None = ..., count: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override] def sscan_iter(self, name: _Key, match: str | None = ..., count: int | None = ...) -> Iterator[Any]: ... def hscan(self, name: _Key, cursor: int = ..., match: str | None = ..., count: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override] @@ -836,7 +683,6 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def script_flush(self, sync_type: Any | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override] def script_kill(self) -> Pipeline[_StrType]: ... # type: ignore[override] def script_load(self, script) -> Pipeline[_StrType]: ... # type: ignore[override] - def register_script(self, script: str | _StrType) -> Script: ... # type: ignore[override] def pubsub_channels(self, pattern: _Key = ...) -> Pipeline[_StrType]: ... # type: ignore[override] def pubsub_numsub(self, *args: _Key) -> Pipeline[_StrType]: ... # type: ignore[override] def pubsub_numpat(self) -> Pipeline[_StrType]: ... # type: ignore[override] @@ -844,13 +690,6 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def cluster(self, cluster_arg: str, *args: Any) -> Pipeline[_StrType]: ... # type: ignore[override] def client(self) -> Any: ... -class Script: - registered_client: Any - script: Any - sha: Any - def __init__(self, registered_client, script) -> None: ... - def __call__(self, keys=..., args=..., client=...): ... - class Monitor(object): command_re: Pattern[str] monitor_re: Pattern[str] diff --git a/stubs/redis/redis/cluster.pyi b/stubs/redis/redis/cluster.pyi new file mode 100644 index 000000000..74241e7a0 --- /dev/null +++ b/stubs/redis/redis/cluster.pyi @@ -0,0 +1,218 @@ +from typing import Any, ClassVar, Generic + +from redis.client import PubSub +from redis.commands import RedisClusterCommands +from redis.commands.core import _StrType +from redis.connection import DefaultParser +from redis.exceptions import RedisError + +def get_node_name(host, port): ... +def get_connection(redis_node, *args, **options): ... +def parse_scan_result(command, res, **options): ... +def parse_pubsub_numsub(command, res, **options): ... +def parse_cluster_slots(resp, **options): ... + +PRIMARY: str +REPLICA: str +SLOT_ID: str +REDIS_ALLOWED_KEYS: Any +KWARGS_DISABLED_KEYS: Any +READ_COMMANDS: Any + +def cleanup_kwargs(**kwargs): ... + +class ClusterParser(DefaultParser): + EXCEPTION_CLASSES: Any + +class RedisCluster(RedisClusterCommands[_StrType], Generic[_StrType]): + RedisClusterRequestTTL: ClassVar[int] + PRIMARIES: ClassVar[str] + REPLICAS: ClassVar[str] + ALL_NODES: ClassVar[str] + RANDOM: ClassVar[str] + DEFAULT_NODE: ClassVar[str] + NODE_FLAGS: ClassVar[set[str]] + COMMAND_FLAGS: ClassVar[Any] + CLUSTER_COMMANDS_RESPONSE_CALLBACKS: ClassVar[dict[str, Any]] + RESULT_CALLBACKS: ClassVar[Any] + ERRORS_ALLOW_RETRY: ClassVar[tuple[type[RedisError], ...]] + user_on_connect_func: Any + encoder: Any + cluster_error_retry_attempts: Any + command_flags: Any + node_flags: Any + read_from_replicas: Any + reinitialize_counter: int + reinitialize_steps: Any + nodes_manager: Any + cluster_response_callbacks: Any + result_callbacks: Any + commands_parser: Any + def __init__( + self, + host: Any | None = ..., + port: int = ..., + startup_nodes: Any | None = ..., + cluster_error_retry_attempts: int = ..., + require_full_coverage: bool = ..., + skip_full_coverage_check: bool = ..., + reinitialize_steps: int = ..., + read_from_replicas: bool = ..., + url: Any | None = ..., + **kwargs, + ) -> None: ... + def __enter__(self): ... + def __exit__(self, exc_type, exc_value, traceback) -> None: ... + def __del__(self) -> None: ... + def disconnect_connection_pools(self) -> None: ... + @classmethod + def from_url(cls, url, **kwargs): ... + def on_connect(self, connection) -> None: ... + def get_redis_connection(self, node): ... + def get_node(self, host: Any | None = ..., port: Any | None = ..., node_name: Any | None = ...): ... + def get_primaries(self): ... + def get_replicas(self): ... + def get_random_node(self): ... + def get_nodes(self): ... + def get_node_from_key(self, key, replica: bool = ...): ... + def get_default_node(self): ... + def set_default_node(self, node): ... + def monitor(self, target_node: Any | None = ...): ... + def pubsub(self, node: Any | None = ..., host: Any | None = ..., port: Any | None = ..., **kwargs): ... + def pipeline(self, transaction: Any | None = ..., shard_hint: Any | None = ...): ... + def keyslot(self, key): ... + def determine_slot(self, *args): ... + def reinitialize_caches(self) -> None: ... + def get_encoder(self): ... + def get_connection_kwargs(self): ... + def execute_command(self, *args, **kwargs): ... + def close(self) -> None: ... + +class ClusterNode: + host: Any + port: Any + name: Any + server_type: Any + redis_connection: Any + def __init__(self, host, port, server_type: Any | None = ..., redis_connection: Any | None = ...) -> None: ... + def __eq__(self, obj): ... + def __del__(self) -> None: ... + +class LoadBalancer: + primary_to_idx: Any + start_index: Any + def __init__(self, start_index: int = ...) -> None: ... + def get_server_index(self, primary, list_size): ... + def reset(self) -> None: ... + +class NodesManager: + nodes_cache: Any + slots_cache: Any + startup_nodes: Any + default_node: Any + from_url: Any + connection_kwargs: Any + read_load_balancer: Any + def __init__( + self, + startup_nodes, + from_url: bool = ..., + require_full_coverage: bool = ..., + skip_full_coverage_check: bool = ..., + lock: Any | None = ..., + **kwargs, + ) -> None: ... + def get_node(self, host: Any | None = ..., port: Any | None = ..., node_name: Any | None = ...): ... + def update_moved_exception(self, exception) -> None: ... + def get_node_from_slot(self, slot, read_from_replicas: bool = ..., server_type: Any | None = ...): ... + def get_nodes_by_server_type(self, server_type): ... + def populate_startup_nodes(self, nodes) -> None: ... + def cluster_require_full_coverage(self, cluster_nodes): ... + def check_slots_coverage(self, slots_cache): ... + def create_redis_connections(self, nodes) -> None: ... + def create_redis_node(self, host, port, **kwargs): ... + def initialize(self) -> None: ... + def close(self) -> None: ... + def reset(self) -> None: ... + +class ClusterPubSub(PubSub): + node: Any + cluster: Any + def __init__( + self, redis_cluster, node: Any | None = ..., host: Any | None = ..., port: Any | None = ..., **kwargs + ) -> None: ... + def set_pubsub_node(self, cluster, node: Any | None = ..., host: Any | None = ..., port: Any | None = ...) -> None: ... + def get_pubsub_node(self): ... + def execute_command(self, *args, **kwargs) -> None: ... + def get_redis_connection(self): ... + +class ClusterPipeline(RedisCluster[_StrType], Generic[_StrType]): + command_stack: Any + nodes_manager: Any + refresh_table_asap: bool + result_callbacks: Any + startup_nodes: Any + read_from_replicas: Any + command_flags: Any + cluster_response_callbacks: Any + cluster_error_retry_attempts: Any + reinitialize_counter: int + reinitialize_steps: Any + encoder: Any + commands_parser: Any + def __init__( + self, + nodes_manager, + result_callbacks: Any | None = ..., + cluster_response_callbacks: Any | None = ..., + startup_nodes: Any | None = ..., + read_from_replicas: bool = ..., + cluster_error_retry_attempts: int = ..., + reinitialize_steps: int = ..., + **kwargs, + ) -> None: ... + def __enter__(self): ... + def __exit__(self, exc_type, exc_value, traceback) -> None: ... + def __del__(self) -> None: ... + def __len__(self): ... + def __nonzero__(self): ... + def __bool__(self): ... + def execute_command(self, *args, **kwargs): ... + def pipeline_execute_command(self, *args, **options): ... + def raise_first_error(self, stack) -> None: ... + def annotate_exception(self, exception, number, command) -> None: ... + def execute(self, raise_on_error: bool = ...): ... + scripts: Any + watching: bool + explicit_transaction: bool + def reset(self) -> None: ... + def send_cluster_commands(self, stack, raise_on_error: bool = ..., allow_redirections: bool = ...): ... + def eval(self) -> None: ... + def multi(self) -> None: ... + def immediate_execute_command(self, *args, **options) -> None: ... + def load_scripts(self) -> None: ... + def watch(self, *names) -> None: ... + def unwatch(self) -> None: ... + def script_load_for_pipeline(self, *args, **kwargs) -> None: ... + def delete(self, *names): ... + +def block_pipeline_command(func): ... + +class PipelineCommand: + args: Any + options: Any + position: Any + result: Any + node: Any + asking: bool + def __init__(self, args, options: Any | None = ..., position: Any | None = ...) -> None: ... + +class NodeCommands: + parse_response: Any + connection_pool: Any + connection: Any + commands: Any + def __init__(self, parse_response, connection_pool, connection) -> None: ... + def append(self, c) -> None: ... + def write(self) -> None: ... + def read(self) -> None: ... diff --git a/stubs/redis/redis/commands/__init__.pyi b/stubs/redis/redis/commands/__init__.pyi index 3debade74..5ab5e2219 100644 --- a/stubs/redis/redis/commands/__init__.pyi +++ b/stubs/redis/redis/commands/__init__.pyi @@ -1,6 +1,8 @@ +from .cluster import RedisClusterCommands as RedisClusterCommands from .core import CoreCommands as CoreCommands from .helpers import list_or_args as list_or_args +from .parser import CommandsParser as CommandsParser from .redismodules import RedisModuleCommands as RedisModuleCommands from .sentinel import SentinelCommands as SentinelCommands -__all__ = ["CoreCommands", "RedisModuleCommands", "SentinelCommands", "list_or_args"] +__all__ = ["RedisClusterCommands", "CommandsParser", "CoreCommands", "list_or_args", "RedisModuleCommands", "SentinelCommands"] diff --git a/stubs/redis/redis/commands/bf/__init__.pyi b/stubs/redis/redis/commands/bf/__init__.pyi new file mode 100644 index 000000000..ba1eb8dd8 --- /dev/null +++ b/stubs/redis/redis/commands/bf/__init__.pyi @@ -0,0 +1,58 @@ +from typing import Any + +from .commands import * +from .info import BFInfo as BFInfo, CFInfo as CFInfo, CMSInfo as CMSInfo, TDigestInfo as TDigestInfo, TopKInfo as TopKInfo + +class AbstractBloom: + @staticmethod + def appendItems(params, items) -> None: ... + @staticmethod + def appendError(params, error) -> None: ... + @staticmethod + def appendCapacity(params, capacity) -> None: ... + @staticmethod + def appendExpansion(params, expansion) -> None: ... + @staticmethod + def appendNoScale(params, noScale) -> None: ... + @staticmethod + def appendWeights(params, weights) -> None: ... + @staticmethod + def appendNoCreate(params, noCreate) -> None: ... + @staticmethod + def appendItemsAndIncrements(params, items, increments) -> None: ... + @staticmethod + def appendValuesAndWeights(params, items, weights) -> None: ... + @staticmethod + def appendMaxIterations(params, max_iterations) -> None: ... + @staticmethod + def appendBucketSize(params, bucket_size) -> None: ... + +class CMSBloom(CMSCommands, AbstractBloom): + client: Any + commandmixin: Any + execute_command: Any + def __init__(self, client, **kwargs) -> None: ... + +class TOPKBloom(TOPKCommands, AbstractBloom): + client: Any + commandmixin: Any + execute_command: Any + def __init__(self, client, **kwargs) -> None: ... + +class CFBloom(CFCommands, AbstractBloom): + client: Any + commandmixin: Any + execute_command: Any + def __init__(self, client, **kwargs) -> None: ... + +class TDigestBloom(TDigestCommands, AbstractBloom): + client: Any + commandmixin: Any + execute_command: Any + def __init__(self, client, **kwargs) -> None: ... + +class BFBloom(BFCommands, AbstractBloom): + client: Any + commandmixin: Any + execute_command: Any + def __init__(self, client, **kwargs) -> None: ... diff --git a/stubs/redis/redis/commands/bf/commands.pyi b/stubs/redis/redis/commands/bf/commands.pyi new file mode 100644 index 000000000..5036d1108 --- /dev/null +++ b/stubs/redis/redis/commands/bf/commands.pyi @@ -0,0 +1,107 @@ +from typing import Any + +BF_RESERVE: str +BF_ADD: str +BF_MADD: str +BF_INSERT: str +BF_EXISTS: str +BF_MEXISTS: str +BF_SCANDUMP: str +BF_LOADCHUNK: str +BF_INFO: str +CF_RESERVE: str +CF_ADD: str +CF_ADDNX: str +CF_INSERT: str +CF_INSERTNX: str +CF_EXISTS: str +CF_DEL: str +CF_COUNT: str +CF_SCANDUMP: str +CF_LOADCHUNK: str +CF_INFO: str +CMS_INITBYDIM: str +CMS_INITBYPROB: str +CMS_INCRBY: str +CMS_QUERY: str +CMS_MERGE: str +CMS_INFO: str +TOPK_RESERVE: str +TOPK_ADD: str +TOPK_INCRBY: str +TOPK_QUERY: str +TOPK_COUNT: str +TOPK_LIST: str +TOPK_INFO: str +TDIGEST_CREATE: str +TDIGEST_RESET: str +TDIGEST_ADD: str +TDIGEST_MERGE: str +TDIGEST_CDF: str +TDIGEST_QUANTILE: str +TDIGEST_MIN: str +TDIGEST_MAX: str +TDIGEST_INFO: str + +class BFCommands: + def create(self, key, errorRate, capacity, expansion: Any | None = ..., noScale: Any | None = ...): ... + def add(self, key, item): ... + def madd(self, key, *items): ... + def insert( + self, + key, + items, + capacity: Any | None = ..., + error: Any | None = ..., + noCreate: Any | None = ..., + expansion: Any | None = ..., + noScale: Any | None = ..., + ): ... + def exists(self, key, item): ... + def mexists(self, key, *items): ... + def scandump(self, key, iter): ... + def loadchunk(self, key, iter, data): ... + def info(self, key): ... + +class CFCommands: + def create( + self, key, capacity, expansion: Any | None = ..., bucket_size: Any | None = ..., max_iterations: Any | None = ... + ): ... + def add(self, key, item): ... + def addnx(self, key, item): ... + def insert(self, key, items, capacity: Any | None = ..., nocreate: Any | None = ...): ... + def insertnx(self, key, items, capacity: Any | None = ..., nocreate: Any | None = ...): ... + def exists(self, key, item): ... + def delete(self, key, item): ... + def count(self, key, item): ... + def scandump(self, key, iter): ... + def loadchunk(self, key, iter, data): ... + def info(self, key): ... + +class TOPKCommands: + def reserve(self, key, k, width, depth, decay): ... + def add(self, key, *items): ... + def incrby(self, key, items, increments): ... + def query(self, key, *items): ... + def count(self, key, *items): ... + def list(self, key, withcount: bool = ...): ... + def info(self, key): ... + +class TDigestCommands: + def create(self, key, compression): ... + def reset(self, key): ... + def add(self, key, values, weights): ... + def merge(self, toKey, fromKey): ... + def min(self, key): ... + def max(self, key): ... + def quantile(self, key, quantile): ... + def cdf(self, key, value): ... + def info(self, key): ... + +class CMSCommands: + def initbydim(self, key, width, depth): ... + def initbyprob(self, key, error, probability): ... + def incrby(self, key, items, increments): ... + def query(self, key, *items): ... + def merge(self, destKey, numKeys, srcKeys, weights=...): ... + def info(self, key): ... diff --git a/stubs/redis/redis/commands/bf/info.pyi b/stubs/redis/redis/commands/bf/info.pyi new file mode 100644 index 000000000..54d1cf044 --- /dev/null +++ b/stubs/redis/redis/commands/bf/info.pyi @@ -0,0 +1,43 @@ +from typing import Any + +class BFInfo: + capacity: Any + size: Any + filterNum: Any + insertedNum: Any + expansionRate: Any + def __init__(self, args) -> None: ... + +class CFInfo: + size: Any + bucketNum: Any + filterNum: Any + insertedNum: Any + deletedNum: Any + bucketSize: Any + expansionRate: Any + maxIteration: Any + def __init__(self, args) -> None: ... + +class CMSInfo: + width: Any + depth: Any + count: Any + def __init__(self, args) -> None: ... + +class TopKInfo: + k: Any + width: Any + depth: Any + decay: Any + def __init__(self, args) -> None: ... + +class TDigestInfo: + compression: Any + capacity: Any + mergedNodes: Any + unmergedNodes: Any + mergedWeight: Any + unmergedWeight: Any + totalCompressions: Any + def __init__(self, args) -> None: ... diff --git a/stubs/redis/redis/commands/cluster.pyi b/stubs/redis/redis/commands/cluster.pyi new file mode 100644 index 000000000..66324ed8a --- /dev/null +++ b/stubs/redis/redis/commands/cluster.pyi @@ -0,0 +1,60 @@ +from typing import Any, Generic + +from .core import ACLCommands, DataAccessCommands, ManagementCommands, PubSubCommands, _StrType + +class ClusterMultiKeyCommands: + def mget_nonatomic(self, keys, *args): ... + def mset_nonatomic(self, mapping): ... + def exists(self, *keys): ... + def delete(self, *keys): ... + def touch(self, *keys): ... + def unlink(self, *keys): ... + +class ClusterManagementCommands(ManagementCommands): + def slaveof(self, *args, **kwargs) -> None: ... + def replicaof(self, *args, **kwargs) -> None: ... + def swapdb(self, *args, **kwargs) -> None: ... + +class ClusterDataAccessCommands(DataAccessCommands[_StrType], Generic[_StrType]): + def stralgo( + self, + algo, + value1, + value2, + specific_argument: str = ..., + len: bool = ..., + idx: bool = ..., + minmatchlen: Any | None = ..., + withmatchlen: bool = ..., + **kwargs, + ): ... + +class RedisClusterCommands( + ClusterMultiKeyCommands, + ClusterManagementCommands, + ACLCommands[_StrType], + PubSubCommands, + ClusterDataAccessCommands[_StrType], + Generic[_StrType], +): + def cluster_addslots(self, target_node, *slots): ... + def cluster_countkeysinslot(self, slot_id): ... + def cluster_count_failure_report(self, node_id): ... + def cluster_delslots(self, *slots): ... + def cluster_failover(self, target_node, option: Any | None = ...): ... + def cluster_info(self, target_nodes: Any | None = ...): ... + def cluster_keyslot(self, key): ... + def cluster_meet(self, host, port, target_nodes: Any | None = ...): ... + def cluster_nodes(self): ... + def cluster_replicate(self, target_nodes, node_id): ... + def cluster_reset(self, soft: bool = ..., target_nodes: Any | None = ...): ... + def cluster_save_config(self, target_nodes: Any | None = ...): ... + def cluster_get_keys_in_slot(self, slot, num_keys): ... + def cluster_set_config_epoch(self, epoch, target_nodes: Any | None = ...): ... + def cluster_setslot(self, target_node, node_id, slot_id, state): ... + def cluster_setslot_stable(self, slot_id): ... + def cluster_replicas(self, node_id, target_nodes: Any | None = ...): ... + def cluster_slots(self, target_nodes: Any | None = ...): ... + read_from_replicas: bool + def readonly(self, target_nodes: Any | None = ...): ... + def readwrite(self, target_nodes: Any | None = ...): ... diff --git a/stubs/redis/redis/commands/core.pyi b/stubs/redis/redis/commands/core.pyi index cd279a09c..4a4080250 100644 --- a/stubs/redis/redis/commands/core.pyi +++ b/stubs/redis/redis/commands/core.pyi @@ -1,5 +1,6 @@ -from collections.abc import Callable, Iterable, Mapping, Sequence -from datetime import timedelta +import builtins +from collections.abc import Callable, Iterable, Iterator, Mapping, Sequence +from datetime import datetime, timedelta from typing import Any, Generic, TypeVar, Union, overload from typing_extensions import Literal @@ -8,13 +9,17 @@ from ..client import _Key, _Value _ScoreCastFuncReturn = TypeVar("_ScoreCastFuncReturn") _StrType = TypeVar("_StrType", bound=Union[str, bytes]) -class CoreCommands(Generic[_StrType]): - def acl_cat(self, category: str | None = ...) -> list[str]: ... - def acl_deluser(self, username: str) -> int: ... - def acl_genpass(self, bits: int | None = ...) -> str: ... - def acl_getuser(self, username: str) -> Any | None: ... - def acl_list(self) -> list[str]: ... - def acl_load(self) -> bool: ... +class ACLCommands(Generic[_StrType]): + def acl_cat(self, category: str | None = ..., **kwargs) -> list[str]: ... + def acl_deluser(self, *username: str, **kwargs) -> int: ... + def acl_genpass(self, bits: int | None = ..., **kwargs) -> str: ... + def acl_getuser(self, username: str, **kwargs) -> Any | None: ... + def acl_help(self, **kwargs): ... + def acl_list(self, **kwargs) -> list[str]: ... + def acl_log(self, count: int | None = ..., **kwargs): ... + def acl_log_reset(self, **kwargs): ... + def acl_load(self, **kwargs) -> bool: ... + def acl_save(self, **kwargs): ... def acl_setuser( self, username: str, @@ -28,27 +33,132 @@ class CoreCommands(Generic[_StrType]): reset: bool = ..., reset_keys: bool = ..., reset_passwords: bool = ..., + **kwargs, ) -> bool: ... - def acl_users(self) -> list[str]: ... - def acl_whoami(self) -> str: ... + def acl_users(self, **kwargs) -> list[str]: ... + def acl_whoami(self, **kwargs) -> str: ... + +class ManagementCommands: + def bgrewriteaof(self, **kwargs): ... + def bgsave(self, schedule: bool = ..., **kwargs): ... + def role(self): ... + def client_kill(self, address: str, **kwargs) -> bool: ... + def client_kill_filter( + self, + _id: Any | None = ..., + _type: Any | None = ..., + addr: Any | None = ..., + skipme: Any | None = ..., + laddr: Any | None = ..., + user: Any | None = ..., + **kwargs, + ): ... + def client_info(self, **kwargs): ... + def client_list(self, _type: str | None = ..., client_id: list[str] = ..., **kwargs) -> list[dict[str, str]]: ... + def client_getname(self, **kwargs) -> str | None: ... + def client_getredir(self, **kwargs): ... + def client_reply(self, reply, **kwargs): ... + def client_id(self, **kwargs) -> int: ... + def client_tracking_on( + self, clientid: Any | None = ..., prefix=..., bcast: bool = ..., optin: bool = ..., optout: bool = ..., noloop: bool = ... + ): ... + def client_tracking_off( + self, clientid: Any | None = ..., prefix=..., bcast: bool = ..., optin: bool = ..., optout: bool = ..., noloop: bool = ... + ): ... + def client_tracking( + self, + on: bool = ..., + clientid: Any | None = ..., + prefix=..., + bcast: bool = ..., + optin: bool = ..., + optout: bool = ..., + noloop: bool = ..., + **kwargs, + ): ... + def client_trackinginfo(self, **kwargs): ... + def client_setname(self, name: str, **kwargs) -> bool: ... + def client_unblock(self, client_id, error: bool = ..., **kwargs): ... + def client_pause(self, timeout, all: bool = ..., **kwargs): ... + def client_unpause(self, **kwargs): ... + def command(self, **kwargs): ... + def command_info(self, **kwargs): ... + def command_count(self, **kwargs): ... + def config_get(self, pattern: str = ..., **kwargs): ... + def config_set(self, name, value, **kwargs): ... + def config_resetstat(self, **kwargs): ... + def config_rewrite(self, **kwargs): ... + def dbsize(self, **kwargs) -> int: ... + def debug_object(self, key, **kwargs): ... + def debug_segfault(self, **kwargs): ... + def echo(self, value: _Value, **kwargs) -> bytes: ... + def flushall(self, asynchronous: bool = ..., **kwargs) -> bool: ... + def flushdb(self, asynchronous: bool = ..., **kwargs) -> bool: ... + def sync(self): ... + def psync(self, replicationid, offset): ... + def swapdb(self, first, second, **kwargs): ... + def select(self, index, **kwargs): ... + def info(self, section: _Key | None = ..., **kwargs) -> Mapping[str, Any]: ... + def lastsave(self, **kwargs): ... + def lolwut(self, *version_numbers, **kwargs): ... + def reset(self) -> None: ... + def migrate( + self, host, port, keys, destination_db, timeout, copy: bool = ..., replace: bool = ..., auth: Any | None = ..., **kwargs + ): ... + def object(self, infotype, key, **kwargs): ... + def memory_doctor(self, **kwargs): ... + def memory_help(self, **kwargs): ... + def memory_stats(self, **kwargs) -> dict[str, Any]: ... + def memory_malloc_stats(self, **kwargs): ... + def memory_usage(self, key, samples: Any | None = ..., **kwargs): ... + def memory_purge(self, **kwargs): ... + def ping(self, **kwargs): ... + def quit(self, **kwargs): ... + def replicaof(self, *args, **kwargs): ... + def save(self, **kwargs): ... + def shutdown(self, save: bool = ..., nosave: bool = ..., **kwargs) -> None: ... + def slaveof(self, host: Any | None = ..., port: Any | None = ..., **kwargs): ... + def slowlog_get(self, num: Any | None = ..., **kwargs): ... + def slowlog_len(self, **kwargs): ... + def slowlog_reset(self, **kwargs): ... + def time(self, **kwargs): ... + def wait(self, num_replicas, timeout, **kwargs): ... + +class BasicKeyCommands(Generic[_StrType]): def append(self, key, value): ... def bitcount(self, key: _Key, start: int | None = ..., end: int | None = ...) -> int: ... + def bitfield(self, key, default_overflow: Any | None = ...): ... def bitop(self, operation, dest, *keys): ... def bitpos(self, key, bit, start=..., end=...): ... - def bgrewriteaof(self): ... - def bgsave(self, schedule: bool = ...): ... - def client_id(self) -> int: ... - def client_kill(self, address: str) -> bool: ... - def client_list(self, _type: str | None = ..., client_id: list[str] = ...) -> list[dict[str, str]]: ... - def client_getname(self) -> str | None: ... - def client_setname(self, name: str) -> bool: ... - def flushall(self, asynchronous: bool = ...) -> bool: ... - def flushdb(self, asynchronous: bool = ...) -> bool: ... - def lindex(self, name: _Key, index: int) -> _StrType | None: ... - def linsert( - self, name: _Key, where: Literal["BEFORE", "AFTER", "before", "after"], refvalue: _Value, value: _Value - ) -> int: ... - def llen(self, name: _Key) -> int: ... + def copy(self, source, destination, destination_db: Any | None = ..., replace: bool = ...): ... + def decr(self, name, amount: int = ...) -> int: ... + def decrby(self, name, amount: int = ...) -> int: ... + def delete(self, *names: _Key) -> int: ... + def __delitem__(self, name: _Key) -> None: ... + def dump(self, name): ... + def exists(self, *names: _Key) -> int: ... + __contains__ = exists + def expire(self, name: _Key, time: int | timedelta) -> bool: ... + def expireat(self, name, when): ... + def get(self, name: _Key) -> _StrType | None: ... + def getdel(self, name): ... + def getex( + self, + name, + ex: Any | None = ..., + px: Any | None = ..., + exat: Any | None = ..., + pxat: Any | None = ..., + persist: bool = ..., + ): ... + def __getitem__(self, name: str): ... + def getbit(self, name: _Key, offset: int) -> int: ... + def getrange(self, key, start, end): ... + def getset(self, name, value) -> _StrType | None: ... + def incr(self, name: _Key, amount: int = ...) -> int: ... + def incrby(self, name: _Key, amount: int = ...) -> int: ... + def incrbyfloat(self, name: _Key, amount: float = ...) -> float: ... + def keys(self, pattern: _Key = ..., **kwargs) -> list[_StrType]: ... def lmove( self, first_list: _Key, second_list: _Key, src: Literal["LEFT", "RIGHT"] = ..., dest: Literal["LEFT", "RIGHT"] = ... ) -> _Value: ... @@ -60,23 +170,22 @@ class CoreCommands(Generic[_StrType]): src: Literal["LEFT", "RIGHT"] = ..., dest: Literal["LEFT", "RIGHT"] = ..., ) -> _Value | None: ... - def lpop(self, name, count: int | None = ...): ... - def lpush(self, name: _Value, *values: _Value) -> int: ... - def lpushx(self, name, value): ... - def lrange(self, name: _Key, start: int, end: int) -> list[_StrType]: ... - def lrem(self, name: _Key, count: int, value: _Value) -> int: ... - def lset(self, name: _Key, index: int, value: _Value) -> bool: ... - def ltrim(self, name: _Key, start: int, end: int) -> bool: ... - def randomkey(self): ... + def mget(self, keys: _Key | Iterable[_Key], *args: _Key) -> list[_StrType | None]: ... + def mset(self, mapping: Mapping[_Key, _Value]) -> Literal[True]: ... + def msetnx(self, mapping: Mapping[_Key, _Value]) -> bool: ... + def move(self, name: _Key, db: int) -> bool: ... + def persist(self, name: _Key) -> bool: ... + def pexpire(self, name: _Key, time: int | timedelta) -> Literal[1, 0]: ... + def pexpireat(self, name: _Key, when: int | datetime) -> Literal[1, 0]: ... + def psetex(self, name, time_ms, value): ... + def pttl(self, name): ... + def hrandfield(self, key, count: Any | None = ..., withvalues: bool = ...): ... + def randomkey(self, **kwargs): ... def rename(self, src, dst): ... def renamenx(self, src, dst): ... def restore( self, name, ttl, value, replace: bool = ..., absttl: bool = ..., idletime: Any | None = ..., frequency: Any | None = ... ): ... - def rpop(self, name, count: int | None = ...): ... - def rpoplpush(self, src, dst): ... - def rpush(self, name: _Value, *values: _Value) -> int: ... - def rpushx(self, name, value): ... def set( self, name: _Key, @@ -90,6 +199,142 @@ class CoreCommands(Generic[_StrType]): exat: Any | None = ..., pxat: Any | None = ..., ) -> bool | None: ... + def __setitem__(self, name, value) -> None: ... + def setbit(self, name: _Key, offset: int, value: int) -> int: ... + def setex(self, name: _Key, time: int | timedelta, value: _Value) -> bool: ... + def setnx(self, name: _Key, value: _Value) -> bool: ... + def setrange(self, name, offset, value): ... + def stralgo( + self, + algo, + value1, + value2, + specific_argument: str = ..., + len: bool = ..., + idx: bool = ..., + minmatchlen: Any | None = ..., + withmatchlen: bool = ..., + **kwargs, + ): ... + def strlen(self, name): ... + def substr(self, name, start, end: int = ...): ... + def touch(self, *args): ... + def ttl(self, name: _Key) -> int: ... + def type(self, name): ... + def watch(self, *names): ... + def unwatch(self): ... + def unlink(self, *names: _Key) -> int: ... + +class ListCommands(Generic[_StrType]): + @overload + def blpop(self, keys: _Value | Iterable[_Value], timeout: Literal[0] | None = ...) -> tuple[_StrType, _StrType]: ... + @overload + def blpop(self, keys: _Value | Iterable[_Value], timeout: float) -> tuple[_StrType, _StrType] | None: ... + @overload + def brpop(self, keys: _Value | Iterable[_Value], timeout: Literal[0] | None = ...) -> tuple[_StrType, _StrType]: ... + @overload + def brpop(self, keys: _Value | Iterable[_Value], timeout: float) -> tuple[_StrType, _StrType] | None: ... + def brpoplpush(self, src, dst, timeout: int | None = ...): ... + def lindex(self, name: _Key, index: int) -> _StrType | None: ... + def linsert( + self, name: _Key, where: Literal["BEFORE", "AFTER", "before", "after"], refvalue: _Value, value: _Value + ) -> int: ... + def llen(self, name: _Key) -> int: ... + def lpop(self, name, count: int | None = ...): ... + def lpush(self, name: _Value, *values: _Value) -> int: ... + def lpushx(self, name, value): ... + def lrange(self, name: _Key, start: int, end: int) -> list[_StrType]: ... + def lrem(self, name: _Key, count: int, value: _Value) -> int: ... + def lset(self, name: _Key, index: int, value: _Value) -> bool: ... + def ltrim(self, name: _Key, start: int, end: int) -> bool: ... + def rpop(self, name, count: int | None = ...): ... + def rpoplpush(self, src, dst): ... + def rpush(self, name: _Value, *values: _Value) -> int: ... + def rpushx(self, name, value): ... + def lpos(self, name, value, rank: Any | None = ..., count: Any | None = ..., maxlen: Any | None = ...): ... + @overload + def sort( + self, + name: _Key, + start: int | None = ..., + num: int | None = ..., + by: _Key | None = ..., + get: _Key | Sequence[_Key] | None = ..., + desc: bool = ..., + alpha: bool = ..., + store: None = ..., + groups: bool = ..., + ) -> list[_StrType]: ... + @overload + def sort( + self, + name: _Key, + start: int | None = ..., + num: int | None = ..., + by: _Key | None = ..., + get: _Key | Sequence[_Key] | None = ..., + desc: bool = ..., + alpha: bool = ..., + *, + store: _Key, + groups: bool = ..., + ) -> int: ... + @overload + def sort( + self, + name: _Key, + start: int | None, + num: int | None, + by: _Key | None, + get: _Key | Sequence[_Key] | None, + desc: bool, + alpha: bool, + store: _Key, + groups: bool = ..., + ) -> int: ... + +class ScanCommands(Generic[_StrType]): + def scan( + self, cursor: int = ..., match: _Key | None = ..., count: int | None = ..., _type: str | None = ..., **kwargs + ) -> tuple[int, list[_StrType]]: ... + def scan_iter( + self, match: str | None = ..., count: int | None = ..., _type: str | None = ..., **kwargs + ) -> Iterator[_StrType]: ... + def sscan( + self, name: _Key, cursor: int = ..., match: str | None = ..., count: int | None = ... + ) -> tuple[int, list[_StrType]]: ... + def sscan_iter(self, name: _Key, match: str | None = ..., count: int | None = ...): ... + def hscan( + self, name: _Key, cursor: int = ..., match: str | None = ..., count: int | None = ... + ) -> tuple[int, dict[_StrType, _StrType]]: ... + def hscan_iter(self, name: _Key, match: str | None = ..., count: int | None = ...): ... + def zscan(self, name, cursor: int = ..., match: Any | None = ..., count: Any | None = ..., score_cast_func=...): ... + def zscan_iter(self, name, match: Any | None = ..., count: Any | None = ..., score_cast_func=...): ... + +class SetCommands(Generic[_StrType]): + def sadd(self, name: _Key, *values: _Value) -> int: ... + def scard(self, name: _Key) -> int: ... + def sdiff(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ... + def sdiffstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ... + def sinter(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ... + def sinterstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ... + def sismember(self, name: _Key, value: _Value) -> bool: ... + def smembers(self, name: _Key) -> builtins.set[_StrType]: ... + def smismember(self, name, values, *args): ... + def smove(self, src: _Key, dst: _Key, value: _Value) -> bool: ... + @overload + def spop(self, name: _Key, count: None = ...) -> _Value | None: ... + @overload + def spop(self, name: _Key, count: int) -> list[_Value]: ... + @overload + def srandmember(self, name: _Key, number: None = ...) -> _Value | None: ... + @overload + def srandmember(self, name: _Key, number: int) -> list[_Value]: ... + def srem(self, name: _Key, *values: _Value) -> int: ... + def sunion(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ... + def sunionstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ... + +class StreamCommands: def xack(self, name, groupname, *ids): ... def xadd( self, @@ -102,13 +347,17 @@ class CoreCommands(Generic[_StrType]): minid: Any | None = ..., limit: Any | None = ..., ): ... + def xautoclaim( + self, name, groupname, consumername, min_idle_time, start_id: int = ..., count: Any | None = ..., justid: bool = ... + ): ... def xclaim( self, name, groupname, consumername, min_idle_time, message_ids, idle=..., time=..., retrycount=..., force=..., justid=... ): ... def xdel(self, name, *ids): ... - def xgroup_create(self, name, groupname, id=..., mkstream=...): ... + def xgroup_create(self, name, groupname, id: str = ..., mkstream: bool = ...): ... def xgroup_delconsumer(self, name, groupname, consumername): ... def xgroup_destroy(self, name, groupname): ... + def xgroup_createconsumer(self, name, groupname, consumername): ... def xgroup_setid(self, name, groupname, id): ... def xinfo_consumers(self, name, groupname): ... def xinfo_groups(self, name): ... @@ -125,13 +374,17 @@ class CoreCommands(Generic[_StrType]): count: int | None = ..., consumername: Any | None = ..., ): ... - def xrange(self, name, min=..., max=..., count=...): ... - def xread(self, streams, count=..., block=...): ... - def xreadgroup(self, groupname, consumername, streams, count=..., block=..., noack=...): ... - def xrevrange(self, name, max=..., min=..., count=...): ... + def xrange(self, name, min: str = ..., max: str = ..., count: Any | None = ...): ... + def xread(self, streams, count: Any | None = ..., block: Any | None = ...): ... + def xreadgroup( + self, groupname, consumername, streams, count: Any | None = ..., block: Any | None = ..., noack: bool = ... + ): ... + def xrevrange(self, name, max: str = ..., min: str = ..., count: Any | None = ...): ... def xtrim( self, name, maxlen: Any | None = ..., approximate: bool = ..., minid: Any | None = ..., limit: Any | None = ... ): ... + +class SortedSetCommands(Generic[_StrType]): def zadd( self, name: _Key, @@ -145,11 +398,15 @@ class CoreCommands(Generic[_StrType]): ) -> int: ... def zcard(self, name: _Key) -> int: ... def zcount(self, name: _Key, min: _Value, max: _Value) -> int: ... + def zdiff(self, keys, withscores: bool = ...): ... + def zdiffstore(self, dest, keys): ... def zincrby(self, name: _Key, amount: float, value: _Value) -> float: ... + def zinter(self, keys, aggregate: Any | None = ..., withscores: bool = ...): ... def zinterstore(self, dest: _Key, keys: Iterable[_Key], aggregate: Literal["SUM", "MIN", "MAX"] | None = ...) -> int: ... def zlexcount(self, name: _Key, min: _Value, max: _Value) -> int: ... def zpopmax(self, name: _Key, count: int | None = ...) -> list[tuple[_StrType, float]]: ... def zpopmin(self, name: _Key, count: int | None = ...) -> list[tuple[_StrType, float]]: ... + def zrandmember(self, key, count: Any | None = ..., withscores: bool = ...): ... @overload def bzpopmax(self, keys: _Key | Iterable[_Key], timeout: Literal[0] = ...) -> tuple[_StrType, _StrType, float]: ... @overload @@ -159,6 +416,20 @@ class CoreCommands(Generic[_StrType]): @overload def bzpopmin(self, keys: _Key | Iterable[_Key], timeout: float) -> tuple[_StrType, _StrType, float] | None: ... @overload + def zrange( + self, + name: _Key, + start: int, + end: int, + desc: bool, + withscores: Literal[True], + score_cast_func: Callable[[float], _ScoreCastFuncReturn] = ..., + byscore: bool = ..., + bylex: bool = ..., + offset: int | None = ..., + num: int | None = ..., + ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... + @overload def zrange( self, name: _Key, @@ -187,9 +458,37 @@ class CoreCommands(Generic[_StrType]): offset: int | None = ..., num: int | None = ..., ) -> list[_StrType]: ... + @overload + def zrevrange( + self, + name: _Key, + start: int, + end: int, + withscores: Literal[True], + score_cast_func: Callable[[float], _ScoreCastFuncReturn] = ..., + ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... + @overload + def zrevrange( + self, name: _Key, start: int, end: int, withscores: bool = ..., score_cast_func: Callable[[Any], Any] = ... + ) -> list[_StrType]: ... + def zrangestore( + self, + dest, + name, + start, + end, + byscore: bool = ..., + bylex: bool = ..., + desc: bool = ..., + offset: Any | None = ..., + num: Any | None = ..., + ): ... def zrangebylex( self, name: _Key, min: _Value, max: _Value, start: int | None = ..., num: int | None = ... ) -> list[_StrType]: ... + def zrevrangebylex( + self, name: _Key, max: _Value, min: _Value, start: int | None = ..., num: int | None = ... + ) -> list[_StrType]: ... @overload def zrangebyscore( self, @@ -213,60 +512,161 @@ class CoreCommands(Generic[_StrType]): withscores: bool = ..., score_cast_func: Callable[[Any], Any] = ..., ) -> list[_StrType]: ... + @overload + def zrevrangebyscore( + self, + name: _Key, + max: _Value, + min: _Value, + start: int | None = ..., + num: int | None = ..., + *, + withscores: Literal[True], + score_cast_func: Callable[[float], _ScoreCastFuncReturn] = ..., + ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... + @overload + def zrevrangebyscore( + self, + name: _Key, + max: _Value, + min: _Value, + start: int | None = ..., + num: int | None = ..., + withscores: bool = ..., + score_cast_func: Callable[[Any], Any] = ..., + ) -> list[_StrType]: ... def zrank(self, name: _Key, value: _Value) -> int | None: ... def zrem(self, name: _Key, *values: _Value) -> int: ... def zremrangebylex(self, name: _Key, min: _Value, max: _Value) -> int: ... def zremrangebyrank(self, name: _Key, min: int, max: int) -> int: ... def zremrangebyscore(self, name: _Key, min: _Value, max: _Value) -> int: ... - @overload - def zrevrange( - self, - name: _Key, - start: int, - end: int, - *, - withscores: Literal[True], - score_cast_func: Callable[[float], _ScoreCastFuncReturn] = ..., - ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... - @overload - def zrevrange( - self, name: _Key, start: int, end: int, withscores: bool = ..., score_cast_func: Callable[[Any], Any] = ... - ) -> list[_StrType]: ... - @overload - def zrevrangebyscore( - self, - name: _Key, - max: _Value, - min: _Value, - start: int | None = ..., - num: int | None = ..., - *, - withscores: Literal[True], - score_cast_func: Callable[[float], _ScoreCastFuncReturn] = ..., - ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... - @overload - def zrevrangebyscore( - self, - name: _Key, - max: _Value, - min: _Value, - start: int | None = ..., - num: int | None = ..., - withscores: bool = ..., - score_cast_func: Callable[[Any], Any] = ..., - ) -> list[_StrType]: ... - def zrevrangebylex( - self, name: _Key, max: _Value, min: _Value, start: int | None = ..., num: int | None = ... - ) -> list[_StrType]: ... def zrevrank(self, name: _Key, value: _Value) -> int | None: ... def zscore(self, name: _Key, value: _Value) -> float | None: ... + def zunion(self, keys, aggregate: Any | None = ..., withscores: bool = ...): ... def zunionstore(self, dest: _Key, keys: Iterable[_Key], aggregate: Literal["SUM", "MIN", "MAX"] | None = ...) -> int: ... + def zmscore(self, key, members): ... + +class HyperlogCommands: + def pfadd(self, name: _Key, *values: _Value) -> int: ... + def pfcount(self, name: _Key) -> int: ... + def pfmerge(self, dest: _Key, *sources: _Key) -> bool: ... + +class HashCommands(Generic[_StrType]): + def hdel(self, name: _Key, *keys: _Key) -> int: ... + def hexists(self, name: _Key, key: _Key) -> bool: ... + def hget(self, name: _Key, key: _Key) -> _StrType | None: ... + def hgetall(self, name: _Key) -> dict[_StrType, _StrType]: ... + def hincrby(self, name: _Key, key: _Key, amount: int = ...) -> int: ... + def hincrbyfloat(self, name: _Key, key: _Key, amount: float = ...) -> float: ... + def hkeys(self, name: _Key) -> list[_StrType]: ... + def hlen(self, name: _Key) -> int: ... + @overload + def hset(self, name: _Key, key: _Key, value: _Value, mapping: Mapping[_Key, _Value] | None = ...) -> int: ... + @overload + def hset(self, name: _Key, key: None, value: None, mapping: Mapping[_Key, _Value]) -> int: ... + @overload + def hset(self, name: _Key, *, mapping: Mapping[_Key, _Value]) -> int: ... + def hsetnx(self, name: _Key, key: _Key, value: _Value) -> int: ... + def hmset(self, name: _Key, mapping: Mapping[_Key, _Value]) -> bool: ... + def hmget(self, name: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> list[_StrType | None]: ... + def hvals(self, name: _Key) -> list[_StrType]: ... + def hstrlen(self, name, key): ... + +class PubSubCommands: + def publish(self, channel: _Key, message: _Key, **kwargs) -> int: ... + def pubsub_channels(self, pattern: _Key = ..., **kwargs) -> list[str]: ... + def pubsub_numpat(self, **kwargs) -> int: ... + def pubsub_numsub(self, *args: _Key, **kwargs) -> list[tuple[str, int]]: ... + +class ScriptCommands(Generic[_StrType]): + def eval(self, script, numkeys, *keys_and_args): ... + def evalsha(self, sha, numkeys, *keys_and_args): ... def script_exists(self, *args): ... + def script_debug(self, *args): ... def script_flush(self, sync_type: Any | None = ...): ... def script_kill(self): ... def script_load(self, script): ... def register_script(self, script: str | _StrType) -> Script: ... +class GeoCommands: + def geoadd(self, name, values, nx: bool = ..., xx: bool = ..., ch: bool = ...): ... + def geodist(self, name, place1, place2, unit: Any | None = ...): ... + def geohash(self, name, *values): ... + def geopos(self, name, *values): ... + def georadius( + self, + name, + longitude, + latitude, + radius, + unit: Any | None = ..., + withdist: bool = ..., + withcoord: bool = ..., + withhash: bool = ..., + count: Any | None = ..., + sort: Any | None = ..., + store: Any | None = ..., + store_dist: Any | None = ..., + any: bool = ..., + ): ... + def georadiusbymember( + self, + name, + member, + radius, + unit: Any | None = ..., + withdist: bool = ..., + withcoord: bool = ..., + withhash: bool = ..., + count: Any | None = ..., + sort: Any | None = ..., + store: Any | None = ..., + store_dist: Any | None = ..., + any: bool = ..., + ): ... + def geosearch( + self, + name, + member: Any | None = ..., + longitude: Any | None = ..., + latitude: Any | None = ..., + unit: str = ..., + radius: Any | None = ..., + width: Any | None = ..., + height: Any | None = ..., + sort: Any | None = ..., + count: Any | None = ..., + any: bool = ..., + withcoord: bool = ..., + withdist: bool = ..., + withhash: bool = ..., + ): ... + def geosearchstore( + self, + dest, + name, + member: Any | None = ..., + longitude: Any | None = ..., + latitude: Any | None = ..., + unit: str = ..., + radius: Any | None = ..., + width: Any | None = ..., + height: Any | None = ..., + sort: Any | None = ..., + count: Any | None = ..., + any: bool = ..., + storedist: bool = ..., + ): ... + +class ModuleCommands: + def module_load(self, path, *args): ... + def module_unload(self, name): ... + def module_list(self): ... + def command_info(self): ... + def command_count(self): ... + def command_getkeys(self, *args): ... + def command(self): ... + class Script: def __init__(self, registered_client, script) -> None: ... def __call__(self, keys=..., args=..., client: Any | None = ...): ... @@ -281,3 +681,30 @@ class BitFieldOperation: @property def command(self): ... def execute(self): ... + +class ClusterCommands: + def readwrite(self, **kwargs) -> bool: ... + def readonly(self, **kwargs) -> bool: ... + +class DataAccessCommands( + BasicKeyCommands[_StrType], + HyperlogCommands, + HashCommands[_StrType], + GeoCommands, + ListCommands[_StrType], + ScanCommands[_StrType], + SetCommands[_StrType], + StreamCommands, + SortedSetCommands[_StrType], + Generic[_StrType], +): ... +class CoreCommands( + ACLCommands[_StrType], + ClusterCommands, + DataAccessCommands[_StrType], + ManagementCommands, + ModuleCommands, + PubSubCommands, + ScriptCommands[_StrType], + Generic[_StrType], +): ... diff --git a/stubs/redis/redis/commands/graph/__init__.pyi b/stubs/redis/redis/commands/graph/__init__.pyi new file mode 100644 index 000000000..2f4915e3b --- /dev/null +++ b/stubs/redis/redis/commands/graph/__init__.pyi @@ -0,0 +1,26 @@ +from typing import Any + +from .commands import GraphCommands as GraphCommands +from .edge import Edge as Edge +from .node import Node as Node +from .path import Path as Path + +class Graph(GraphCommands): + NAME: Any + client: Any + execute_command: Any + nodes: Any + edges: Any + version: int + def __init__(self, client, name=...) -> None: ... + @property + def name(self): ... + def get_label(self, idx): ... + def get_relation(self, idx): ... + def get_property(self, idx): ... + def add_node(self, node) -> None: ... + def add_edge(self, edge) -> None: ... + def call_procedure(self, procedure, *args, read_only: bool = ..., **kwagrs): ... + def labels(self): ... + def relationshipTypes(self): ... + def propertyKeys(self): ... diff --git a/stubs/redis/redis/commands/graph/commands.pyi b/stubs/redis/redis/commands/graph/commands.pyi new file mode 100644 index 000000000..baa061374 --- /dev/null +++ b/stubs/redis/redis/commands/graph/commands.pyi @@ -0,0 +1,17 @@ +from typing import Any + +class GraphCommands: + def commit(self): ... + version: Any + def query(self, q, params: Any | None = ..., timeout: Any | None = ..., read_only: bool = ..., profile: bool = ...): ... + def merge(self, pattern): ... + def delete(self): ... + nodes: Any + edges: Any + def flush(self) -> None: ... + def explain(self, query, params: Any | None = ...): ... + def bulk(self, **kwargs) -> None: ... + def profile(self, query): ... + def slowlog(self): ... + def config(self, name, value: Any | None = ..., set: bool = ...): ... + def list_keys(self): ... diff --git a/stubs/redis/redis/commands/graph/edge.pyi b/stubs/redis/redis/commands/graph/edge.pyi new file mode 100644 index 000000000..22543f522 --- /dev/null +++ b/stubs/redis/redis/commands/graph/edge.pyi @@ -0,0 +1,11 @@ +from typing import Any + +class Edge: + id: Any + relation: Any + properties: Any + src_node: Any + dest_node: Any + def __init__(self, src_node, relation, dest_node, edge_id: Any | None = ..., properties: Any | None = ...) -> None: ... + def toString(self): ... + def __eq__(self, rhs): ... diff --git a/stubs/redis/redis/commands/graph/exceptions.pyi b/stubs/redis/redis/commands/graph/exceptions.pyi new file mode 100644 index 000000000..6069e0555 --- /dev/null +++ b/stubs/redis/redis/commands/graph/exceptions.pyi @@ -0,0 +1,5 @@ +from typing import Any + +class VersionMismatchException(Exception): + version: Any + def __init__(self, version) -> None: ... diff --git a/stubs/redis/redis/commands/graph/node.pyi b/stubs/redis/redis/commands/graph/node.pyi new file mode 100644 index 000000000..0b14fbae6 --- /dev/null +++ b/stubs/redis/redis/commands/graph/node.pyi @@ -0,0 +1,17 @@ +from typing import Any + +class Node: + id: Any + alias: Any + label: Any + labels: Any + properties: Any + def __init__( + self, + node_id: Any | None = ..., + alias: Any | None = ..., + label: str | list[str] | None = ..., + properties: Any | None = ..., + ) -> None: ... + def toString(self): ... + def __eq__(self, rhs): ... diff --git a/stubs/redis/redis/commands/graph/path.pyi b/stubs/redis/redis/commands/graph/path.pyi new file mode 100644 index 000000000..69106f896 --- /dev/null +++ b/stubs/redis/redis/commands/graph/path.pyi @@ -0,0 +1,18 @@ +from typing import Any + +class Path: + append_type: Any + def __init__(self, nodes, edges) -> None: ... + @classmethod + def new_empty_path(cls): ... + def nodes(self): ... + def edges(self): ... + def get_node(self, index): ... + def get_relationship(self, index): ... + def first_node(self): ... + def last_node(self): ... + def edge_count(self): ... + def nodes_count(self): ... + def add_node(self, node): ... + def add_edge(self, edge): ... + def __eq__(self, other): ... diff --git a/stubs/redis/redis/commands/graph/query_result.pyi b/stubs/redis/redis/commands/graph/query_result.pyi new file mode 100644 index 000000000..53cf3ebf4 --- /dev/null +++ b/stubs/redis/redis/commands/graph/query_result.pyi @@ -0,0 +1,75 @@ +from typing import Any, ClassVar +from typing_extensions import Literal + +LABELS_ADDED: str +NODES_CREATED: str +NODES_DELETED: str +RELATIONSHIPS_DELETED: str +PROPERTIES_SET: str +RELATIONSHIPS_CREATED: str +INDICES_CREATED: str +INDICES_DELETED: str +CACHED_EXECUTION: str +INTERNAL_EXECUTION_TIME: str +STATS: Any + +class ResultSetColumnTypes: + COLUMN_UNKNOWN: ClassVar[Literal[0]] + COLUMN_SCALAR: ClassVar[Literal[1]] + COLUMN_NODE: ClassVar[Literal[2]] + COLUMN_RELATION: ClassVar[Literal[3]] + +class ResultSetScalarTypes: + VALUE_UNKNOWN: ClassVar[Literal[0]] + VALUE_NULL: ClassVar[Literal[1]] + VALUE_STRING: ClassVar[Literal[2]] + VALUE_INTEGER: ClassVar[Literal[3]] + VALUE_BOOLEAN: ClassVar[Literal[4]] + VALUE_DOUBLE: ClassVar[Literal[5]] + VALUE_ARRAY: ClassVar[Literal[6]] + VALUE_EDGE: ClassVar[Literal[7]] + VALUE_NODE: ClassVar[Literal[8]] + VALUE_PATH: ClassVar[Literal[9]] + VALUE_MAP: ClassVar[Literal[10]] + VALUE_POINT: ClassVar[Literal[11]] + +class QueryResult: + graph: Any + header: Any + result_set: Any + def __init__(self, graph, response, profile: bool = ...) -> None: ... + def parse_results(self, raw_result_set) -> None: ... + statistics: Any + def parse_statistics(self, raw_statistics) -> None: ... + def parse_header(self, raw_result_set): ... + def parse_records(self, raw_result_set): ... + def parse_entity_properties(self, props): ... + def parse_string(self, cell): ... + def parse_node(self, cell): ... + def parse_edge(self, cell): ... + def parse_path(self, cell): ... + def parse_map(self, cell): ... + def parse_point(self, cell): ... + def parse_scalar(self, cell): ... + def parse_profile(self, response) -> None: ... + def is_empty(self): ... + @property + def labels_added(self): ... + @property + def nodes_created(self): ... + @property + def nodes_deleted(self): ... + @property + def properties_set(self): ... + @property + def relationships_created(self): ... + @property + def relationships_deleted(self): ... + @property + def indices_created(self): ... + @property + def indices_deleted(self): ... + @property + def cached_execution(self): ... + @property + def run_time_ms(self): ... diff --git a/stubs/redis/redis/commands/helpers.pyi b/stubs/redis/redis/commands/helpers.pyi index 231306845..d359ff0f8 100644 --- a/stubs/redis/redis/commands/helpers.pyi +++ b/stubs/redis/redis/commands/helpers.pyi @@ -2,5 +2,9 @@ def list_or_args(keys, args): ... def nativestr(x): ... def delist(x): ... def parse_to_list(response): ... +def parse_list_to_dict(response): ... +def parse_to_dict(response): ... def random_string(length: int = ...) -> str: ... def quote_string(v): ... +def decodeDictKeys(obj): ... +def stringify_param_value(value): ... diff --git a/stubs/redis/redis/commands/json/commands.pyi b/stubs/redis/redis/commands/json/commands.pyi index e3bdc25a5..6f830282a 100644 --- a/stubs/redis/redis/commands/json/commands.pyi +++ b/stubs/redis/redis/commands/json/commands.pyi @@ -19,6 +19,8 @@ class JSONCommands: def get(self, name, *args, no_escape: bool = ...): ... def mget(self, keys, path): ... def set(self, name, path, obj, nx: bool = ..., xx: bool = ..., decode_keys: bool = ...): ... + def set_file(self, name, path, file_name, nx: bool = ..., xx: bool = ..., decode_keys: bool = ...): ... + def set_path(self, json_path, root_folder, nx: bool = ..., xx: bool = ..., decode_keys: bool = ...): ... def strlen(self, name, path: Any | None = ...): ... def toggle(self, name, path=...): ... def strappend(self, name, value, path=...): ... diff --git a/stubs/redis/redis/commands/parser.pyi b/stubs/redis/redis/commands/parser.pyi new file mode 100644 index 000000000..58094e5d7 --- /dev/null +++ b/stubs/redis/redis/commands/parser.pyi @@ -0,0 +1,8 @@ +from typing import Any + +class CommandsParser: + initialized: bool + commands: Any + def __init__(self, redis_connection) -> None: ... + def initialize(self, r) -> None: ... + def get_keys(self, redis_conn, *args): ... diff --git a/stubs/redis/redis/commands/redismodules.pyi b/stubs/redis/redis/commands/redismodules.pyi index 9f807c993..6f535b231 100644 --- a/stubs/redis/redis/commands/redismodules.pyi +++ b/stubs/redis/redis/commands/redismodules.pyi @@ -6,3 +6,9 @@ class RedisModuleCommands: def json(self, encoder=..., decoder=...) -> JSON: ... def ft(self, index_name: str = ...) -> Search: ... def ts(self) -> TimeSeries: ... + def bf(self): ... + def cf(self): ... + def cms(self): ... + def topk(self): ... + def tdigest(self): ... + def graph(self, index_name: str = ...): ... diff --git a/stubs/redis/redis/commands/search/aggregation.pyi b/stubs/redis/redis/commands/search/aggregation.pyi new file mode 100644 index 000000000..0ccd50523 --- /dev/null +++ b/stubs/redis/redis/commands/search/aggregation.pyi @@ -0,0 +1,54 @@ +from typing import Any, ClassVar +from typing_extensions import Literal + +FIELDNAME: Any + +class Limit: + offset: Any + count: Any + def __init__(self, offset: int = ..., count: int = ...) -> None: ... + def build_args(self): ... + +class Reducer: + NAME: ClassVar[None] + def __init__(self, *args) -> None: ... + def alias(self, alias): ... + @property + def args(self): ... + +class SortDirection: + DIRSTRING: ClassVar[str | None] + field: Any + def __init__(self, field) -> None: ... + +class Asc(SortDirection): + DIRSTRING: ClassVar[Literal["ASC"]] + +class Desc(SortDirection): + DIRSTRING: ClassVar[Literal["DESC"]] + +class AggregateRequest: + def __init__(self, query: str = ...) -> None: ... + def load(self, *fields): ... + def group_by(self, fields, *reducers): ... + def apply(self, **kwexpr): ... + def limit(self, offset, num): ... + def sort_by(self, *fields, **kwargs): ... + def filter(self, expressions): ... + def with_schema(self): ... + def verbatim(self): ... + def cursor(self, count: int = ..., max_idle: float = ...): ... + def build_args(self): ... + +class Cursor: + cid: Any + max_idle: int + count: int + def __init__(self, cid) -> None: ... + def build_args(self): ... + +class AggregateResult: + rows: Any + cursor: Any + schema: Any + def __init__(self, rows, cursor, schema) -> None: ... diff --git a/stubs/redis/redis/commands/search/commands.pyi b/stubs/redis/redis/commands/search/commands.pyi index 459376b5f..05c9a0a95 100644 --- a/stubs/redis/redis/commands/search/commands.pyi +++ b/stubs/redis/redis/commands/search/commands.pyi @@ -13,6 +13,7 @@ EXPLAIN_CMD: Literal["FT.EXPLAIN"] EXPLAINCLI_CMD: Literal["FT.EXPLAINCLI"] DEL_CMD: Literal["FT.DEL"] AGGREGATE_CMD: Literal["FT.AGGREGATE"] +PROFILE_CMD: Literal["FT.PROFILE"] CURSOR_CMD: Literal["FT.CURSOR"] SPELLCHECK_CMD: Literal["FT.SPELLCHECK"] DICT_ADD_CMD: Literal["FT.DICTADD"] @@ -51,7 +52,6 @@ class SearchCommands: definition: Any | None = ..., ): ... def alter_schema_add(self, fields): ... - def drop_index(self, delete_documents: bool = ...): ... def dropindex(self, delete_documents: bool = ...): ... def add_document( self, @@ -74,6 +74,7 @@ class SearchCommands: def explain(self, query): ... def explain_cli(self, query): ... def aggregate(self, query): ... + def profile(self, query, limited: bool = ...): ... def spellcheck(self, query, distance: Any | None = ..., include: Any | None = ..., exclude: Any | None = ...): ... def dict_add(self, name, *terms): ... def dict_del(self, name, *terms): ... diff --git a/stubs/redis/redis/connection.pyi b/stubs/redis/redis/connection.pyi index 875068195..c1261feb1 100644 --- a/stubs/redis/redis/connection.pyi +++ b/stubs/redis/redis/connection.pyi @@ -34,17 +34,17 @@ class PythonParser(BaseParser): def on_connect(self, connection): ... def on_disconnect(self): ... def can_read(self, timeout): ... - def read_response(self): ... + def read_response(self, disable_decoding: bool = ...): ... class HiredisParser(BaseParser): socket_read_size: Any def __init__(self, socket_read_size) -> None: ... def __del__(self): ... - def on_connect(self, connection): ... + def on_connect(self, connection, **kwargs): ... def on_disconnect(self): ... def can_read(self, timeout): ... def read_from_socket(self, timeout=..., raise_on_timeout: bool = ...) -> bool: ... - def read_response(self): ... + def read_response(self, disable_decoding: bool = ...): ... DefaultParser: Any @@ -65,10 +65,12 @@ class Connection: socket_keepalive: Any socket_keepalive_options: Any retry_on_timeout: Any + retry_on_error: Any encoding: Any encoding_errors: Any decode_responses: Any retry: Retry + redis_connect_func: Any | None def __init__( self, host: str = ..., @@ -81,6 +83,7 @@ class Connection: socket_keepalive_options: Mapping[str, int | str] | None = ..., socket_type: int = ..., retry_on_timeout: bool = ..., + retry_on_error=..., encoding: str = ..., encoding_errors: str = ..., decode_responses: bool = ..., @@ -90,10 +93,12 @@ class Connection: client_name: str | None = ..., username: str | None = ..., retry: Retry | None = ..., + redis_connect_func: Any | None = ..., ) -> None: ... def __del__(self): ... def register_connect_callback(self, callback): ... def clear_connect_callbacks(self): ... + def set_parser(self, parser_class): ... def connect(self): ... def on_connect(self): ... def disconnect(self): ... @@ -101,7 +106,7 @@ class Connection: def send_packed_command(self, command, check_health: bool = ...): ... def send_command(self, *args): ... def can_read(self, timeout=...): ... - def read_response(self): ... + def read_response(self, disable_decoding: bool = ...): ... def pack_command(self, *args): ... def pack_commands(self, commands): ... def repr_pieces(self) -> list[tuple[str, str]]: ... @@ -112,8 +117,21 @@ class SSLConnection(Connection): certfile: Any cert_reqs: Any ca_certs: Any + ca_path: Any | None + check_hostname: bool + certificate_password: Any | None + ssl_validate_ocsp: bool def __init__( - self, ssl_keyfile=..., ssl_certfile=..., ssl_cert_reqs=..., ssl_ca_certs=..., ssl_check_hostname: bool = ..., **kwargs + self, + ssl_keyfile=..., + ssl_certfile=..., + ssl_cert_reqs=..., + ssl_ca_certs=..., + ssl_check_hostname: bool = ..., + ssl_ca_path: Any | None = ..., + ssl_password: Any | None = ..., + ssl_validate_ocsp: bool = ..., + **kwargs, ) -> None: ... class UnixDomainSocketConnection(Connection): @@ -139,11 +157,13 @@ class UnixDomainSocketConnection(Connection): encoding_errors: str = ..., decode_responses: bool = ..., retry_on_timeout: bool = ..., + retry_on_error=..., parser_class=..., socket_read_size: int = ..., health_check_interval: int = ..., client_name=..., retry: Retry | None = ..., + redis_connect_func: Any | None = ..., ) -> None: ... def repr_pieces(self) -> list[tuple[str, str]]: ... diff --git a/stubs/redis/redis/crc.pyi b/stubs/redis/redis/crc.pyi new file mode 100644 index 000000000..af2e5f7f7 --- /dev/null +++ b/stubs/redis/redis/crc.pyi @@ -0,0 +1,3 @@ +REDIS_CLUSTER_HASH_SLOTS: int + +def key_slot(key, bucket=...): ... diff --git a/stubs/redis/redis/exceptions.pyi b/stubs/redis/redis/exceptions.pyi index 7aff7f227..1820d3d91 100644 --- a/stubs/redis/redis/exceptions.pyi +++ b/stubs/redis/redis/exceptions.pyi @@ -2,6 +2,7 @@ class RedisError(Exception): ... class AuthenticationError(RedisError): ... class ConnectionError(RedisError): ... class TimeoutError(RedisError): ... +class AuthorizationError(ConnectionError): ... class BusyLoadingError(ConnectionError): ... class InvalidResponse(RedisError): ... class ResponseError(RedisError): ... @@ -17,3 +18,25 @@ class LockError(RedisError, ValueError): ... class LockNotOwnedError(LockError): ... class ChildDeadlockedError(Exception): ... class AuthenticationWrongNumberOfArgsError(ResponseError): ... +class RedisClusterException(Exception): ... +class ClusterError(RedisError): ... + +class ClusterDownError(ClusterError, ResponseError): + args: tuple[str] + message: str + def __init__(self, resp: str) -> None: ... + +class AskError(ResponseError): + args: tuple[str] + message: str + slot_id: int + node_addr: tuple[str, int] + host: str + port: int + def __init__(self, resp: str) -> None: ... + +class TryAgainError(ResponseError): ... +class ClusterCrossSlotError(ResponseError): ... +class MovedError(AskError): ... +class MasterDownError(ClusterDownError): ... +class SlotNotCoveredError(RedisClusterException): ... diff --git a/stubs/redis/redis/ocsp.pyi b/stubs/redis/redis/ocsp.pyi new file mode 100644 index 000000000..41d879720 --- /dev/null +++ b/stubs/redis/redis/ocsp.pyi @@ -0,0 +1,13 @@ +from typing import Any + +class OCSPVerifier: + SOCK: Any + HOST: Any + PORT: Any + CA_CERTS: Any + def __init__(self, sock, host, port, ca_certs: Any | None = ...) -> None: ... + def components_from_socket(self): ... + def components_from_direct_connection(self): ... + def build_certificate_url(self, server, cert, issuer_cert): ... + def check_certificate(self, server, cert, issuer_url): ... + def is_valid(self): ... diff --git a/stubs/redis/redis/retry.pyi b/stubs/redis/redis/retry.pyi index 3182bf5bc..ec14a3750 100644 --- a/stubs/redis/redis/retry.pyi +++ b/stubs/redis/redis/retry.pyi @@ -1,3 +1,4 @@ class Retry: def __init__(self, backoff, retries, supported_errors=...) -> None: ... + def update_supported_erros(self, specified_errors) -> None: ... def call_with_retry(self, do, fail): ... diff --git a/stubs/redis/redis/sentinel.pyi b/stubs/redis/redis/sentinel.pyi index ef757caf7..1022cc77f 100644 --- a/stubs/redis/redis/sentinel.pyi +++ b/stubs/redis/redis/sentinel.pyi @@ -16,7 +16,7 @@ class SentinelManagedConnection(Connection): def __init__(self, **kwargs) -> None: ... def connect_to(self, address) -> None: ... def connect(self) -> None: ... - def read_response(self): ... + def read_response(self, disable_decoding: bool = ...): ... class SentinelManagedSSLConnection(SentinelManagedConnection, SSLConnection): ... diff --git a/stubs/redis/redis/utils.pyi b/stubs/redis/redis/utils.pyi index 9df7a80e3..5180003bf 100644 --- a/stubs/redis/redis/utils.pyi +++ b/stubs/redis/redis/utils.pyi @@ -7,6 +7,7 @@ from .client import Pipeline, Redis, _StrType _T = TypeVar("_T") HIREDIS_AVAILABLE: bool +CRYPTOGRAPHY_AVAILABLE: bool @overload def from_url(url: str, *, db: int = ..., decode_responses: Literal[True], **kwargs: Any) -> Redis[str]: ... @@ -18,3 +19,6 @@ def str_if_bytes(value: bytes) -> str: ... # type: ignore[misc] @overload def str_if_bytes(value: _T) -> _T: ... def safe_str(value: object) -> str: ... +def dict_merge(*dicts): ... +def list_keys_to_dict(key_list, callback): ... +def merge_result(command, res): ...