From 605378de6e80c90b39b97c183acbb48a5236fc89 Mon Sep 17 00:00:00 2001 From: Juan Amari <11861490+juanamari94@users.noreply.github.com> Date: Thu, 5 Jan 2023 12:25:11 -0300 Subject: [PATCH] Bump redis to 4.4.0 (#9458) Co-authored-by: AlexWaygood --- stubs/redis/METADATA.toml | 2 +- stubs/redis/redis/asyncio/client.pyi | 7 ++++-- stubs/redis/redis/asyncio/connection.pyi | 31 ++++++------------------ stubs/redis/redis/asyncio/sentinel.pyi | 2 +- stubs/redis/redis/backoff.pyi | 8 +++--- stubs/redis/redis/client.pyi | 4 +++ stubs/redis/redis/cluster.pyi | 3 ++- stubs/redis/redis/commands/core.pyi | 6 ++--- stubs/redis/redis/connection.pyi | 3 +++ stubs/redis/redis/credentials.pyi | 11 +++++++++ 10 files changed, 41 insertions(+), 36 deletions(-) create mode 100644 stubs/redis/redis/credentials.pyi diff --git a/stubs/redis/METADATA.toml b/stubs/redis/METADATA.toml index b94ebe27b..3fbcc09f5 100644 --- a/stubs/redis/METADATA.toml +++ b/stubs/redis/METADATA.toml @@ -1 +1 @@ -version = "4.3.5" +version = "4.4.0" diff --git a/stubs/redis/redis/asyncio/client.pyi b/stubs/redis/redis/asyncio/client.pyi index 3aa9d0bd6..1e32b3c3f 100644 --- a/stubs/redis/redis/asyncio/client.pyi +++ b/stubs/redis/redis/asyncio/client.pyi @@ -10,7 +10,8 @@ from redis.asyncio.lock import Lock from redis.asyncio.retry import Retry from redis.client import AbstractRedis, _CommandOptions, _Key, _StrType, _Value from redis.commands import AsyncCoreCommands, AsyncSentinelCommands, RedisModuleCommands -from redis.typing import ChannelT, EncodableT, KeyT, PatternT +from redis.credentials import CredentialProvider +from redis.typing import ChannelT, EncodableT, KeyT, PatternT, StreamIdT PubSubHandler: TypeAlias = Callable[[dict[str, str]], Awaitable[None]] @@ -63,6 +64,7 @@ class Redis(AbstractRedis, RedisModuleCommands, AsyncCoreCommands[_StrType], Asy retry: Retry | None = ..., auto_close_connection_pool: bool = ..., redis_connect_func: ConnectCallbackT | None = ..., + credential_provider: CredentialProvider | None = ..., ) -> None: ... def __await__(self): ... async def initialize(self: Self) -> Self: ... @@ -82,6 +84,7 @@ class Redis(AbstractRedis, RedisModuleCommands, AsyncCoreCommands[_StrType], Asy name: KeyT, timeout: float | None = ..., sleep: float = ..., + blocking: bool = ..., blocking_timeout: float | None = ..., lock_class: type[Lock] | None = ..., thread_local: bool = ..., @@ -586,7 +589,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): groupname, consumername, min_idle_time, - start_id: int = ..., + start_id: StreamIdT = ..., count: Incomplete | None = ..., justid: bool = ..., ) -> Any: ... diff --git a/stubs/redis/redis/asyncio/connection.pyi b/stubs/redis/redis/asyncio/connection.pyi index 44eb4f75f..ceae18ba9 100644 --- a/stubs/redis/redis/asyncio/connection.pyi +++ b/stubs/redis/redis/asyncio/connection.pyi @@ -3,16 +3,15 @@ import enum import ssl from collections.abc import Callable, Iterable, Mapping from typing import Any, Protocol -from typing_extensions import TypeAlias, TypedDict +from typing_extensions import Literal, TypeAlias, TypedDict from redis import RedisError from redis.asyncio.retry import Retry +from redis.credentials import CredentialProvider from redis.exceptions import ResponseError from redis.typing import EncodableT, EncodedT hiredis: Any -NONBLOCKING_EXCEPTION_ERROR_NUMBERS: Any -NONBLOCKING_EXCEPTIONS: Any SYM_STAR: bytes SYM_DOLLAR: bytes SYM_CRLF: bytes @@ -46,37 +45,20 @@ class BaseParser: def parse_error(self, response: str) -> ResponseError: ... def on_disconnect(self) -> None: ... def on_connect(self, connection: Connection): ... - async def can_read(self, timeout: float) -> bool: ... async def read_response(self, disable_decoding: bool = ...) -> EncodableT | ResponseError | list[EncodableT] | None: ... -class SocketBuffer: - socket_read_size: Any - socket_timeout: Any - bytes_written: int - bytes_read: int - def __init__(self, stream_reader: asyncio.StreamReader, socket_read_size: int, socket_timeout: float | None) -> None: ... - @property - def length(self): ... - async def can_read(self, timeout: float) -> bool: ... - async def read(self, length: int) -> bytes: ... - async def readline(self) -> bytes: ... - def purge(self) -> None: ... - def close(self) -> None: ... - class PythonParser(BaseParser): encoder: Any def __init__(self, socket_read_size: int) -> None: ... def on_connect(self, connection: Connection): ... def on_disconnect(self) -> None: ... - async def can_read(self, timeout: float): ... async def read_response(self, disable_decoding: bool = ...) -> EncodableT | ResponseError | None: ... class HiredisParser(BaseParser): def __init__(self, socket_read_size: int) -> None: ... def on_connect(self, connection: Connection): ... def on_disconnect(self) -> None: ... - async def can_read(self, timeout: float): ... - async def read_from_socket(self, timeout: float | None | _Sentinel = ..., raise_on_timeout: bool = ...): ... + async def read_from_socket(self) -> Literal[True]: ... async def read_response(self, disable_decoding: bool = ...) -> EncodableT | list[EncodableT]: ... DefaultParser: type[PythonParser | HiredisParser] @@ -135,6 +117,7 @@ class Connection: retry: Retry | None = ..., redis_connect_func: ConnectCallbackT | None = ..., encoder_class: type[Encoder] = ..., + credential_provider: CredentialProvider | None = ..., ) -> None: ... def repr_pieces(self): ... def __del__(self) -> None: ... @@ -145,12 +128,11 @@ class Connection: def set_parser(self, parser_class) -> None: ... async def connect(self) -> None: ... async def on_connect(self) -> None: ... - async def disconnect(self) -> None: ... + async def disconnect(self, nowait: bool = ...) -> None: ... async def check_health(self) -> None: ... async def send_packed_command(self, command: bytes | str | Iterable[bytes], check_health: bool = ...): ... async def send_command(self, *args, **kwargs) -> None: ... - async def can_read(self, timeout: float = ...): ... - async def read_response(self, disable_decoding: bool = ...): ... + async def read_response(self, disable_decoding: bool = ..., timeout: float | None = ...): ... def pack_command(self, *args: EncodableT) -> list[bytes]: ... def pack_commands(self, commands: Iterable[Iterable[EncodableT]]) -> list[bytes]: ... @@ -234,6 +216,7 @@ class UnixDomainSocketConnection(Connection): client_name: str | None = ..., retry: Retry | None = ..., redis_connect_func: ConnectCallbackT | None = ..., + credential_provider: CredentialProvider | None = ..., ) -> None: ... def repr_pieces(self) -> Iterable[tuple[str, str | int]]: ... diff --git a/stubs/redis/redis/asyncio/sentinel.pyi b/stubs/redis/redis/asyncio/sentinel.pyi index 59b31e0c5..d0070816a 100644 --- a/stubs/redis/redis/asyncio/sentinel.pyi +++ b/stubs/redis/redis/asyncio/sentinel.pyi @@ -15,7 +15,7 @@ class SentinelManagedConnection(Connection): def __init__(self, **kwargs) -> None: ... async def connect_to(self, address) -> None: ... async def connect(self): ... - async def read_response(self, disable_decoding: bool = ...): ... + async def read_response(self, disable_decoding: bool = ...): ... # type: ignore[override] class SentinelManagedSSLConnection(SentinelManagedConnection, SSLConnection): ... diff --git a/stubs/redis/redis/backoff.pyi b/stubs/redis/redis/backoff.pyi index 643c0bceb..03b559e5b 100644 --- a/stubs/redis/redis/backoff.pyi +++ b/stubs/redis/redis/backoff.pyi @@ -13,17 +13,17 @@ class NoBackoff(ConstantBackoff): def __init__(self) -> None: ... class ExponentialBackoff(AbstractBackoff): - def __init__(self, cap: float, base: float) -> None: ... + def __init__(self, cap: float = ..., base: float = ...) -> None: ... def compute(self, failures: int) -> float: ... class FullJitterBackoff(AbstractBackoff): - def __init__(self, cap: float, base: float) -> None: ... + def __init__(self, cap: float = ..., base: float = ...) -> None: ... def compute(self, failures: int) -> float: ... class EqualJitterBackoff(AbstractBackoff): - def __init__(self, cap: float, base: float) -> None: ... + def __init__(self, cap: float = ..., base: float = ...) -> None: ... def compute(self, failures: int) -> float: ... class DecorrelatedJitterBackoff(AbstractBackoff): - def __init__(self, cap: float, base: float) -> None: ... + def __init__(self, cap: float = ..., base: float = ...) -> None: ... def compute(self, failures: int) -> float: ... diff --git a/stubs/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index ecab3eed4..1b3de0b14 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -11,6 +11,7 @@ from redis import RedisError from .commands import CoreCommands, RedisModuleCommands, SentinelCommands from .connection import ConnectionPool, _ConnectFunc, _ConnectionPoolOptions +from .credentials import CredentialProvider from .lock import Lock from .retry import Retry from .typing import ChannelT, EncodableT, KeyT, PatternT @@ -186,6 +187,7 @@ class Redis(AbstractRedis, RedisModuleCommands, CoreCommands[_StrType], Sentinel username: str | None = ..., retry: Retry | None = ..., redis_connect_func: _ConnectFunc | None = ..., + credential_provider: CredentialProvider | None = ..., ) -> None: ... @overload def __init__( @@ -226,6 +228,7 @@ class Redis(AbstractRedis, RedisModuleCommands, CoreCommands[_StrType], Sentinel username: str | None = ..., retry: Retry | None = ..., redis_connect_func: _ConnectFunc | None = ..., + credential_provider: CredentialProvider | None = ..., ) -> None: ... @overload def __init__( @@ -265,6 +268,7 @@ class Redis(AbstractRedis, RedisModuleCommands, CoreCommands[_StrType], Sentinel username: str | None = ..., retry: Retry | None = ..., redis_connect_func: _ConnectFunc | None = ..., + credential_provider: CredentialProvider | None = ..., ) -> None: ... def get_encoder(self): ... def get_connection_kwargs(self): ... diff --git a/stubs/redis/redis/cluster.pyi b/stubs/redis/redis/cluster.pyi index 19277243a..b872a8cf7 100644 --- a/stubs/redis/redis/cluster.pyi +++ b/stubs/redis/redis/cluster.pyi @@ -10,6 +10,7 @@ from redis.commands import CommandsParser, RedisClusterCommands from redis.commands.core import _StrType from redis.connection import BaseParser, Connection, ConnectionPool, Encoder, _ConnectionPoolOptions, _Encodable from redis.exceptions import MovedError, RedisError +from redis.retry import Retry from redis.typing import EncodableT def get_node_name(host: str, port: str | int) -> str: ... @@ -62,6 +63,7 @@ class RedisCluster(AbstractRedisCluster, RedisClusterCommands[_StrType], Generic port: int | None = ..., startup_nodes: list[ClusterNode] | None = ..., cluster_error_retry_attempts: int = ..., + retry: Retry | None = ..., require_full_coverage: bool = ..., reinitialize_steps: int = ..., read_from_replicas: bool = ..., @@ -205,7 +207,6 @@ class ClusterPipeline(RedisCluster[_StrType], Generic[_StrType]): **kwargs, ) -> None: ... def __len__(self) -> int: ... - def __nonzero__(self) -> Literal[True]: ... def __bool__(self) -> Literal[True]: ... def execute_command(self, *args, **kwargs): ... def pipeline_execute_command(self, *args, **options): ... diff --git a/stubs/redis/redis/commands/core.pyi b/stubs/redis/redis/commands/core.pyi index 7b97a370e..919173948 100644 --- a/stubs/redis/redis/commands/core.pyi +++ b/stubs/redis/redis/commands/core.pyi @@ -7,7 +7,7 @@ from typing_extensions import Literal from ..asyncio.client import Redis as AsyncRedis from ..client import _CommandOptions, _Key, _Value -from ..typing import ChannelT, EncodableT, KeyT, PatternT, ScriptTextT +from ..typing import ChannelT, EncodableT, KeyT, PatternT, ScriptTextT, StreamIdT _ScoreCastFuncReturn = TypeVar("_ScoreCastFuncReturn") _StrType = TypeVar("_StrType", bound=str | bytes) @@ -818,7 +818,7 @@ class StreamCommands: limit: Any | None = ..., ): ... def xautoclaim( - self, name, groupname, consumername, min_idle_time, start_id: int = ..., count: Any | None = ..., justid: bool = ... + self, name, groupname, consumername, min_idle_time, start_id: StreamIdT = ..., count: Any | None = ..., justid: bool = ... ): ... def xclaim( self, name, groupname, consumername, min_idle_time, message_ids, idle=..., time=..., retrycount=..., force=..., justid=... @@ -861,7 +861,7 @@ class AsyncStreamCommands: limit: Any | None = ..., ): ... async def xautoclaim( - self, name, groupname, consumername, min_idle_time, start_id: int = ..., count: Any | None = ..., justid: bool = ... + self, name, groupname, consumername, min_idle_time, start_id: StreamIdT = ..., count: Any | None = ..., justid: bool = ... ): ... async def xclaim( self, name, groupname, consumername, min_idle_time, message_ids, idle=..., time=..., retrycount=..., force=..., justid=... diff --git a/stubs/redis/redis/connection.pyi b/stubs/redis/redis/connection.pyi index cec6df8aa..123a5f4c0 100644 --- a/stubs/redis/redis/connection.pyi +++ b/stubs/redis/redis/connection.pyi @@ -5,6 +5,7 @@ from socket import socket from typing import Any, ClassVar from typing_extensions import TypeAlias +from .credentials import CredentialProvider from .retry import Retry ssl_available: bool @@ -121,6 +122,7 @@ class Connection: username: str | None = ..., retry: Retry | None = ..., redis_connect_func: _ConnectFunc | None = ..., + credential_provider: CredentialProvider | None = ..., ) -> None: ... def __del__(self) -> None: ... def register_connect_callback(self, callback: _ConnectFunc) -> None: ... @@ -187,6 +189,7 @@ class UnixDomainSocketConnection(Connection): client_name: str | None = ..., retry: Retry | None = ..., redis_connect_func: _ConnectFunc | None = ..., + credential_provider: CredentialProvider | None = ..., ) -> None: ... # TODO: make generic on `connection_class` diff --git a/stubs/redis/redis/credentials.pyi b/stubs/redis/redis/credentials.pyi new file mode 100644 index 000000000..aecf728a9 --- /dev/null +++ b/stubs/redis/redis/credentials.pyi @@ -0,0 +1,11 @@ +from abc import abstractmethod + +class CredentialProvider: + @abstractmethod + def get_credentials(self) -> tuple[str] | tuple[str, str]: ... + +class UsernamePasswordCredentialProvider(CredentialProvider): + username: str + password: str + def __init__(self, username: str | None = ..., password: str | None = ...) -> None: ... + def get_credentials(self) -> tuple[str] | tuple[str, str]: ...