From 39487a8bab933a8c29edef5cf399de5fa8bb94cd Mon Sep 17 00:00:00 2001 From: Sebastian Rittau Date: Fri, 10 Feb 2023 12:10:37 +0100 Subject: [PATCH] [redis] Update to 4.5.1 (#9697) Also add a few argument defaults --- stubs/redis/METADATA.toml | 2 +- stubs/redis/redis/asyncio/client.pyi | 7 ++- stubs/redis/redis/asyncio/connection.pyi | 10 ++- stubs/redis/redis/asyncio/sentinel.pyi | 9 ++- stubs/redis/redis/client.pyi | 8 ++- stubs/redis/redis/cluster.pyi | 14 +++-- stubs/redis/redis/commands/core.pyi | 14 +++-- stubs/redis/redis/connection.pyi | 79 ++++++++++++------------ 8 files changed, 82 insertions(+), 61 deletions(-) diff --git a/stubs/redis/METADATA.toml b/stubs/redis/METADATA.toml index ac35510f3..09b4d61d5 100644 --- a/stubs/redis/METADATA.toml +++ b/stubs/redis/METADATA.toml @@ -1,4 +1,4 @@ -version = "4.4.0" +version = "4.5.1" # Requires a version of cryptography with a `py.typed` file requires = ["types-pyOpenSSL", "cryptography>=35.0.0"] diff --git a/stubs/redis/redis/asyncio/client.pyi b/stubs/redis/redis/asyncio/client.pyi index 6154780c3..197501b63 100644 --- a/stubs/redis/redis/asyncio/client.pyi +++ b/stubs/redis/redis/asyncio/client.pyi @@ -232,9 +232,10 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): keys: Sequence[str] | None = ..., channels: Iterable[ChannelT] | None = ..., selectors: Iterable[tuple[str, KeyT]] | None = ..., - reset: bool = ..., - reset_keys: bool = ..., - reset_passwords: bool = ..., + reset: bool = False, + reset_keys: bool = False, + reset_channels: bool = False, + reset_passwords: bool = False, **kwargs: _CommandOptions, ) -> Pipeline[_StrType]: ... def acl_users(self, **kwargs: _CommandOptions) -> Any: ... # type: ignore[override] diff --git a/stubs/redis/redis/asyncio/connection.pyi b/stubs/redis/redis/asyncio/connection.pyi index ceae18ba9..435c5854f 100644 --- a/stubs/redis/redis/asyncio/connection.pyi +++ b/stubs/redis/redis/asyncio/connection.pyi @@ -1,8 +1,9 @@ import asyncio import enum import ssl +from _typeshed import Incomplete from collections.abc import Callable, Iterable, Mapping -from typing import Any, Protocol +from typing import Any, Protocol, overload from typing_extensions import Literal, TypeAlias, TypedDict from redis import RedisError @@ -132,7 +133,12 @@ class Connection: 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 read_response(self, disable_decoding: bool = ..., timeout: float | None = ...): ... + @overload + async def read_response(self, *, timeout: float) -> Incomplete | None: ... + @overload + async def read_response(self, disable_decoding: bool, timeout: float) -> Incomplete | None: ... + @overload + async def read_response(self, disable_decoding: bool = False, timeout: None = None): ... def pack_command(self, *args: EncodableT) -> list[bytes]: ... def pack_commands(self, commands: Iterable[Iterable[EncodableT]]) -> list[bytes]: ... diff --git a/stubs/redis/redis/asyncio/sentinel.pyi b/stubs/redis/redis/asyncio/sentinel.pyi index 92166d929..e452986c8 100644 --- a/stubs/redis/redis/asyncio/sentinel.pyi +++ b/stubs/redis/redis/asyncio/sentinel.pyi @@ -1,6 +1,6 @@ from _typeshed import Incomplete from collections.abc import AsyncIterator, Iterable, Mapping, Sequence -from typing import Any +from typing import Any, overload from redis.asyncio.client import Redis from redis.asyncio.connection import Connection, ConnectionPool, SSLConnection @@ -16,7 +16,12 @@ 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 = ...): ... # type: ignore[override] + @overload + async def read_response(self, *, timeout: float) -> Incomplete | None: ... + @overload + async def read_response(self, disable_decoding: bool, timeout: float) -> Incomplete | None: ... + @overload + async def read_response(self, disable_decoding: bool = False, timeout: None = None): ... class SentinelManagedSSLConnection(SentinelManagedConnection, SSLConnection): ... diff --git a/stubs/redis/redis/client.pyi b/stubs/redis/redis/client.pyi index 329c6313f..39cdfa0a9 100644 --- a/stubs/redis/redis/client.pyi +++ b/stubs/redis/redis/client.pyi @@ -428,9 +428,11 @@ class Pipeline(Redis[_StrType], Generic[_StrType]): keys: Sequence[str] | None = ..., channels: Iterable[ChannelT] | None = ..., selectors: Iterable[tuple[str, KeyT]] | None = ..., - reset: bool = ..., - reset_keys: bool = ..., - reset_passwords: bool = ..., + reset: bool = False, + reset_keys: bool = False, + reset_channels: bool = False, + reset_passwords: bool = False, + **kwargs: _CommandOptions, ) -> Pipeline[_StrType]: ... def acl_users(self) -> Pipeline[_StrType]: ... # type: ignore[override] def acl_whoami(self) -> Pipeline[_StrType]: ... # type: ignore[override] diff --git a/stubs/redis/redis/cluster.pyi b/stubs/redis/redis/cluster.pyi index 98a5cb6e9..c321db066 100644 --- a/stubs/redis/redis/cluster.pyi +++ b/stubs/redis/redis/cluster.pyi @@ -136,16 +136,18 @@ class NodesManager: startup_nodes: dict[str, ClusterNode] default_node: ClusterNode | None from_url: bool - connection_kwargs: dict[str, Any] + connection_pool_class: type[ConnectionPool] + connection_kwargs: dict[str, Incomplete] # TODO: could be a TypedDict read_load_balancer: LoadBalancer def __init__( self, startup_nodes: Iterable[ClusterNode], - from_url: bool = ..., - require_full_coverage: bool = ..., - lock: Lock | None = ..., - dynamic_startup_nodes: bool = ..., - **kwargs: Any, + from_url: bool = False, + require_full_coverage: bool = False, + lock: Lock | None = None, + dynamic_startup_nodes: bool = True, + connection_pool_class: type[ConnectionPool] = ..., + **kwargs, # TODO: same type as connection_kwargs ) -> None: ... def get_node( self, host: str | None = ..., port: int | str | None = ..., node_name: str | None = ... diff --git a/stubs/redis/redis/commands/core.pyi b/stubs/redis/redis/commands/core.pyi index feca85c9d..65aca2c57 100644 --- a/stubs/redis/redis/commands/core.pyi +++ b/stubs/redis/redis/commands/core.pyi @@ -35,9 +35,10 @@ class ACLCommands(Generic[_StrType]): keys: Sequence[str] | None = ..., channels: Iterable[ChannelT] | None = ..., selectors: Iterable[tuple[str, KeyT]] | None = ..., - reset: bool = ..., - reset_keys: bool = ..., - reset_passwords: bool = ..., + reset: bool = False, + reset_keys: bool = False, + reset_channels: bool = False, + reset_passwords: bool = False, **kwargs: _CommandOptions, ) -> bool: ... def acl_users(self, **kwargs: _CommandOptions) -> list[str]: ... @@ -66,9 +67,10 @@ class AsyncACLCommands(Generic[_StrType]): keys: Sequence[str] | None = ..., channels: Iterable[ChannelT] | None = ..., selectors: Iterable[tuple[str, KeyT]] | None = ..., - reset: bool = ..., - reset_keys: bool = ..., - reset_passwords: bool = ..., + reset: bool = False, + reset_keys: bool = False, + reset_channels: bool = False, + reset_passwords: bool = False, **kwargs: _CommandOptions, ) -> bool: ... async def acl_users(self, **kwargs: _CommandOptions) -> list[str]: ... diff --git a/stubs/redis/redis/connection.pyi b/stubs/redis/redis/connection.pyi index 87853369e..b58b81c19 100644 --- a/stubs/redis/redis/connection.pyi +++ b/stubs/redis/redis/connection.pyi @@ -38,13 +38,14 @@ class SocketBuffer: bytes_read: int socket_timeout: float | None def __init__(self, socket: socket, socket_read_size: int, socket_timeout: float | None) -> None: ... - @property - def length(self) -> int: ... + def unread_bytes(self) -> int: ... + def can_read(self, timeout: float | None) -> bool: ... def read(self, length: int) -> bytes: ... def readline(self) -> bytes: ... + def get_pos(self) -> int: ... + def rewind(self, pos: int) -> None: ... def purge(self) -> None: ... def close(self) -> None: ... - def can_read(self, timeout: float | None) -> bool: ... class PythonParser(BaseParser): encoding: str @@ -101,28 +102,29 @@ class Connection: health_check_interval: int def __init__( self, - host: str = ..., - port: int = ..., - db: int = ..., - 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 = ..., + host: str = "localhost", + port: int = 6379, + db: int = 0, + password: str | None = None, + socket_timeout: float | None = None, + socket_connect_timeout: float | None = None, + socket_keepalive: bool = False, + socket_keepalive_options: Mapping[str, int | str] | None = None, + socket_type: int = 0, + retry_on_timeout: bool = False, retry_on_error: list[type[Exception]] = ..., - encoding: str = ..., - encoding_errors: str = ..., - decode_responses: bool = ..., + encoding: str = "utf-8", + encoding_errors: str = "strict", + decode_responses: bool = False, parser_class: type[BaseParser] = ..., - socket_read_size: int = ..., - health_check_interval: int = ..., - client_name: str | None = ..., - username: str | None = ..., - retry: Retry | None = ..., - redis_connect_func: _ConnectFunc | None = ..., - credential_provider: CredentialProvider | None = ..., + socket_read_size: int = 65536, + health_check_interval: int = 0, + client_name: str | None = None, + username: str | None = None, + retry: Retry | None = None, + redis_connect_func: _ConnectFunc | None = None, + credential_provider: CredentialProvider | None = None, + command_packer: Incomplete | None = None, ) -> None: ... def __del__(self) -> None: ... def register_connect_callback(self, callback: _ConnectFunc) -> None: ... @@ -173,23 +175,24 @@ class UnixDomainSocketConnection(Connection): path: str def __init__( self, - path: str = ..., - db: int = ..., - username: str | None = ..., - password: str | None = ..., - socket_timeout: float | None = ..., - encoding: str = ..., - encoding_errors: str = ..., - decode_responses: bool = ..., - retry_on_timeout: bool = ..., + path: str = "", + db: int = 0, + username: str | None = None, + password: str | None = None, + socket_timeout: float | None = None, + encoding: str = "utf-8", + encoding_errors: str = "strict", + decode_responses: bool = False, + retry_on_timeout: bool = False, retry_on_error: list[type[Exception]] = ..., parser_class: type[BaseParser] = ..., - socket_read_size: int = ..., - health_check_interval: int = ..., - client_name: str | None = ..., - retry: Retry | None = ..., - redis_connect_func: _ConnectFunc | None = ..., - credential_provider: CredentialProvider | None = ..., + socket_read_size: int = 65536, + health_check_interval: int = 0, + client_name: str | None = None, + retry: Retry | None = None, + redis_connect_func: _ConnectFunc | None = None, + credential_provider: CredentialProvider | None = None, + command_packer: Incomplete | None = None, ) -> None: ... # TODO: make generic on `connection_class`