diff --git a/stubs/redis/@tests/stubtest_allowlist.txt b/stubs/redis/@tests/stubtest_allowlist.txt index 65805b4d29b9..fb3dec38f976 100644 --- a/stubs/redis/@tests/stubtest_allowlist.txt +++ b/stubs/redis/@tests/stubtest_allowlist.txt @@ -1,4 +1,3 @@ -redis.client.Pipeline.acl_setuser redis.client.Pipeline.client_list redis.client.Pipeline.flushall redis.client.Pipeline.flushdb @@ -18,27 +17,17 @@ redis.client.PubSub.encode redis.client.PubSub.execute_command redis.client.PubSub.parse_response redis.client.PubSub.run_in_thread -redis.client.Redis.acl_setuser -redis.client.Redis.client_list redis.client.Redis.flushall redis.client.Redis.flushdb -redis.client.Redis.from_url redis.client.Redis.hscan redis.client.Redis.pubsub redis.client.Redis.scan redis.client.Redis.scan_iter redis.client.Redis.shutdown redis.client.Redis.sscan -redis.client.Redis.zinterstore -redis.client.Redis.zrevrange -redis.client.Redis.zrevrangebylex -redis.client.Redis.zrevrangebyscore -redis.client.Redis.zunionstore redis.client.pairs_to_dict redis.connection.HIREDIS_SUPPORTS_BYTE_BUFFER redis.connection.HIREDIS_SUPPORTS_CALLABLE_ERRORS redis.connection.HIREDIS_USE_BYTE_BUFFER redis.connection.hiredis_version redis.connection.msg -redis.utils.safe_str -redis.utils.str_if_bytes diff --git a/stubs/redis/METADATA.toml b/stubs/redis/METADATA.toml index f1af1bfd7fc4..0ca63cc11f20 100644 --- a/stubs/redis/METADATA.toml +++ b/stubs/redis/METADATA.toml @@ -1,3 +1,2 @@ -version = "3.5.*" -python2 = true +version = "4.0.*" requires = [] diff --git a/stubs/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index e74550fe0e04..b7d1e8e600da 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -1,17 +1,18 @@ import builtins from datetime import datetime, timedelta -from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, Sequence, Text, Type, TypeVar, Union, overload +from typing import Any, Callable, Generic, Iterable, Iterator, Mapping, Sequence, Type, TypeVar, Union, overload from typing_extensions import Literal +from .commands import CoreCommands, RedisModuleCommands, SentinelCommands from .connection import ConnectionPool from .lock import Lock +from .retry import Retry SYM_EMPTY: Any def list_or_args(keys, args): ... def timestamp_to_datetime(response): ... def string_keys_to_dict(key_string, callback): ... -def dict_merge(*dicts): ... def parse_debug_object(response): ... def parse_object(response, infotype): ... def parse_info(response): ... @@ -39,305 +40,182 @@ def parse_slowlog_get(response, **options): ... _ScoreCastFuncReturn = TypeVar("_ScoreCastFuncReturn") -_Value = Union[bytes, float, int, Text] -_Key = Union[Text, bytes] +_Value = Union[bytes, float, int, str] +_Key = Union[str, bytes] # Lib returns str or bytes depending on Python version and value of decode_responses -_StrType = TypeVar("_StrType", bound=Union[Text, bytes]) +_StrType = TypeVar("_StrType", bound=Union[str, bytes]) _LockType = TypeVar("_LockType") -class Redis(Generic[_StrType]): +class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Generic[_StrType]): RESPONSE_CALLBACKS: Any @overload @classmethod def from_url( cls, - url: Text, - host: Text | None, - port: int | None, - db: int | None, - password: Text | None, - socket_timeout: float | None, - socket_connect_timeout: float | None, - socket_keepalive: bool | None, - socket_keepalive_options: Mapping[str, int | str] | None, - connection_pool: ConnectionPool | None, - unix_socket_path: Text | None, - encoding: Text, - encoding_errors: Text, - charset: Text | None, - errors: Text | None, - decode_responses: Literal[True], - retry_on_timeout: bool = ..., - ssl: bool = ..., - ssl_keyfile: Text | None = ..., - ssl_certfile: Text | None = ..., - ssl_cert_reqs: str | int | None = ..., - ssl_ca_certs: Text | None = ..., - ssl_check_hostname: bool = ..., - max_connections: int | None = ..., - single_connection_client: bool = ..., - health_check_interval: float = ..., - client_name: Text | None = ..., - username: Text | None = ..., - ) -> Redis[str]: ... - @overload - @classmethod - def from_url( - cls, - url: Text, - host: Text | None = ..., + url: str, + *, + host: str | None = ..., port: int | None = ..., db: int | None = ..., - password: Text | None = ..., + password: str | None = ..., socket_timeout: float | None = ..., socket_connect_timeout: float | None = ..., socket_keepalive: bool | None = ..., socket_keepalive_options: Mapping[str, int | str] | None = ..., connection_pool: ConnectionPool | None = ..., - unix_socket_path: Text | None = ..., - encoding: Text = ..., - encoding_errors: Text = ..., - charset: Text | None = ..., - errors: Text | None = ..., - *, + unix_socket_path: str | None = ..., + encoding: str = ..., + encoding_errors: str = ..., + charset: str | None = ..., + errors: str | None = ..., decode_responses: Literal[True], retry_on_timeout: bool = ..., ssl: bool = ..., - ssl_keyfile: Text | None = ..., - ssl_certfile: Text | None = ..., + ssl_keyfile: str | None = ..., + ssl_certfile: str | None = ..., ssl_cert_reqs: str | int | None = ..., - ssl_ca_certs: Text | None = ..., + ssl_ca_certs: str | None = ..., ssl_check_hostname: bool = ..., max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., - client_name: Text | None = ..., - username: Text | None = ..., + client_name: str | None = ..., + username: str | None = ..., ) -> Redis[str]: ... @overload @classmethod def from_url( cls, - url: Text, - host: Text | None = ..., + url: str, + *, + host: str | None = ..., port: int | None = ..., db: int | None = ..., - password: Text | None = ..., + password: str | None = ..., socket_timeout: float | None = ..., socket_connect_timeout: float | None = ..., socket_keepalive: bool | None = ..., socket_keepalive_options: Mapping[str, int | str] | None = ..., connection_pool: ConnectionPool | None = ..., - unix_socket_path: Text | None = ..., - encoding: Text = ..., - encoding_errors: Text = ..., - charset: Text | None = ..., + unix_socket_path: str | None = ..., + encoding: str = ..., + encoding_errors: str = ..., + charset: str | None = ..., + errors: str | None = ..., decode_responses: Literal[False] = ..., - errors: Text | None = ..., retry_on_timeout: bool = ..., ssl: bool = ..., - ssl_keyfile: Text | None = ..., - ssl_certfile: Text | None = ..., + ssl_keyfile: str | None = ..., + ssl_certfile: str | None = ..., ssl_cert_reqs: str | int | None = ..., - ssl_ca_certs: Text | None = ..., + ssl_ca_certs: str | None = ..., ssl_check_hostname: bool = ..., max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., - client_name: Text | None = ..., - username: Text | None = ..., + client_name: str | None = ..., + username: str | None = ..., ) -> Redis[bytes]: ... connection_pool: Any response_callbacks: Any @overload - def __new__( - cls, - host: Text, - port: int, - db: int, - password: Text | None, - socket_timeout: float | None, - socket_connect_timeout: float | None, - socket_keepalive: bool | None, - socket_keepalive_options: Mapping[str, int | str] | None, - connection_pool: ConnectionPool | None, - unix_socket_path: Text | None, - encoding: Text, - encoding_errors: Text, - charset: Text | None, - decode_responses: Literal[True], - errors: Text | None = ..., - retry_on_timeout: bool = ..., - ssl: bool = ..., - ssl_keyfile: Text | None = ..., - ssl_certfile: Text | None = ..., - ssl_cert_reqs: str | int | None = ..., - ssl_ca_certs: Text | None = ..., - ssl_check_hostname: bool = ..., - max_connections: int | None = ..., - single_connection_client: bool = ..., - health_check_interval: float = ..., - client_name: Text | None = ..., - username: Text | None = ..., - ) -> Redis[str]: ... - @overload - def __new__( - cls, - host: Text = ..., - port: int = ..., - db: int = ..., - password: Text | None = ..., - socket_timeout: float | None = ..., - socket_connect_timeout: float | None = ..., - socket_keepalive: bool | None = ..., - socket_keepalive_options: Mapping[str, int | str] | None = ..., - connection_pool: ConnectionPool | None = ..., - unix_socket_path: Text | None = ..., - encoding: Text = ..., - encoding_errors: Text = ..., - charset: Text | None = ..., - *, - decode_responses: Literal[True], - errors: Text | None = ..., - retry_on_timeout: bool = ..., - ssl: bool = ..., - ssl_keyfile: Text | None = ..., - ssl_certfile: Text | None = ..., - ssl_cert_reqs: str | int | None = ..., - ssl_ca_certs: Text | None = ..., - ssl_check_hostname: bool = ..., - max_connections: int | None = ..., - single_connection_client: bool = ..., - health_check_interval: float = ..., - client_name: Text | None = ..., - username: Text | None = ..., - ) -> Redis[str]: ... - @overload - def __new__( - cls, - host: Text = ..., - port: int = ..., - db: int = ..., - password: Text | None = ..., - socket_timeout: float | None = ..., - socket_connect_timeout: float | None = ..., - socket_keepalive: bool | None = ..., - socket_keepalive_options: Mapping[str, int | str] | None = ..., - connection_pool: ConnectionPool | None = ..., - unix_socket_path: Text | None = ..., - encoding: Text = ..., - encoding_errors: Text = ..., - charset: Text | None = ..., - errors: Text | None = ..., - decode_responses: Literal[False] = ..., - retry_on_timeout: bool = ..., - ssl: bool = ..., - ssl_keyfile: Text | None = ..., - ssl_certfile: Text | None = ..., - ssl_cert_reqs: str | int | None = ..., - ssl_ca_certs: Text | None = ..., - ssl_check_hostname: bool = ..., - max_connections: int | None = ..., - single_connection_client: bool = ..., - health_check_interval: float = ..., - client_name: Text | None = ..., - username: Text | None = ..., - ) -> Redis[bytes]: ... - @overload def __init__( self: Redis[str], - host: Text, + host: str, port: int, db: int, - password: Text | None, + password: str | None, socket_timeout: float | None, socket_connect_timeout: float | None, socket_keepalive: bool | None, socket_keepalive_options: Mapping[str, int | str] | None, connection_pool: ConnectionPool | None, - unix_socket_path: Text | None, - encoding: Text, - encoding_errors: Text, - charset: Text | None, - errors: Text | None, + unix_socket_path: str | None, + encoding: str, + encoding_errors: str, + charset: str | None, + errors: str | None, decode_responses: Literal[True], retry_on_timeout: bool = ..., ssl: bool = ..., - ssl_keyfile: Text | None = ..., - ssl_certfile: Text | None = ..., + ssl_keyfile: str | None = ..., + ssl_certfile: str | None = ..., ssl_cert_reqs: str | int | None = ..., - ssl_ca_certs: Text | None = ..., + ssl_ca_certs: str | None = ..., ssl_check_hostname: bool = ..., max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., - client_name: Text | None = ..., - username: Text | None = ..., + client_name: str | None = ..., + username: str | None = ..., + retry: Retry | None = ..., ) -> None: ... @overload def __init__( self: Redis[str], - host: Text = ..., + host: str = ..., port: int = ..., db: int = ..., - password: Text | None = ..., + password: str | None = ..., socket_timeout: float | None = ..., socket_connect_timeout: float | None = ..., socket_keepalive: bool | None = ..., socket_keepalive_options: Mapping[str, int | str] | None = ..., connection_pool: ConnectionPool | None = ..., - unix_socket_path: Text | None = ..., - encoding: Text = ..., - encoding_errors: Text = ..., - charset: Text | None = ..., - errors: Text | None = ..., + unix_socket_path: str | None = ..., + encoding: str = ..., + encoding_errors: str = ..., + charset: str | None = ..., + errors: str | None = ..., *, decode_responses: Literal[True], retry_on_timeout: bool = ..., ssl: bool = ..., - ssl_keyfile: Text | None = ..., - ssl_certfile: Text | None = ..., + ssl_keyfile: str | None = ..., + ssl_certfile: str | None = ..., ssl_cert_reqs: str | int | None = ..., - ssl_ca_certs: Text | None = ..., + ssl_ca_certs: str | None = ..., ssl_check_hostname: bool = ..., max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., - client_name: Text | None = ..., - username: Text | None = ..., + client_name: str | None = ..., + username: str | None = ..., + retry: Retry | None = ..., ) -> None: ... @overload def __init__( self: Redis[bytes], - host: Text = ..., + host: str = ..., port: int = ..., db: int = ..., - password: Text | None = ..., + password: str | None = ..., socket_timeout: float | None = ..., socket_connect_timeout: float | None = ..., socket_keepalive: bool | None = ..., socket_keepalive_options: Mapping[str, int | str] | None = ..., connection_pool: ConnectionPool | None = ..., - unix_socket_path: Text | None = ..., - encoding: Text = ..., - encoding_errors: Text = ..., - charset: Text | None = ..., - errors: Text | None = ..., + unix_socket_path: str | None = ..., + encoding: str = ..., + encoding_errors: str = ..., + charset: str | None = ..., + errors: str | None = ..., decode_responses: Literal[False] = ..., retry_on_timeout: bool = ..., ssl: bool = ..., - ssl_keyfile: Text | None = ..., - ssl_certfile: Text | None = ..., + ssl_keyfile: str | None = ..., + ssl_certfile: str | None = ..., ssl_cert_reqs: str | int | None = ..., - ssl_ca_certs: Text | None = ..., + ssl_ca_certs: str | None = ..., ssl_check_hostname: bool = ..., max_connections: int | None = ..., single_connection_client: bool = ..., health_check_interval: float = ..., - client_name: Text | None = ..., - username: Text | None = ..., + client_name: str | None = ..., + username: str | None = ..., + retry: Retry | None = ..., ) -> None: ... def set_response_callback(self, command, callback): ... def pipeline(self, transaction: bool = ..., shard_hint: Any = ...) -> Pipeline[_StrType]: ... @@ -376,35 +254,7 @@ class Redis(Generic[_StrType]): 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): ... - def acl_cat(self, category: Text | None = ...) -> list[str]: ... - def acl_deluser(self, username: Text) -> int: ... - def acl_genpass(self) -> Text: ... - def acl_getuser(self, username: Text) -> Any | None: ... - def acl_list(self) -> list[Text]: ... - def acl_load(self) -> bool: ... - def acl_setuser( - self, - username: Text = ..., - enabled: bool = ..., - nopass: bool = ..., - passwords: Sequence[Text] | None = ..., - hashed_passwords: Sequence[Text] | None = ..., - categories: Sequence[Text] | None = ..., - commands: Sequence[Text] | None = ..., - keys: Sequence[Text] | None = ..., - reset: bool = ..., - reset_keys: bool = ..., - reset_passwords: bool = ..., - ) -> bool: ... - def acl_users(self) -> list[Text]: ... - def acl_whoami(self) -> Text: ... - def bgrewriteaof(self): ... - def bgsave(self): ... - def client_id(self) -> int: ... - def client_kill(self, address: Text) -> bool: ... - def client_list(self) -> list[dict[str, str]]: ... - def client_getname(self) -> str | None: ... - def client_setname(self, name: Text) -> bool: ... + # 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=...): ... @@ -421,15 +271,6 @@ class Redis(Generic[_StrType]): def object(self, infotype, key): ... def ping(self) -> bool: ... def save(self) -> bool: ... - def sentinel(self, *args): ... - def sentinel_get_master_addr_by_name(self, service_name): ... - def sentinel_master(self, service_name): ... - def sentinel_masters(self): ... - def sentinel_monitor(self, name, ip, port, quorum): ... - def sentinel_remove(self, name): ... - def sentinel_sentinels(self, service_name): ... - def sentinel_set(self, name, option, value): ... - def sentinel_slaves(self, service_name): ... def shutdown(self): ... def slaveof(self, host=..., port=...): ... def slowlog_get(self, num=...): ... @@ -467,20 +308,6 @@ class Redis(Generic[_StrType]): def pexpireat(self, name: _Key, when: int | datetime) -> Literal[1, 0]: ... def psetex(self, name, time_ms, value): ... def pttl(self, name): ... - def randomkey(self): ... - def rename(self, src, dst): ... - def renamenx(self, src, dst): ... - def restore(self, name, ttl, value, replace: bool = ...): ... - def set( - self, - name: _Key, - value: _Value, - ex: None | int | timedelta = ..., - px: None | int | timedelta = ..., - nx: bool = ..., - xx: bool = ..., - keepttl: bool = ..., - ) -> bool | None: ... 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: ... @@ -502,22 +329,6 @@ class Redis(Generic[_StrType]): @overload def brpop(self, keys: _Value | Iterable[_Value], timeout: float) -> tuple[_StrType, _StrType] | None: ... def brpoplpush(self, src, dst, timeout=...): ... - 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): ... - 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): ... - def rpoplpush(self, src, dst): ... - def rpush(self, name: _Value, *values: _Value) -> int: ... - def rpushx(self, name, value): ... @overload def sort( self, @@ -559,11 +370,11 @@ class Redis(Generic[_StrType]): groups: bool = ..., ) -> int: ... def scan(self, cursor: int = ..., match: _Key | None = ..., count: int | None = ...) -> tuple[int, list[_StrType]]: ... - def scan_iter(self, match: Text | None = ..., count: int | None = ...) -> Iterator[_StrType]: ... - def sscan(self, name: _Key, cursor: int = ..., match: Text = ..., count: int = ...) -> tuple[int, list[_StrType]]: ... + def scan_iter(self, match: str | None = ..., count: int | None = ...) -> Iterator[_StrType]: ... + def sscan(self, name: _Key, cursor: int = ..., match: str = ..., count: int = ...) -> tuple[int, list[_StrType]]: ... def sscan_iter(self, name, match=..., count=...): ... def hscan( - self, name: _Key, cursor: int = ..., match: Text = ..., count: int = ... + self, name: _Key, cursor: int = ..., match: str = ..., count: int = ... ) -> tuple[int, dict[_StrType, _StrType]]: ... def hscan_iter(self, name, match=..., count=...): ... def zscan(self, name, cursor=..., match=..., count=..., score_cast_func=...): ... @@ -588,147 +399,6 @@ class Redis(Generic[_StrType]): 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 xack(self, name, groupname, *ids): ... - def xadd(self, name, fields, id=..., maxlen=..., approximate=...): ... - 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_delconsumer(self, name, groupname, consumername): ... - def xgroup_destroy(self, name, groupname): ... - def xgroup_setid(self, name, groupname, id): ... - def xinfo_consumers(self, name, groupname): ... - def xinfo_groups(self, name): ... - def xinfo_stream(self, name): ... - def xlen(self, name: _Key) -> int: ... - def xpending(self, name, groupname): ... - def xpending_range(self, name, groupname, min, max, count, consumername=...): ... - 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 xtrim(self, name, maxlen, approximate=...): ... - def zadd( - self, name: _Key, mapping: Mapping[_Key, _Value], nx: bool = ..., xx: bool = ..., ch: bool = ..., incr: bool = ... - ) -> int: ... - def zcard(self, name: _Key) -> int: ... - def zcount(self, name: _Key, min: _Value, max: _Value) -> int: ... - def zincrby(self, name: _Key, amount: float, value: _Value) -> float: ... - def zinterstore(self, dest: _Key, keys: Iterable[_Key], aggregate: Literal["SUM", "MIN", "MAX"] = ...) -> int: ... - def zlexcount(self, name: _Key, min: _Value, max: _Value) -> int: ... - def zpopmax(self, name: _Key, count: int | None = ...) -> list[_StrType]: ... - def zpopmin(self, name: _Key, count: int | None = ...) -> list[_StrType]: ... - @overload - def bzpopmax(self, keys: _Key | Iterable[_Key], timeout: Literal[0] = ...) -> tuple[_StrType, _StrType, float]: ... - @overload - def bzpopmax(self, keys: _Key | Iterable[_Key], timeout: float) -> tuple[_StrType, _StrType, float] | None: ... - @overload - def bzpopmin(self, keys: _Key | Iterable[_Key], timeout: Literal[0] = ...) -> tuple[_StrType, _StrType, float]: ... - @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] = ..., - ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... - @overload - def zrange( - self, - name: _Key, - start: int, - end: int, - desc: bool = ..., - withscores: bool = ..., - score_cast_func: Callable[[Any], Any] = ..., - ) -> list[_StrType]: ... - def zrangebylex( - self, name: _Key, min: _Value, max: _Value, start: int | None = ..., num: int | None = ... - ) -> list[_StrType]: ... - @overload - def zrangebyscore( - self, - name: _Key, - min: _Value, - max: _Value, - start: int | None = ..., - num: int | None = ..., - *, - withscores: Literal[True], - score_cast_func: Callable[[float], _ScoreCastFuncReturn] = ..., - ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... - @overload - def zrangebyscore( - self, - name: _Key, - min: _Value, - max: _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, - desc: bool = ..., - *, - withscores: Literal[True], - score_cast_func: Callable[[float], _ScoreCastFuncReturn] = ..., - ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... - @overload - def zrevrange( - self, - name: _Key, - start: int, - end: int, - desc: bool = ..., - withscores: bool = ..., - score_cast_func: Callable[[Any], Any] = ..., - ) -> list[_StrType]: ... - @overload - def zrevrangebyscore( - self, - name: _Key, - min: _Value, - max: _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, - min: _Value, - max: _Value, - start: int | None = ..., - num: int | None = ..., - withscores: bool = ..., - score_cast_func: Callable[[Any], Any] = ..., - ) -> list[_StrType]: ... - def zrevrangebylex( - self, name: _Key, min: _Value, max: _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 zunionstore(self, dest: _Key, keys: Iterable[_Key], aggregate: Literal["SUM", "MIN", "MAX"] = ...) -> int: ... def pfadd(self, name: _Key, *values: _Value) -> int: ... def pfcount(self, name: _Key) -> int: ... def pfmerge(self, dest: _Key, *sources: _Key) -> bool: ... @@ -753,13 +423,8 @@ class Redis(Generic[_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 script_exists(self, *args): ... - def script_flush(self): ... - def script_kill(self): ... - def script_load(self, script): ... - def register_script(self, script: Text | _StrType) -> Script: ... - def pubsub_channels(self, pattern: _Key = ...) -> list[Text]: ... - def pubsub_numsub(self, *args: _Key) -> list[tuple[Text, int]]: ... + 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]: ... @@ -840,22 +505,22 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def pipeline(self, transaction: bool = ..., shard_hint: Any = ...) -> Pipeline[_StrType]: ... # type: ignore[override] def lock(self, name, timeout=..., sleep=..., blocking_timeout=..., lock_class=..., thread_local=...): ... def pubsub(self, shard_hint: Any = ..., ignore_subscribe_messages: bool = ...) -> PubSub: ... - def acl_cat(self, category: Text | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override] - def acl_deluser(self, username: Text) -> Pipeline[_StrType]: ... # type: ignore[override] - def acl_genpass(self) -> Pipeline[_StrType]: ... # type: ignore[override] - def acl_getuser(self, username: Text) -> Pipeline[_StrType]: ... # type: ignore[override] + def acl_cat(self, category: str | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override] + def acl_deluser(self, username: str) -> Pipeline[_StrType]: ... # type: ignore[override] + def acl_genpass(self, bits: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override] + def acl_getuser(self, username: str) -> Pipeline[_StrType]: ... # type: ignore[override] def acl_list(self) -> Pipeline[_StrType]: ... # type: ignore[override] def acl_load(self) -> Pipeline[_StrType]: ... # type: ignore[override] def acl_setuser( # type: ignore[override] self, - username: Text = ..., + username: str, enabled: bool = ..., nopass: bool = ..., - passwords: Sequence[Text] | None = ..., - hashed_passwords: Sequence[Text] | None = ..., - categories: Sequence[Text] | None = ..., - commands: Sequence[Text] | None = ..., - keys: Sequence[Text] | None = ..., + passwords: Sequence[str] | None = ..., + hashed_passwords: Sequence[str] | None = ..., + categories: Sequence[str] | None = ..., + commands: Sequence[str] | None = ..., + keys: Sequence[str] | None = ..., reset: bool = ..., reset_keys: bool = ..., reset_passwords: bool = ..., @@ -863,12 +528,12 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def acl_users(self) -> Pipeline[_StrType]: ... # type: ignore[override] def acl_whoami(self) -> Pipeline[_StrType]: ... # type: ignore[override] def bgrewriteaof(self) -> Pipeline[_StrType]: ... # type: ignore[override] - def bgsave(self) -> Pipeline[_StrType]: ... # type: ignore[override] + def bgsave(self, schedule: bool = ...) -> Pipeline[_StrType]: ... # type: ignore[override] def client_id(self) -> Pipeline[_StrType]: ... # type: ignore[override] - def client_kill(self, address: Text) -> Pipeline[_StrType]: ... # type: ignore[override] + def client_kill(self, address: str) -> Pipeline[_StrType]: ... # type: ignore[override] def client_list(self) -> Pipeline[_StrType]: ... # type: ignore[override] def client_getname(self) -> Pipeline[_StrType]: ... # type: ignore[override] - def client_setname(self, name: Text) -> Pipeline[_StrType]: ... # type: ignore[override] + def client_setname(self, name: str) -> Pipeline[_StrType]: ... # type: ignore[override] def readwrite(self) -> Pipeline[_StrType]: ... # type: ignore[override] def readonly(self) -> Pipeline[_StrType]: ... # type: ignore[override] def config_get(self, pattern=...) -> Pipeline[_StrType]: ... # type: ignore[override] @@ -885,7 +550,6 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def object(self, infotype, key) -> Pipeline[_StrType]: ... # type: ignore[override] def ping(self) -> Pipeline[_StrType]: ... # type: ignore[override] def save(self) -> Pipeline[_StrType]: ... # type: ignore[override] - def sentinel(self, *args) -> None: ... def sentinel_get_master_addr_by_name(self, service_name) -> Pipeline[_StrType]: ... # type: ignore[override] def sentinel_master(self, service_name) -> Pipeline[_StrType]: ... # type: ignore[override] def sentinel_masters(self) -> Pipeline[_StrType]: ... # type: ignore[override] @@ -933,7 +597,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def randomkey(self) -> Pipeline[_StrType]: ... # type: ignore[override] def rename(self, src, dst) -> Pipeline[_StrType]: ... # type: ignore[override] def renamenx(self, src, dst) -> Pipeline[_StrType]: ... # type: ignore[override] - def restore(self, name, ttl, value, replace: bool = ...) -> Pipeline[_StrType]: ... # type: ignore[override] + def restore(self, name, ttl, value, replace: bool = ..., absttl: bool = ..., idletime: Any | None = ..., frequency: Any | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override] def set( # type: ignore[override] self, name: _Key, @@ -943,6 +607,9 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): nx: bool = ..., xx: bool = ..., keepttl: bool = ..., + get: bool = ..., + exat: Any | None = ..., + pxat: Any | None = ..., ) -> Pipeline[_StrType]: ... def __setitem__(self, name, value) -> None: ... def setbit(self, name: _Key, offset: int, value: int) -> Pipeline[_StrType]: ... # type: ignore[override] @@ -962,14 +629,14 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): self, name: _Key, where: Literal["BEFORE", "AFTER", "before", "after"], refvalue: _Value, value: _Value ) -> Pipeline[_StrType]: ... def llen(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore[override] - def lpop(self, name) -> Pipeline[_StrType]: ... # type: ignore[override] + def lpop(self, name, count: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override] def lpush(self, name: _Value, *values: _Value) -> Pipeline[_StrType]: ... # type: ignore[override] def lpushx(self, name, value) -> Pipeline[_StrType]: ... # type: ignore[override] def lrange(self, name: _Key, start: int, end: int) -> Pipeline[_StrType]: ... # type: ignore[override] def lrem(self, name: _Key, count: int, value: _Value) -> Pipeline[_StrType]: ... # type: ignore[override] def lset(self, name: _Key, index: int, value: _Value) -> Pipeline[_StrType]: ... # type: ignore[override] def ltrim(self, name: _Key, start: int, end: int) -> Pipeline[_StrType]: ... # type: ignore[override] - def rpop(self, name) -> Pipeline[_StrType]: ... # type: ignore[override] + def rpop(self, name, count: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override] def rpoplpush(self, src, dst) -> Pipeline[_StrType]: ... # type: ignore[override] def rpush(self, name: _Value, *values: _Value) -> Pipeline[_StrType]: ... # type: ignore[override] def rpushx(self, name, value) -> Pipeline[_StrType]: ... # type: ignore[override] @@ -986,10 +653,10 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): groups: bool = ..., ) -> Pipeline[_StrType]: ... def scan(self, cursor: int = ..., match: _Key | None = ..., count: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override] - def scan_iter(self, match: Text | None = ..., count: int | None = ...) -> Iterator[Any]: ... - def sscan(self, name: _Key, cursor: int = ..., match: Text = ..., count: int = ...) -> Pipeline[_StrType]: ... # type: ignore[override] + def scan_iter(self, match: str | None = ..., count: int | None = ...) -> Iterator[Any]: ... + def sscan(self, name: _Key, cursor: int = ..., match: str = ..., count: int = ...) -> Pipeline[_StrType]: ... # type: ignore[override] def sscan_iter(self, name, match=..., count=...) -> Iterator[Any]: ... - def hscan(self, name: _Key, cursor: int = ..., match: Text = ..., count: int = ...) -> Pipeline[_StrType]: ... # type: ignore[override] + def hscan(self, name: _Key, cursor: int = ..., match: str = ..., count: int = ...) -> Pipeline[_StrType]: ... # type: ignore[override] def hscan_iter(self, name, match=..., count=...) -> Iterator[Any]: ... def zscan(self, name, cursor=..., match=..., count=..., score_cast_func=...) -> Pipeline[_StrType]: ... # type: ignore[override] def zscan_iter(self, name, match=..., count=..., score_cast_func=...) -> Iterator[Any]: ... @@ -1008,7 +675,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def sunion(self, keys: _Key | Iterable[_Key], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore[override] def sunionstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore[override] def xack(self, name, groupname, *ids) -> Pipeline[_StrType]: ... # type: ignore[override] - def xadd(self, name, fields, id=..., maxlen=..., approximate=...) -> Pipeline[_StrType]: ... # type: ignore[override] + def xadd(self, name, fields, id=..., maxlen=..., approximate: bool = ..., nomkstream: bool = ..., minid: Any | None = ..., limit: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override] def xclaim( self, name, groupname, consumername, min_idle_time, message_ids, idle=..., time=..., retrycount=..., force=..., justid=... ) -> Pipeline[_StrType]: ... # type: ignore[override] @@ -1019,17 +686,25 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def xgroup_setid(self, name, groupname, id) -> Pipeline[_StrType]: ... # type: ignore[override] def xinfo_consumers(self, name, groupname) -> Pipeline[_StrType]: ... # type: ignore[override] def xinfo_groups(self, name) -> Pipeline[_StrType]: ... # type: ignore[override] - def xinfo_stream(self, name) -> Pipeline[_StrType]: ... # type: ignore[override] + def xinfo_stream(self, name, full: bool = ...) -> Pipeline[_StrType]: ... # type: ignore[override] def xlen(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore[override] def xpending(self, name, groupname) -> Pipeline[_StrType]: ... # type: ignore[override] - def xpending_range(self, name, groupname, min, max, count, consumername=...) -> Pipeline[_StrType]: ... # type: ignore[override] + def xpending_range(self, name, groupname, idle: Any | None = ..., min: int | None = ..., max: int | None = ..., count: int | None = ..., consumername=...) -> Pipeline[_StrType]: ... # type: ignore[override] def xrange(self, name, min=..., max=..., count=...) -> Pipeline[_StrType]: ... # type: ignore[override] def xread(self, streams, count=..., block=...) -> Pipeline[_StrType]: ... # type: ignore[override] def xreadgroup(self, groupname, consumername, streams, count=..., block=..., noack=...) -> Pipeline[_StrType]: ... # type: ignore[override] def xrevrange(self, name, max=..., min=..., count=...) -> Pipeline[_StrType]: ... # type: ignore[override] - def xtrim(self, name, maxlen, approximate=...) -> Pipeline[_StrType]: ... # type: ignore[override] + def xtrim(self, name, maxlen: int | None = ..., approximate: bool = ..., minid: Any | None = ..., limit: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override] def zadd( # type: ignore[override] - self, name: _Key, mapping: Mapping[_Key, _Value], nx: bool = ..., xx: bool = ..., ch: bool = ..., incr: bool = ... + self, + name: _Key, + mapping: Mapping[_Key, _Value], + nx: bool = ..., + xx: bool = ..., + ch: bool = ..., + incr: bool = ..., + gt: Any | None = ..., + lt: Any | None = ..., ) -> Pipeline[_StrType]: ... def zcard(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore[override] def zcount(self, name: _Key, min: _Value, max: _Value) -> Pipeline[_StrType]: ... # type: ignore[override] @@ -1048,6 +723,10 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): desc: bool = ..., withscores: bool = ..., score_cast_func: Callable[[Any], Any] = ..., + byscore: bool = ..., + bylex: bool = ..., + offset: int | None = ..., + num: int | None = ..., ) -> Pipeline[_StrType]: ... def zrangebylex(self, name: _Key, min: _Value, max: _Value, start: int | None = ..., num: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override] def zrangebyscore( # type: ignore[override] @@ -1115,10 +794,10 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): def eval(self, script, numkeys, *keys_and_args) -> Pipeline[_StrType]: ... # type: ignore[override] def evalsha(self, sha, numkeys, *keys_and_args) -> Pipeline[_StrType]: ... # type: ignore[override] def script_exists(self, *args) -> Pipeline[_StrType]: ... # type: ignore[override] - def script_flush(self) -> Pipeline[_StrType]: ... # type: ignore[override] + 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: Text | _StrType) -> Script: ... + 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] @@ -1137,5 +816,5 @@ class Monitor(object): def __init__(self, connection_pool) -> None: ... def __enter__(self) -> Monitor: ... def __exit__(self, *args: Any) -> None: ... - def next_command(self) -> dict[Text, Any]: ... - def listen(self) -> Iterable[dict[Text, Any]]: ... + def next_command(self) -> dict[str, Any]: ... + def listen(self) -> Iterable[dict[str, Any]]: ... diff --git a/stubs/redis/redis/commands/__init__.pyi b/stubs/redis/redis/commands/__init__.pyi new file mode 100644 index 000000000000..3debade74407 --- /dev/null +++ b/stubs/redis/redis/commands/__init__.pyi @@ -0,0 +1,6 @@ +from .core import CoreCommands as CoreCommands +from .helpers import list_or_args as list_or_args +from .redismodules import RedisModuleCommands as RedisModuleCommands +from .sentinel import SentinelCommands as SentinelCommands + +__all__ = ["CoreCommands", "RedisModuleCommands", "SentinelCommands", "list_or_args"] diff --git a/stubs/redis/redis/commands/core.pyi b/stubs/redis/redis/commands/core.pyi new file mode 100644 index 000000000000..31db56fabedd --- /dev/null +++ b/stubs/redis/redis/commands/core.pyi @@ -0,0 +1,266 @@ +from collections.abc import Callable, Iterable, Mapping, Sequence +from datetime import timedelta +from typing import Any, Generic, TypeVar, Union, overload +from typing_extensions import Literal + +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: ... + def acl_setuser( + self, + username: str, + enabled: bool = ..., + nopass: bool = ..., + passwords: Sequence[str] | None = ..., + hashed_passwords: Sequence[str] | None = ..., + categories: Sequence[str] | None = ..., + commands: Sequence[str] | None = ..., + keys: Sequence[str] | None = ..., + reset: bool = ..., + reset_keys: bool = ..., + reset_passwords: bool = ..., + ) -> bool: ... + def acl_users(self) -> list[str]: ... + def acl_whoami(self) -> str: ... + 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: Any | None = ..., client_id=...) -> list[dict[str, str]]: ... + def client_getname(self) -> str | None: ... + def client_setname(self, name: str) -> 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 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 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, + value: _Value, + ex: None | int | timedelta = ..., + px: None | int | timedelta = ..., + nx: bool = ..., + xx: bool = ..., + keepttl: bool = ..., + get: bool = ..., + exat: Any | None = ..., + pxat: Any | None = ..., + ) -> bool | None: ... + def xack(self, name, groupname, *ids): ... + def xadd( + self, + name, + fields, + id: str = ..., + maxlen=..., + approximate: bool = ..., + nomkstream: bool = ..., + minid: Any | None = ..., + limit: Any | None = ..., + ): ... + 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_delconsumer(self, name, groupname, consumername): ... + def xgroup_destroy(self, name, groupname): ... + def xgroup_setid(self, name, groupname, id): ... + def xinfo_consumers(self, name, groupname): ... + def xinfo_groups(self, name): ... + def xinfo_stream(self, name, full: bool = ...): ... + def xlen(self, name: _Key) -> int: ... + def xpending(self, name, groupname): ... + def xpending_range( + self, + name, + groupname, + idle: Any | None = ..., + min: Any | None = ..., + max: Any | None = ..., + 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 xtrim( + self, name, maxlen: Any | None = ..., approximate: bool = ..., minid: Any | None = ..., limit: Any | None = ... + ): ... + def zadd( + self, + name: _Key, + mapping: Mapping[_Key, _Value], + nx: bool = ..., + xx: bool = ..., + ch: bool = ..., + incr: bool = ..., + gt: Any | None = ..., + lt: Any | None = ..., + ) -> int: ... + def zcard(self, name: _Key) -> int: ... + def zcount(self, name: _Key, min: _Value, max: _Value) -> int: ... + def zincrby(self, name: _Key, amount: float, value: _Value) -> float: ... + 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[_StrType]: ... + def zpopmin(self, name: _Key, count: int | None = ...) -> list[_StrType]: ... + @overload + def bzpopmax(self, keys: _Key | Iterable[_Key], timeout: Literal[0] = ...) -> tuple[_StrType, _StrType, float]: ... + @overload + def bzpopmax(self, keys: _Key | Iterable[_Key], timeout: float) -> tuple[_StrType, _StrType, float] | None: ... + @overload + def bzpopmin(self, keys: _Key | Iterable[_Key], timeout: Literal[0] = ...) -> tuple[_StrType, _StrType, float]: ... + @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, + start: int, + end: int, + desc: bool = ..., + withscores: bool = ..., + score_cast_func: Callable[[Any], Any] = ..., + byscore: bool = ..., + bylex: bool = ..., + offset: int | None = ..., + num: int | None = ..., + ) -> list[_StrType]: ... + def zrangebylex( + self, name: _Key, min: _Value, max: _Value, start: int | None = ..., num: int | None = ... + ) -> list[_StrType]: ... + @overload + def zrangebyscore( + self, + name: _Key, + min: _Value, + max: _Value, + start: int | None = ..., + num: int | None = ..., + *, + withscores: Literal[True], + score_cast_func: Callable[[float], _ScoreCastFuncReturn] = ..., + ) -> list[tuple[_StrType, _ScoreCastFuncReturn]]: ... + @overload + def zrangebyscore( + self, + name: _Key, + min: _Value, + max: _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 zunionstore(self, dest: _Key, keys: Iterable[_Key], aggregate: Literal["SUM", "MIN", "MAX"] | None = ...) -> int: ... + def script_exists(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 Script: + def __init__(self, registered_client, script) -> None: ... + def __call__(self, keys=..., args=..., client: Any | None = ...): ... + +class BitFieldOperation: + def __init__(self, client, key, default_overflow: Any | None = ...): ... + def reset(self) -> None: ... + def overflow(self, overflow): ... + def incrby(self, fmt, offset, increment, overflow: Any | None = ...): ... + def get(self, fmt, offset): ... + def set(self, fmt, offset, value): ... + @property + def command(self): ... + def execute(self): ... diff --git a/stubs/redis/redis/commands/helpers.pyi b/stubs/redis/redis/commands/helpers.pyi new file mode 100644 index 000000000000..231306845749 --- /dev/null +++ b/stubs/redis/redis/commands/helpers.pyi @@ -0,0 +1,6 @@ +def list_or_args(keys, args): ... +def nativestr(x): ... +def delist(x): ... +def parse_to_list(response): ... +def random_string(length: int = ...) -> str: ... +def quote_string(v): ... diff --git a/stubs/redis/redis/commands/json/__init__.pyi b/stubs/redis/redis/commands/json/__init__.pyi new file mode 100644 index 000000000000..71db9fb68aa0 --- /dev/null +++ b/stubs/redis/redis/commands/json/__init__.pyi @@ -0,0 +1,14 @@ +from typing import Any + +from ...client import Pipeline as ClientPipeline +from .commands import JSONCommands + +class JSON(JSONCommands): + MODULE_CALLBACKS: dict[str, Any] + client: Any + execute_command: Any + MODULE_VERSION: Any | None + def __init__(self, client, version: Any | None = ..., decoder=..., encoder=...) -> None: ... + def pipeline(self, transaction: bool = ..., shard_hint: Any | None = ...) -> Pipeline: ... + +class Pipeline(JSONCommands, ClientPipeline): ... # type: ignore diff --git a/stubs/redis/redis/commands/json/commands.pyi b/stubs/redis/redis/commands/json/commands.pyi new file mode 100644 index 000000000000..e3bdc25a5ab3 --- /dev/null +++ b/stubs/redis/redis/commands/json/commands.pyi @@ -0,0 +1,28 @@ +from typing import Any + +class JSONCommands: + def arrappend(self, name, path=..., *args): ... + def arrindex(self, name, path, scalar, start: int = ..., stop: int = ...): ... + def arrinsert(self, name, path, index, *args): ... + def arrlen(self, name, path=...): ... + def arrpop(self, name, path=..., index: int = ...): ... + def arrtrim(self, name, path, start, stop): ... + def type(self, name, path=...): ... + def resp(self, name, path=...): ... + def objkeys(self, name, path=...): ... + def objlen(self, name, path=...): ... + def numincrby(self, name, path, number): ... + def nummultby(self, name, path, number): ... + def clear(self, name, path=...): ... + def delete(self, key, path=...): ... + forget = delete + 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 strlen(self, name, path: Any | None = ...): ... + def toggle(self, name, path=...): ... + def strappend(self, name, value, path=...): ... + def debug(self, subcommand, key: Any | None = ..., path=...): ... + def jsonget(self, *args, **kwargs): ... + def jsonmget(self, *args, **kwargs): ... + def jsonset(self, *args, **kwargs): ... diff --git a/stubs/redis/redis/commands/json/decoders.pyi b/stubs/redis/redis/commands/json/decoders.pyi new file mode 100644 index 000000000000..ccea24386cb4 --- /dev/null +++ b/stubs/redis/redis/commands/json/decoders.pyi @@ -0,0 +1,4 @@ +def bulk_of_jsons(d): ... +def decode_dict_keys(obj): ... +def unstring(obj): ... +def decode_list(b): ... diff --git a/stubs/redis/redis/commands/json/path.pyi b/stubs/redis/redis/commands/json/path.pyi new file mode 100644 index 000000000000..d33df3045bea --- /dev/null +++ b/stubs/redis/redis/commands/json/path.pyi @@ -0,0 +1,5 @@ +class Path: + strPath: str + @staticmethod + def rootPath() -> str: ... + def __init__(self, path: str) -> None: ... diff --git a/stubs/redis/redis/commands/redismodules.pyi b/stubs/redis/redis/commands/redismodules.pyi new file mode 100644 index 000000000000..9f807c99327a --- /dev/null +++ b/stubs/redis/redis/commands/redismodules.pyi @@ -0,0 +1,8 @@ +from .json import JSON +from .search import Search +from .timeseries import TimeSeries + +class RedisModuleCommands: + def json(self, encoder=..., decoder=...) -> JSON: ... + def ft(self, index_name: str = ...) -> Search: ... + def ts(self) -> TimeSeries: ... diff --git a/stubs/redis/redis/commands/search/__init__.pyi b/stubs/redis/redis/commands/search/__init__.pyi new file mode 100644 index 000000000000..b08ea3713083 --- /dev/null +++ b/stubs/redis/redis/commands/search/__init__.pyi @@ -0,0 +1,21 @@ +from typing import Any + +from .commands import SearchCommands + +class Search(SearchCommands): + class BatchIndexer: + def __init__(self, client, chunk_size: int = ...) -> None: ... + def add_document( + self, + doc_id, + nosave: bool = ..., + score: float = ..., + payload: Any | None = ..., + replace: bool = ..., + partial: bool = ..., + no_create: bool = ..., + **fields, + ): ... + def add_document_hash(self, doc_id, score: float = ..., replace: bool = ...): ... + def commit(self): ... + def __init__(self, client, index_name: str = ...) -> None: ... diff --git a/stubs/redis/redis/commands/search/commands.pyi b/stubs/redis/redis/commands/search/commands.pyi new file mode 100644 index 000000000000..459376b5f552 --- /dev/null +++ b/stubs/redis/redis/commands/search/commands.pyi @@ -0,0 +1,92 @@ +from typing import Any +from typing_extensions import Literal + +NUMERIC: Literal["NUMERIC"] + +CREATE_CMD: Literal["FT.CREATE"] +ALTER_CMD: Literal["FT.ALTER"] +SEARCH_CMD: Literal["FT.SEARCH"] +ADD_CMD: Literal["FT.ADD"] +ADDHASH_CMD: Literal["FT.ADDHASH"] +DROP_CMD: Literal["FT.DROP"] +EXPLAIN_CMD: Literal["FT.EXPLAIN"] +EXPLAINCLI_CMD: Literal["FT.EXPLAINCLI"] +DEL_CMD: Literal["FT.DEL"] +AGGREGATE_CMD: Literal["FT.AGGREGATE"] +CURSOR_CMD: Literal["FT.CURSOR"] +SPELLCHECK_CMD: Literal["FT.SPELLCHECK"] +DICT_ADD_CMD: Literal["FT.DICTADD"] +DICT_DEL_CMD: Literal["FT.DICTDEL"] +DICT_DUMP_CMD: Literal["FT.DICTDUMP"] +GET_CMD: Literal["FT.GET"] +MGET_CMD: Literal["FT.MGET"] +CONFIG_CMD: Literal["FT.CONFIG"] +TAGVALS_CMD: Literal["FT.TAGVALS"] +ALIAS_ADD_CMD: Literal["FT.ALIASADD"] +ALIAS_UPDATE_CMD: Literal["FT.ALIASUPDATE"] +ALIAS_DEL_CMD: Literal["FT.ALIASDEL"] +INFO_CMD: Literal["FT.INFO"] +SUGADD_COMMAND: Literal["FT.SUGADD"] +SUGDEL_COMMAND: Literal["FT.SUGDEL"] +SUGLEN_COMMAND: Literal["FT.SUGLEN"] +SUGGET_COMMAND: Literal["FT.SUGGET"] +SYNUPDATE_CMD: Literal["FT.SYNUPDATE"] +SYNDUMP_CMD: Literal["FT.SYNDUMP"] + +NOOFFSETS: Literal["NOOFFSETS"] +NOFIELDS: Literal["NOFIELDS"] +STOPWORDS: Literal["STOPWORDS"] +WITHSCORES: Literal["WITHSCORES"] +FUZZY: Literal["FUZZY"] +WITHPAYLOADS: Literal["WITHPAYLOADS"] + +class SearchCommands: + def batch_indexer(self, chunk_size: int = ...): ... + def create_index( + self, + fields, + no_term_offsets: bool = ..., + no_field_flags: bool = ..., + stopwords: Any | None = ..., + 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, + doc_id, + nosave: bool = ..., + score: float = ..., + payload: Any | None = ..., + replace: bool = ..., + partial: bool = ..., + language: Any | None = ..., + no_create: bool = ..., + **fields, + ): ... + def add_document_hash(self, doc_id, score: float = ..., language: Any | None = ..., replace: bool = ...): ... + def delete_document(self, doc_id, conn: Any | None = ..., delete_actual_document: bool = ...): ... + def load_document(self, id): ... + def get(self, *ids): ... + def info(self): ... + def search(self, query): ... + def explain(self, query): ... + def explain_cli(self, query): ... + def aggregate(self, query): ... + 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): ... + def dict_dump(self, name): ... + def config_set(self, option, value): ... + def config_get(self, option): ... + def tagvals(self, tagfield): ... + def aliasadd(self, alias): ... + def aliasupdate(self, alias): ... + def aliasdel(self, alias): ... + def sugadd(self, key, *suggestions, **kwargs): ... + def suglen(self, key): ... + def sugdel(self, key, string): ... + def sugget(self, key, prefix, fuzzy: bool = ..., num: int = ..., with_scores: bool = ..., with_payloads: bool = ...): ... + def synupdate(self, groupid, skipinitial: bool = ..., *terms): ... + def syndump(self): ... diff --git a/stubs/redis/redis/commands/sentinel.pyi b/stubs/redis/redis/commands/sentinel.pyi new file mode 100644 index 000000000000..545642fac979 --- /dev/null +++ b/stubs/redis/redis/commands/sentinel.pyi @@ -0,0 +1,14 @@ +class SentinelCommands: + def sentinel(self, *args): ... + def sentinel_get_master_addr_by_name(self, service_name): ... + def sentinel_master(self, service_name): ... + def sentinel_masters(self): ... + def sentinel_monitor(self, name, ip, port, quorum): ... + def sentinel_remove(self, name): ... + def sentinel_sentinels(self, service_name): ... + def sentinel_set(self, name, option, value): ... + def sentinel_slaves(self, service_name): ... + def sentinel_reset(self, pattern): ... + def sentinel_failover(self, new_master_name): ... + def sentinel_ckquorum(self, new_master_name): ... + def sentinel_flushconfig(self): ... diff --git a/stubs/redis/redis/commands/timeseries/__init__.pyi b/stubs/redis/redis/commands/timeseries/__init__.pyi new file mode 100644 index 000000000000..588fc2a5fb9c --- /dev/null +++ b/stubs/redis/redis/commands/timeseries/__init__.pyi @@ -0,0 +1,13 @@ +from typing import Any + +from ...client import Pipeline as ClientPipeline +from .commands import TimeSeriesCommands + +class TimeSeries(TimeSeriesCommands): + MODULE_CALLBACKS: dict[str, Any] + client: Any + execute_command: Any + def __init__(self, client: Any | None = ..., **kwargs) -> None: ... + def pipeline(self, transaction: bool = ..., shard_hint: Any | None = ...) -> Pipeline: ... + +class Pipeline(TimeSeriesCommands, ClientPipeline): ... # type: ignore diff --git a/stubs/redis/redis/commands/timeseries/commands.pyi b/stubs/redis/redis/commands/timeseries/commands.pyi new file mode 100644 index 000000000000..4a5a19af17ba --- /dev/null +++ b/stubs/redis/redis/commands/timeseries/commands.pyi @@ -0,0 +1,95 @@ +from typing import Any +from typing_extensions import Literal + +ADD_CMD: Literal["TS.ADD"] +ALTER_CMD: Literal["TS.ALTER"] +CREATERULE_CMD: Literal["TS.CREATERULE"] +CREATE_CMD: Literal["TS.CREATE"] +DECRBY_CMD: Literal["TS.DECRBY"] +DELETERULE_CMD: Literal["TS.DELETERULE"] +DEL_CMD: Literal["TS.DEL"] +GET_CMD: Literal["TS.GET"] +INCRBY_CMD: Literal["TS.INCRBY"] +INFO_CMD: Literal["TS.INFO"] +MADD_CMD: Literal["TS.MADD"] +MGET_CMD: Literal["TS.MGET"] +MRANGE_CMD: Literal["TS.MRANGE"] +MREVRANGE_CMD: Literal["TS.MREVRANGE"] +QUERYINDEX_CMD: Literal["TS.QUERYINDEX"] +RANGE_CMD: Literal["TS.RANGE"] +REVRANGE_CMD: Literal["TS.REVRANGE"] + +class TimeSeriesCommands: + def create(self, key, **kwargs): ... + def alter(self, key, **kwargs): ... + def add(self, key, timestamp, value, **kwargs): ... + def madd(self, ktv_tuples): ... + def incrby(self, key, value, **kwargs): ... + def decrby(self, key, value, **kwargs): ... + def delete(self, key, from_time, to_time): ... + def createrule(self, source_key, dest_key, aggregation_type, bucket_size_msec): ... + def deleterule(self, source_key, dest_key): ... + def range( + self, + key, + from_time, + to_time, + count: Any | None = ..., + aggregation_type: Any | None = ..., + bucket_size_msec: int = ..., + filter_by_ts: Any | None = ..., + filter_by_min_value: Any | None = ..., + filter_by_max_value: Any | None = ..., + align: Any | None = ..., + ): ... + def revrange( + self, + key, + from_time, + to_time, + count: Any | None = ..., + aggregation_type: Any | None = ..., + bucket_size_msec: int = ..., + filter_by_ts: Any | None = ..., + filter_by_min_value: Any | None = ..., + filter_by_max_value: Any | None = ..., + align: Any | None = ..., + ): ... + def mrange( + self, + from_time, + to_time, + filters, + count: Any | None = ..., + aggregation_type: Any | None = ..., + bucket_size_msec: int = ..., + with_labels: bool = ..., + filter_by_ts: Any | None = ..., + filter_by_min_value: Any | None = ..., + filter_by_max_value: Any | None = ..., + groupby: Any | None = ..., + reduce: Any | None = ..., + select_labels: Any | None = ..., + align: Any | None = ..., + ): ... + def mrevrange( + self, + from_time, + to_time, + filters, + count: Any | None = ..., + aggregation_type: Any | None = ..., + bucket_size_msec: int = ..., + with_labels: bool = ..., + filter_by_ts: Any | None = ..., + filter_by_min_value: Any | None = ..., + filter_by_max_value: Any | None = ..., + groupby: Any | None = ..., + reduce: Any | None = ..., + select_labels: Any | None = ..., + align: Any | None = ..., + ): ... + def get(self, key): ... + def mget(self, filters, with_labels: bool = ...): ... + def info(self, key): ... + def queryindex(self, filters): ... diff --git a/stubs/redis/redis/commands/timeseries/info.pyi b/stubs/redis/redis/commands/timeseries/info.pyi new file mode 100644 index 000000000000..425dd29d5024 --- /dev/null +++ b/stubs/redis/redis/commands/timeseries/info.pyi @@ -0,0 +1,17 @@ +from typing import Any + +class TSInfo: + rules: list[Any] + labels: list[Any] + sourceKey: Any | None + chunk_count: Any | None + memory_usage: Any | None + total_samples: Any | None + retention_msecs: Any | None + last_time_stamp: Any | None + first_time_stamp: Any | None + + max_samples_per_chunk: Any | None + chunk_size: Any | None + duplicate_policy: Any | None + def __init__(self, args) -> None: ... diff --git a/stubs/redis/redis/commands/timeseries/utils.pyi b/stubs/redis/redis/commands/timeseries/utils.pyi new file mode 100644 index 000000000000..4a0d52c4d5cc --- /dev/null +++ b/stubs/redis/redis/commands/timeseries/utils.pyi @@ -0,0 +1,5 @@ +def list_to_dict(aList): ... +def parse_range(response): ... +def parse_m_range(response): ... +def parse_get(response): ... +def parse_m_get(response): ... diff --git a/stubs/redis/redis/connection.pyi b/stubs/redis/redis/connection.pyi index 3ace17aded01..438cc375040d 100644 --- a/stubs/redis/redis/connection.pyi +++ b/stubs/redis/redis/connection.pyi @@ -1,4 +1,6 @@ -from typing import Any, Mapping, Text, Type +from typing import Any, Mapping, Type + +from .retry import Retry ssl_available: Any hiredis_version: Any @@ -53,8 +55,8 @@ DefaultParser: Any class Encoder: def __init__(self, encoding, encoding_errors, decode_responses: bool) -> None: ... - def encode(self, value: Text | bytes | memoryview | bool | float) -> bytes: ... - def decode(self, value: Text | bytes | memoryview, force: bool = ...) -> Text: ... + def encode(self, value: str | bytes | memoryview | bool | float) -> bytes: ... + def decode(self, value: str | bytes | memoryview, force: bool = ...) -> str: ... class Connection: description_format: Any @@ -71,26 +73,28 @@ class Connection: encoding: Any encoding_errors: Any decode_responses: Any + retry: Retry def __init__( self, - host: Text = ..., + host: str = ..., port: int = ..., db: int = ..., - password: Text | None = ..., + password: str | None = ..., socket_timeout: float | None = ..., socket_connect_timeout: float | None = ..., socket_keepalive: bool = ..., socket_keepalive_options: Mapping[str, int | str] | None = ..., socket_type: int = ..., retry_on_timeout: bool = ..., - encoding: Text = ..., - encoding_errors: Text = ..., + encoding: str = ..., + encoding_errors: str = ..., decode_responses: bool = ..., parser_class: Type[BaseParser] = ..., socket_read_size: int = ..., health_check_interval: int = ..., - client_name: Text | None = ..., - username: Text | None = ..., + client_name: str | None = ..., + username: str | None = ..., + retry: Retry | None = ..., ) -> None: ... def __del__(self): ... def register_connect_callback(self, callback): ... @@ -105,7 +109,7 @@ class Connection: def read_response(self): ... def pack_command(self, *args): ... def pack_commands(self, commands): ... - def repr_pieces(self) -> list[tuple[Text, Text]]: ... + def repr_pieces(self) -> list[tuple[str, str]]: ... class SSLConnection(Connection): description_format: Any @@ -128,6 +132,7 @@ class UnixDomainSocketConnection(Connection): encoding: Any encoding_errors: Any decode_responses: Any + retry: Retry def __init__( self, path=..., @@ -135,22 +140,23 @@ class UnixDomainSocketConnection(Connection): username=..., password=..., socket_timeout=..., - encoding=..., - encoding_errors=..., - decode_responses=..., - retry_on_timeout=..., + encoding: str = ..., + encoding_errors: str = ..., + decode_responses: bool = ..., + retry_on_timeout: bool = ..., parser_class=..., socket_read_size: int = ..., health_check_interval: int = ..., client_name=..., + retry: Retry | None = ..., ) -> None: ... - def repr_pieces(self) -> list[tuple[Text, Text]]: ... + def repr_pieces(self) -> list[tuple[str, str]]: ... def to_bool(value: object) -> bool: ... class ConnectionPool: @classmethod - def from_url(cls, url: Text, db: int | None = ..., decode_components: bool = ..., **kwargs) -> ConnectionPool: ... + def from_url(cls, url: str, *, db: int = ..., decode_components: bool = ..., **kwargs) -> ConnectionPool: ... connection_class: Any connection_kwargs: Any max_connections: Any diff --git a/stubs/redis/redis/lock.pyi b/stubs/redis/redis/lock.pyi index 23ed04fca073..8d8b537f2fe3 100644 --- a/stubs/redis/redis/lock.pyi +++ b/stubs/redis/redis/lock.pyi @@ -1,13 +1,11 @@ from types import TracebackType -from typing import Any, Text, Type, Union +from typing import Any, Type from typing_extensions import Protocol from redis.client import Redis -_TokenValue = Union[bytes, Text] - class _Local(Protocol): - token: _TokenValue | None + token: str | bytes | None class Lock: local: _Local @@ -27,13 +25,13 @@ class Lock: self, exc_type: Type[BaseException] | None, exc_value: BaseException | None, traceback: TracebackType | None ) -> bool | None: ... def acquire( - self, blocking: bool | None = ..., blocking_timeout: None | int | float = ..., token: _TokenValue | None = ... + self, blocking: bool | None = ..., blocking_timeout: None | int | float = ..., token: str | bytes | None = ... ) -> bool: ... - def do_acquire(self, token: _TokenValue) -> bool: ... + def do_acquire(self, token: str | bytes) -> bool: ... def locked(self) -> bool: ... def owned(self) -> bool: ... def release(self) -> None: ... - def do_release(self, expected_token: _TokenValue) -> None: ... + def do_release(self, expected_token: str | bytes) -> None: ... def extend(self, additional_time: int | float, replace_ttl: bool = ...) -> bool: ... def do_extend(self, additional_time: int | float, replace_ttl: bool) -> bool: ... def reacquire(self) -> bool: ... diff --git a/stubs/redis/redis/retry.pyi b/stubs/redis/redis/retry.pyi new file mode 100644 index 000000000000..3182bf5bc37c --- /dev/null +++ b/stubs/redis/redis/retry.pyi @@ -0,0 +1,3 @@ +class Retry: + def __init__(self, backoff, retries, supported_errors=...) -> None: ... + def call_with_retry(self, do, fail): ... diff --git a/stubs/redis/redis/utils.pyi b/stubs/redis/redis/utils.pyi index aa0e827f2e1e..337350b51512 100644 --- a/stubs/redis/redis/utils.pyi +++ b/stubs/redis/redis/utils.pyi @@ -1,4 +1,5 @@ -from typing import Any, ContextManager, Text, TypeVar, overload +from contextlib import AbstractContextManager +from typing import Any, TypeVar, overload from typing_extensions import Literal from .client import Pipeline, Redis, _StrType @@ -8,14 +9,12 @@ _T = TypeVar("_T") HIREDIS_AVAILABLE: bool @overload -def from_url(url: Text, db: int | None = ..., *, decode_responses: Literal[True], **kwargs: Any) -> Redis[str]: ... +def from_url(url: str, *, db: int = ..., decode_responses: Literal[True], **kwargs: Any) -> Redis[str]: ... @overload -def from_url(url: Text, db: int | None = ..., *, decode_responses: Literal[False] = ..., **kwargs: Any) -> Redis[bytes]: ... +def from_url(url: str, *, db: int = ..., decode_responses: Literal[False] = ..., **kwargs: Any) -> Redis[bytes]: ... +def pipeline(redis_obj: Redis[_StrType]) -> AbstractContextManager[Pipeline[_StrType]]: ... @overload def str_if_bytes(value: bytes) -> str: ... # type: ignore @overload def str_if_bytes(value: _T) -> _T: ... def safe_str(value: object) -> str: ... -def pipeline(redis_obj: Redis[_StrType]) -> ContextManager[Pipeline[_StrType]]: ... - -class dummy: ...