Skip to content

Commit 605378d

Browse files
Bump redis to 4.4.0 (#9458)
Co-authored-by: AlexWaygood <[email protected]>
1 parent 3dfc3a3 commit 605378d

File tree

10 files changed

+41
-36
lines changed

10 files changed

+41
-36
lines changed

stubs/redis/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "4.3.5"
1+
version = "4.4.0"

stubs/redis/redis/asyncio/client.pyi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ from redis.asyncio.lock import Lock
1010
from redis.asyncio.retry import Retry
1111
from redis.client import AbstractRedis, _CommandOptions, _Key, _StrType, _Value
1212
from redis.commands import AsyncCoreCommands, AsyncSentinelCommands, RedisModuleCommands
13-
from redis.typing import ChannelT, EncodableT, KeyT, PatternT
13+
from redis.credentials import CredentialProvider
14+
from redis.typing import ChannelT, EncodableT, KeyT, PatternT, StreamIdT
1415

1516
PubSubHandler: TypeAlias = Callable[[dict[str, str]], Awaitable[None]]
1617

@@ -63,6 +64,7 @@ class Redis(AbstractRedis, RedisModuleCommands, AsyncCoreCommands[_StrType], Asy
6364
retry: Retry | None = ...,
6465
auto_close_connection_pool: bool = ...,
6566
redis_connect_func: ConnectCallbackT | None = ...,
67+
credential_provider: CredentialProvider | None = ...,
6668
) -> None: ...
6769
def __await__(self): ...
6870
async def initialize(self: Self) -> Self: ...
@@ -82,6 +84,7 @@ class Redis(AbstractRedis, RedisModuleCommands, AsyncCoreCommands[_StrType], Asy
8284
name: KeyT,
8385
timeout: float | None = ...,
8486
sleep: float = ...,
87+
blocking: bool = ...,
8588
blocking_timeout: float | None = ...,
8689
lock_class: type[Lock] | None = ...,
8790
thread_local: bool = ...,
@@ -586,7 +589,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]):
586589
groupname,
587590
consumername,
588591
min_idle_time,
589-
start_id: int = ...,
592+
start_id: StreamIdT = ...,
590593
count: Incomplete | None = ...,
591594
justid: bool = ...,
592595
) -> Any: ...

stubs/redis/redis/asyncio/connection.pyi

Lines changed: 7 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -3,16 +3,15 @@ import enum
33
import ssl
44
from collections.abc import Callable, Iterable, Mapping
55
from typing import Any, Protocol
6-
from typing_extensions import TypeAlias, TypedDict
6+
from typing_extensions import Literal, TypeAlias, TypedDict
77

88
from redis import RedisError
99
from redis.asyncio.retry import Retry
10+
from redis.credentials import CredentialProvider
1011
from redis.exceptions import ResponseError
1112
from redis.typing import EncodableT, EncodedT
1213

1314
hiredis: Any
14-
NONBLOCKING_EXCEPTION_ERROR_NUMBERS: Any
15-
NONBLOCKING_EXCEPTIONS: Any
1615
SYM_STAR: bytes
1716
SYM_DOLLAR: bytes
1817
SYM_CRLF: bytes
@@ -46,37 +45,20 @@ class BaseParser:
4645
def parse_error(self, response: str) -> ResponseError: ...
4746
def on_disconnect(self) -> None: ...
4847
def on_connect(self, connection: Connection): ...
49-
async def can_read(self, timeout: float) -> bool: ...
5048
async def read_response(self, disable_decoding: bool = ...) -> EncodableT | ResponseError | list[EncodableT] | None: ...
5149

52-
class SocketBuffer:
53-
socket_read_size: Any
54-
socket_timeout: Any
55-
bytes_written: int
56-
bytes_read: int
57-
def __init__(self, stream_reader: asyncio.StreamReader, socket_read_size: int, socket_timeout: float | None) -> None: ...
58-
@property
59-
def length(self): ...
60-
async def can_read(self, timeout: float) -> bool: ...
61-
async def read(self, length: int) -> bytes: ...
62-
async def readline(self) -> bytes: ...
63-
def purge(self) -> None: ...
64-
def close(self) -> None: ...
65-
6650
class PythonParser(BaseParser):
6751
encoder: Any
6852
def __init__(self, socket_read_size: int) -> None: ...
6953
def on_connect(self, connection: Connection): ...
7054
def on_disconnect(self) -> None: ...
71-
async def can_read(self, timeout: float): ...
7255
async def read_response(self, disable_decoding: bool = ...) -> EncodableT | ResponseError | None: ...
7356

7457
class HiredisParser(BaseParser):
7558
def __init__(self, socket_read_size: int) -> None: ...
7659
def on_connect(self, connection: Connection): ...
7760
def on_disconnect(self) -> None: ...
78-
async def can_read(self, timeout: float): ...
79-
async def read_from_socket(self, timeout: float | None | _Sentinel = ..., raise_on_timeout: bool = ...): ...
61+
async def read_from_socket(self) -> Literal[True]: ...
8062
async def read_response(self, disable_decoding: bool = ...) -> EncodableT | list[EncodableT]: ...
8163

8264
DefaultParser: type[PythonParser | HiredisParser]
@@ -135,6 +117,7 @@ class Connection:
135117
retry: Retry | None = ...,
136118
redis_connect_func: ConnectCallbackT | None = ...,
137119
encoder_class: type[Encoder] = ...,
120+
credential_provider: CredentialProvider | None = ...,
138121
) -> None: ...
139122
def repr_pieces(self): ...
140123
def __del__(self) -> None: ...
@@ -145,12 +128,11 @@ class Connection:
145128
def set_parser(self, parser_class) -> None: ...
146129
async def connect(self) -> None: ...
147130
async def on_connect(self) -> None: ...
148-
async def disconnect(self) -> None: ...
131+
async def disconnect(self, nowait: bool = ...) -> None: ...
149132
async def check_health(self) -> None: ...
150133
async def send_packed_command(self, command: bytes | str | Iterable[bytes], check_health: bool = ...): ...
151134
async def send_command(self, *args, **kwargs) -> None: ...
152-
async def can_read(self, timeout: float = ...): ...
153-
async def read_response(self, disable_decoding: bool = ...): ...
135+
async def read_response(self, disable_decoding: bool = ..., timeout: float | None = ...): ...
154136
def pack_command(self, *args: EncodableT) -> list[bytes]: ...
155137
def pack_commands(self, commands: Iterable[Iterable[EncodableT]]) -> list[bytes]: ...
156138

@@ -234,6 +216,7 @@ class UnixDomainSocketConnection(Connection):
234216
client_name: str | None = ...,
235217
retry: Retry | None = ...,
236218
redis_connect_func: ConnectCallbackT | None = ...,
219+
credential_provider: CredentialProvider | None = ...,
237220
) -> None: ...
238221
def repr_pieces(self) -> Iterable[tuple[str, str | int]]: ...
239222

stubs/redis/redis/asyncio/sentinel.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ class SentinelManagedConnection(Connection):
1515
def __init__(self, **kwargs) -> None: ...
1616
async def connect_to(self, address) -> None: ...
1717
async def connect(self): ...
18-
async def read_response(self, disable_decoding: bool = ...): ...
18+
async def read_response(self, disable_decoding: bool = ...): ... # type: ignore[override]
1919

2020
class SentinelManagedSSLConnection(SentinelManagedConnection, SSLConnection): ...
2121

stubs/redis/redis/backoff.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,17 +13,17 @@ class NoBackoff(ConstantBackoff):
1313
def __init__(self) -> None: ...
1414

1515
class ExponentialBackoff(AbstractBackoff):
16-
def __init__(self, cap: float, base: float) -> None: ...
16+
def __init__(self, cap: float = ..., base: float = ...) -> None: ...
1717
def compute(self, failures: int) -> float: ...
1818

1919
class FullJitterBackoff(AbstractBackoff):
20-
def __init__(self, cap: float, base: float) -> None: ...
20+
def __init__(self, cap: float = ..., base: float = ...) -> None: ...
2121
def compute(self, failures: int) -> float: ...
2222

2323
class EqualJitterBackoff(AbstractBackoff):
24-
def __init__(self, cap: float, base: float) -> None: ...
24+
def __init__(self, cap: float = ..., base: float = ...) -> None: ...
2525
def compute(self, failures: int) -> float: ...
2626

2727
class DecorrelatedJitterBackoff(AbstractBackoff):
28-
def __init__(self, cap: float, base: float) -> None: ...
28+
def __init__(self, cap: float = ..., base: float = ...) -> None: ...
2929
def compute(self, failures: int) -> float: ...

stubs/redis/redis/client.pyi

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ from redis import RedisError
1111

1212
from .commands import CoreCommands, RedisModuleCommands, SentinelCommands
1313
from .connection import ConnectionPool, _ConnectFunc, _ConnectionPoolOptions
14+
from .credentials import CredentialProvider
1415
from .lock import Lock
1516
from .retry import Retry
1617
from .typing import ChannelT, EncodableT, KeyT, PatternT
@@ -186,6 +187,7 @@ class Redis(AbstractRedis, RedisModuleCommands, CoreCommands[_StrType], Sentinel
186187
username: str | None = ...,
187188
retry: Retry | None = ...,
188189
redis_connect_func: _ConnectFunc | None = ...,
190+
credential_provider: CredentialProvider | None = ...,
189191
) -> None: ...
190192
@overload
191193
def __init__(
@@ -226,6 +228,7 @@ class Redis(AbstractRedis, RedisModuleCommands, CoreCommands[_StrType], Sentinel
226228
username: str | None = ...,
227229
retry: Retry | None = ...,
228230
redis_connect_func: _ConnectFunc | None = ...,
231+
credential_provider: CredentialProvider | None = ...,
229232
) -> None: ...
230233
@overload
231234
def __init__(
@@ -265,6 +268,7 @@ class Redis(AbstractRedis, RedisModuleCommands, CoreCommands[_StrType], Sentinel
265268
username: str | None = ...,
266269
retry: Retry | None = ...,
267270
redis_connect_func: _ConnectFunc | None = ...,
271+
credential_provider: CredentialProvider | None = ...,
268272
) -> None: ...
269273
def get_encoder(self): ...
270274
def get_connection_kwargs(self): ...

stubs/redis/redis/cluster.pyi

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ from redis.commands import CommandsParser, RedisClusterCommands
1010
from redis.commands.core import _StrType
1111
from redis.connection import BaseParser, Connection, ConnectionPool, Encoder, _ConnectionPoolOptions, _Encodable
1212
from redis.exceptions import MovedError, RedisError
13+
from redis.retry import Retry
1314
from redis.typing import EncodableT
1415

1516
def get_node_name(host: str, port: str | int) -> str: ...
@@ -62,6 +63,7 @@ class RedisCluster(AbstractRedisCluster, RedisClusterCommands[_StrType], Generic
6263
port: int | None = ...,
6364
startup_nodes: list[ClusterNode] | None = ...,
6465
cluster_error_retry_attempts: int = ...,
66+
retry: Retry | None = ...,
6567
require_full_coverage: bool = ...,
6668
reinitialize_steps: int = ...,
6769
read_from_replicas: bool = ...,
@@ -205,7 +207,6 @@ class ClusterPipeline(RedisCluster[_StrType], Generic[_StrType]):
205207
**kwargs,
206208
) -> None: ...
207209
def __len__(self) -> int: ...
208-
def __nonzero__(self) -> Literal[True]: ...
209210
def __bool__(self) -> Literal[True]: ...
210211
def execute_command(self, *args, **kwargs): ...
211212
def pipeline_execute_command(self, *args, **options): ...

stubs/redis/redis/commands/core.pyi

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ from typing_extensions import Literal
77

88
from ..asyncio.client import Redis as AsyncRedis
99
from ..client import _CommandOptions, _Key, _Value
10-
from ..typing import ChannelT, EncodableT, KeyT, PatternT, ScriptTextT
10+
from ..typing import ChannelT, EncodableT, KeyT, PatternT, ScriptTextT, StreamIdT
1111

1212
_ScoreCastFuncReturn = TypeVar("_ScoreCastFuncReturn")
1313
_StrType = TypeVar("_StrType", bound=str | bytes)
@@ -818,7 +818,7 @@ class StreamCommands:
818818
limit: Any | None = ...,
819819
): ...
820820
def xautoclaim(
821-
self, name, groupname, consumername, min_idle_time, start_id: int = ..., count: Any | None = ..., justid: bool = ...
821+
self, name, groupname, consumername, min_idle_time, start_id: StreamIdT = ..., count: Any | None = ..., justid: bool = ...
822822
): ...
823823
def xclaim(
824824
self, name, groupname, consumername, min_idle_time, message_ids, idle=..., time=..., retrycount=..., force=..., justid=...
@@ -861,7 +861,7 @@ class AsyncStreamCommands:
861861
limit: Any | None = ...,
862862
): ...
863863
async def xautoclaim(
864-
self, name, groupname, consumername, min_idle_time, start_id: int = ..., count: Any | None = ..., justid: bool = ...
864+
self, name, groupname, consumername, min_idle_time, start_id: StreamIdT = ..., count: Any | None = ..., justid: bool = ...
865865
): ...
866866
async def xclaim(
867867
self, name, groupname, consumername, min_idle_time, message_ids, idle=..., time=..., retrycount=..., force=..., justid=...

stubs/redis/redis/connection.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ from socket import socket
55
from typing import Any, ClassVar
66
from typing_extensions import TypeAlias
77

8+
from .credentials import CredentialProvider
89
from .retry import Retry
910

1011
ssl_available: bool
@@ -121,6 +122,7 @@ class Connection:
121122
username: str | None = ...,
122123
retry: Retry | None = ...,
123124
redis_connect_func: _ConnectFunc | None = ...,
125+
credential_provider: CredentialProvider | None = ...,
124126
) -> None: ...
125127
def __del__(self) -> None: ...
126128
def register_connect_callback(self, callback: _ConnectFunc) -> None: ...
@@ -187,6 +189,7 @@ class UnixDomainSocketConnection(Connection):
187189
client_name: str | None = ...,
188190
retry: Retry | None = ...,
189191
redis_connect_func: _ConnectFunc | None = ...,
192+
credential_provider: CredentialProvider | None = ...,
190193
) -> None: ...
191194

192195
# TODO: make generic on `connection_class`

stubs/redis/redis/credentials.pyi

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
from abc import abstractmethod
2+
3+
class CredentialProvider:
4+
@abstractmethod
5+
def get_credentials(self) -> tuple[str] | tuple[str, str]: ...
6+
7+
class UsernamePasswordCredentialProvider(CredentialProvider):
8+
username: str
9+
password: str
10+
def __init__(self, username: str | None = ..., password: str | None = ...) -> None: ...
11+
def get_credentials(self) -> tuple[str] | tuple[str, str]: ...

0 commit comments

Comments
 (0)