Bump redis to 4.4.0 (#9458)

Co-authored-by: AlexWaygood <alex.waygood@gmail.com>
This commit is contained in:
Juan Amari
2023-01-05 12:25:11 -03:00
committed by GitHub
parent 3dfc3a383c
commit 605378de6e
10 changed files with 41 additions and 36 deletions

View File

@@ -1 +1 @@
version = "4.3.5"
version = "4.4.0"

View File

@@ -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: ...

View File

@@ -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]]: ...

View File

@@ -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): ...

View File

@@ -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: ...

View File

@@ -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): ...

View File

@@ -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): ...

View File

@@ -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=...

View File

@@ -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`

View File

@@ -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]: ...