Skip to content

Commit e6cb341

Browse files
srittauAkulipre-commit-ci[bot]
authored
Update redis stubs to 4.1 (#6711)
Co-authored-by: Akuli <[email protected]> Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
1 parent 14e5d16 commit e6cb341

31 files changed

+1352
-261
lines changed
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
redis.client.Pipeline.transaction # instance attribute has same name as superclass method
2+
redis.ocsp # requires cryptography to be installed

stubs/redis/METADATA.toml

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
version = "4.0.*"
2-
requires = []
1+
version = "4.1.*"

stubs/redis/redis/__init__.pyi

+29
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,34 @@
11
from . import client, connection, exceptions, sentinel, utils
22

3+
__all__ = [
4+
"AuthenticationError",
5+
"AuthenticationWrongNumberOfArgsError",
6+
"BlockingConnectionPool",
7+
"BusyLoadingError",
8+
"ChildDeadlockedError",
9+
"Connection",
10+
"ConnectionError",
11+
"ConnectionPool",
12+
"DataError",
13+
"from_url",
14+
"InvalidResponse",
15+
"PubSubError",
16+
"ReadOnlyError",
17+
"Redis",
18+
"RedisCluster",
19+
"RedisError",
20+
"ResponseError",
21+
"Sentinel",
22+
"SentinelConnectionPool",
23+
"SentinelManagedConnection",
24+
"SentinelManagedSSLConnection",
25+
"SSLConnection",
26+
"StrictRedis",
27+
"TimeoutError",
28+
"UnixDomainSocketConnection",
29+
"WatchError",
30+
]
31+
332
Redis = client.Redis
433

534
BlockingConnectionPool = connection.BlockingConnectionPool

stubs/redis/redis/client.pyi

+26-187
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import builtins
21
import threading
32
from _typeshed import Self, SupportsItems
43
from datetime import datetime, timedelta
@@ -36,6 +35,10 @@ _StrType = TypeVar("_StrType", bound=Union[str, bytes])
3635
_VT = TypeVar("_VT")
3736
_T = TypeVar("_T")
3837

38+
SYM_EMPTY: bytes
39+
EMPTY_RESPONSE: str
40+
NEVER_DECODE: str
41+
3942
class CaseInsensitiveDict(Dict[_StrType, _VT]):
4043
def __init__(self, data: SupportsItems[_StrType, _VT]) -> None: ...
4144
def update(self, data: SupportsItems[_StrType, _VT]) -> None: ... # type: ignore[override]
@@ -45,15 +48,15 @@ class CaseInsensitiveDict(Dict[_StrType, _VT]):
4548
def get(self, k: _StrType, default: _VT | _T) -> _VT | _T: ...
4649
# Overrides many other methods too, but without changing signature
4750

48-
SYM_EMPTY: Any
49-
SENTINEL_STATE_TYPES: Any
50-
5151
def list_or_args(keys, args): ...
5252
def timestamp_to_datetime(response): ...
5353
def string_keys_to_dict(key_string, callback): ...
5454
def parse_debug_object(response): ...
5555
def parse_object(response, infotype): ...
5656
def parse_info(response): ...
57+
58+
SENTINEL_STATE_TYPES: dict[str, type[int]]
59+
5760
def parse_sentinel_state(item): ...
5861
def parse_sentinel_master(response): ...
5962
def parse_sentinel_masters(response): ...
@@ -166,18 +169,23 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener
166169
errors: str | None,
167170
decode_responses: Literal[True],
168171
retry_on_timeout: bool = ...,
172+
retry_on_error=...,
169173
ssl: bool = ...,
170174
ssl_keyfile: str | None = ...,
171175
ssl_certfile: str | None = ...,
172176
ssl_cert_reqs: str | int | None = ...,
173177
ssl_ca_certs: str | None = ...,
178+
ssl_ca_path: Any | None = ...,
174179
ssl_check_hostname: bool = ...,
180+
ssl_password: Any | None = ...,
181+
ssl_validate_ocsp: bool = ...,
175182
max_connections: int | None = ...,
176183
single_connection_client: bool = ...,
177184
health_check_interval: float = ...,
178185
client_name: str | None = ...,
179186
username: str | None = ...,
180187
retry: Retry | None = ...,
188+
redis_connect_func: Any | None = ...,
181189
) -> None: ...
182190
@overload
183191
def __init__(
@@ -211,6 +219,7 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener
211219
client_name: str | None = ...,
212220
username: str | None = ...,
213221
retry: Retry | None = ...,
222+
redis_connect_func: Any | None = ...,
214223
) -> None: ...
215224
@overload
216225
def __init__(
@@ -243,7 +252,10 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener
243252
client_name: str | None = ...,
244253
username: str | None = ...,
245254
retry: Retry | None = ...,
255+
redis_connect_func: Any | None = ...,
246256
) -> None: ...
257+
def get_encoder(self): ...
258+
def get_connection_kwargs(self): ...
247259
def set_response_callback(self, command, callback): ...
248260
def pipeline(self, transaction: bool = ..., shard_hint: Any = ...) -> Pipeline[_StrType]: ...
249261
def transaction(self, func, *watches, **kwargs): ...
@@ -281,179 +293,7 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener
281293
def pubsub(self, *, shard_hint: Any = ..., ignore_subscribe_messages: bool = ...) -> PubSub: ...
282294
def execute_command(self, *args, **options): ...
283295
def parse_response(self, connection, command_name, **options): ...
284-
# TODO: Most of the following methods must be moved to the command classes.
285-
def readwrite(self) -> bool: ...
286-
def readonly(self) -> bool: ...
287-
def config_get(self, pattern=...): ...
288-
def config_set(self, name, value): ...
289-
def config_resetstat(self): ...
290-
def config_rewrite(self): ...
291-
def dbsize(self) -> int: ...
292-
def debug_object(self, key): ...
293-
def echo(self, value: _Value) -> bytes: ...
294-
def info(self, section: _Key | None = ...) -> Mapping[str, Any]: ...
295-
def lastsave(self): ...
296-
def object(self, infotype, key): ...
297-
def ping(self) -> bool: ...
298-
def save(self) -> bool: ...
299-
def shutdown(self, save: bool = ..., nosave: bool = ...) -> None: ...
300-
def slaveof(self, host=..., port=...): ...
301-
def slowlog_get(self, num=...): ...
302-
def slowlog_len(self): ...
303-
def slowlog_reset(self): ...
304-
def time(self): ...
305-
def decr(self, name, amount=...) -> int: ...
306-
def decrby(self, name, amount=...) -> int: ...
307-
def delete(self, *names: _Key) -> int: ...
308-
def __delitem__(self, _Key): ...
309-
def dump(self, name): ...
310-
def exists(self, *names: _Key) -> int: ...
311-
__contains__: Any
312-
def expire(self, name: _Key, time: int | timedelta) -> bool: ...
313-
def expireat(self, name, when): ...
314-
def get(self, name: _Key) -> _StrType | None: ...
315-
def __getitem__(self, name): ...
316-
def getbit(self, name: _Key, offset: int) -> int: ...
317-
def getrange(self, key, start, end): ...
318-
def getset(self, name, value) -> _StrType | None: ...
319-
def incr(self, name: _Key, amount: int = ...) -> int: ...
320-
def incrby(self, name: _Key, amount: int = ...) -> int: ...
321-
def incrbyfloat(self, name: _Key, amount: float = ...) -> float: ...
322-
def keys(self, pattern: _Key = ...) -> list[_StrType]: ...
323-
def mget(self, keys: _Key | Iterable[_Key], *args: _Key) -> list[_StrType | None]: ...
324-
def mset(self, mapping: Mapping[_Key, _Value]) -> Literal[True]: ...
325-
def msetnx(self, mapping: Mapping[_Key, _Value]) -> bool: ...
326-
def move(self, name: _Key, db: int) -> bool: ...
327-
def persist(self, name: _Key) -> bool: ...
328-
def pexpire(self, name: _Key, time: int | timedelta) -> Literal[1, 0]: ...
329-
def pexpireat(self, name: _Key, when: int | datetime) -> Literal[1, 0]: ...
330-
def psetex(self, name, time_ms, value): ...
331-
def pttl(self, name): ...
332-
def __setitem__(self, name, value): ...
333-
def setbit(self, name: _Key, offset: int, value: int) -> int: ...
334-
def setex(self, name: _Key, time: int | timedelta, value: _Value) -> bool: ...
335-
def setnx(self, name: _Key, value: _Value) -> bool: ...
336-
def setrange(self, name, offset, value): ...
337-
def strlen(self, name): ...
338-
def substr(self, name, start, end=...): ...
339-
def ttl(self, name: _Key) -> int: ...
340-
def type(self, name): ...
341-
def watch(self, *names): ...
342-
def unlink(self, *names: _Key) -> int: ...
343-
def unwatch(self): ...
344-
@overload
345-
def blpop(self, keys: _Value | Iterable[_Value], timeout: Literal[0] = ...) -> tuple[_StrType, _StrType]: ...
346-
@overload
347-
def blpop(self, keys: _Value | Iterable[_Value], timeout: float) -> tuple[_StrType, _StrType] | None: ...
348-
@overload
349-
def brpop(self, keys: _Value | Iterable[_Value], timeout: Literal[0] = ...) -> tuple[_StrType, _StrType]: ...
350-
@overload
351-
def brpop(self, keys: _Value | Iterable[_Value], timeout: float) -> tuple[_StrType, _StrType] | None: ...
352-
def brpoplpush(self, src, dst, timeout=...): ...
353-
@overload
354-
def sort(
355-
self,
356-
name: _Key,
357-
start: int | None = ...,
358-
num: int | None = ...,
359-
by: _Key | None = ...,
360-
get: _Key | Sequence[_Key] | None = ...,
361-
desc: bool = ...,
362-
alpha: bool = ...,
363-
store: None = ...,
364-
groups: bool = ...,
365-
) -> list[_StrType]: ...
366-
@overload
367-
def sort(
368-
self,
369-
name: _Key,
370-
start: int | None = ...,
371-
num: int | None = ...,
372-
by: _Key | None = ...,
373-
get: _Key | Sequence[_Key] | None = ...,
374-
desc: bool = ...,
375-
alpha: bool = ...,
376-
*,
377-
store: _Key,
378-
groups: bool = ...,
379-
) -> int: ...
380-
@overload
381-
def sort(
382-
self,
383-
name: _Key,
384-
start: int | None,
385-
num: int | None,
386-
by: _Key | None,
387-
get: _Key | Sequence[_Key] | None,
388-
desc: bool,
389-
alpha: bool,
390-
store: _Key,
391-
groups: bool = ...,
392-
) -> int: ...
393-
def scan(
394-
self, cursor: int = ..., match: _Key | None = ..., count: int | None = ..., _type: str | None = ...
395-
) -> tuple[int, list[_StrType]]: ...
396-
def scan_iter(self, match: str | None = ..., count: int | None = ..., _type: str | None = ...) -> Iterator[_StrType]: ...
397-
def sscan(
398-
self, name: _Key, cursor: int = ..., match: str | None = ..., count: int | None = ...
399-
) -> tuple[int, list[_StrType]]: ...
400-
def sscan_iter(self, name: _Key, match: str | None = ..., count: int | None = ...): ...
401-
def hscan(
402-
self, name: _Key, cursor: int = ..., match: str | None = ..., count: int | None = ...
403-
) -> tuple[int, dict[_StrType, _StrType]]: ...
404-
def hscan_iter(self, name: _Key, match: str | None = ..., count: int | None = ...): ...
405-
def zscan(self, name, cursor=..., match=..., count=..., score_cast_func=...): ...
406-
def zscan_iter(self, name, match=..., count=..., score_cast_func=...): ...
407-
def sadd(self, name: _Key, *values: _Value) -> int: ...
408-
def scard(self, name: _Key) -> int: ...
409-
def sdiff(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ...
410-
def sdiffstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ...
411-
def sinter(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ...
412-
def sinterstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ...
413-
def sismember(self, name: _Key, value: _Value) -> bool: ...
414-
def smembers(self, name: _Key) -> builtins.set[_StrType]: ...
415-
def smove(self, src: _Key, dst: _Key, value: _Value) -> bool: ...
416-
@overload
417-
def spop(self, name: _Key, count: None = ...) -> _Value | None: ...
418-
@overload
419-
def spop(self, name: _Key, count: int) -> list[_Value]: ...
420-
@overload
421-
def srandmember(self, name: _Key, number: None = ...) -> _Value | None: ...
422-
@overload
423-
def srandmember(self, name: _Key, number: int) -> list[_Value]: ...
424-
def srem(self, name: _Key, *values: _Value) -> int: ...
425-
def sunion(self, keys: _Key | Iterable[_Key], *args: _Key) -> builtins.set[_Value]: ...
426-
def sunionstore(self, dest: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> int: ...
427-
def pfadd(self, name: _Key, *values: _Value) -> int: ...
428-
def pfcount(self, name: _Key) -> int: ...
429-
def pfmerge(self, dest: _Key, *sources: _Key) -> bool: ...
430-
def hdel(self, name: _Key, *keys: _Key) -> int: ...
431-
def hexists(self, name: _Key, key: _Key) -> bool: ...
432-
def hget(self, name: _Key, key: _Key) -> _StrType | None: ...
433-
def hgetall(self, name: _Key) -> dict[_StrType, _StrType]: ...
434-
def hincrby(self, name: _Key, key: _Key, amount: int = ...) -> int: ...
435-
def hincrbyfloat(self, name: _Key, key: _Key, amount: float = ...) -> float: ...
436-
def hkeys(self, name: _Key) -> list[_StrType]: ...
437-
def hlen(self, name: _Key) -> int: ...
438-
@overload
439-
def hset(self, name: _Key, key: _Key, value: _Value, mapping: Mapping[_Key, _Value] | None = ...) -> int: ...
440-
@overload
441-
def hset(self, name: _Key, key: None, value: None, mapping: Mapping[_Key, _Value]) -> int: ...
442-
@overload
443-
def hset(self, name: _Key, *, mapping: Mapping[_Key, _Value]) -> int: ...
444-
def hsetnx(self, name: _Key, key: _Key, value: _Value) -> int: ...
445-
def hmset(self, name: _Key, mapping: Mapping[_Key, _Value]) -> bool: ...
446-
def hmget(self, name: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> list[_StrType | None]: ...
447-
def hvals(self, name: _Key) -> list[_StrType]: ...
448-
def publish(self, channel: _Key, message: _Key) -> int: ...
449-
def eval(self, script, numkeys, *keys_and_args): ...
450-
def evalsha(self, sha, numkeys, *keys_and_args): ...
451-
def pubsub_channels(self, pattern: _Key = ...) -> list[str]: ...
452-
def pubsub_numsub(self, *args: _Key) -> list[tuple[str, int]]: ...
453-
def pubsub_numpat(self) -> int: ...
454296
def monitor(self) -> Monitor: ...
455-
def memory_stats(self) -> dict[str, Any]: ...
456-
def memory_purge(self) -> bool: ...
457297
def cluster(self, cluster_arg: str, *args: Any) -> Any: ...
458298
def __enter__(self) -> Redis[_StrType]: ...
459299
def __exit__(self, exc_type, exc_value, traceback): ...
@@ -471,9 +311,13 @@ class PubSub:
471311
shard_hint: Any
472312
ignore_subscribe_messages: Any
473313
connection: Any
314+
subscribed_event: threading.Event
474315
encoder: Any
475-
health_check_response: Any
476-
def __init__(self, connection_pool, shard_hint=..., ignore_subscribe_messages: bool = ...) -> None: ...
316+
health_check_response_b: bytes
317+
health_check_response: list[str] | list[bytes]
318+
def __init__(
319+
self, connection_pool, shard_hint: Any | None = ..., ignore_subscribe_messages: bool = ..., encoder: Any | None = ...
320+
) -> None: ...
477321
def __enter__(self: Self) -> Self: ...
478322
def __exit__(self, exc_type: object, exc_value: object, traceback: object) -> None: ...
479323
def __del__(self): ...
@@ -485,7 +329,10 @@ class PubSub:
485329
@property
486330
def subscribed(self): ...
487331
def execute_command(self, *args): ...
332+
def clean_health_check_responses(self) -> None: ...
488333
def parse_response(self, block: bool = ..., timeout: float = ...): ...
334+
def is_health_check_response(self, response) -> bool: ...
335+
def check_health(self) -> None: ...
489336
def psubscribe(self, *args: _Key, **kwargs: Callable[[Any], None]): ...
490337
def punsubscribe(self, *args: _Key) -> None: ...
491338
def subscribe(self, *args: _Key, **kwargs: Callable[[Any], None]) -> None: ...
@@ -698,7 +545,7 @@ class Pipeline(Redis[_StrType], Generic[_StrType]):
698545
groups: bool = ...,
699546
) -> Pipeline[_StrType]: ...
700547
def scan(self, cursor: int = ..., match: _Key | None = ..., count: int | None = ..., _type: str | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
701-
def scan_iter(self, match: str | None = ..., count: int | None = ..., _type: str | None = ...) -> Iterator[Any]: ...
548+
def scan_iter(self, match: str | None = ..., count: int | None = ..., _type: str | None = ...) -> Iterator[Any]: ... # type: ignore[override]
702549
def sscan(self, name: _Key, cursor: int = ..., match: str | None = ..., count: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
703550
def sscan_iter(self, name: _Key, match: str | None = ..., count: int | None = ...) -> Iterator[Any]: ...
704551
def hscan(self, name: _Key, cursor: int = ..., match: str | None = ..., count: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
@@ -836,21 +683,13 @@ class Pipeline(Redis[_StrType], Generic[_StrType]):
836683
def script_flush(self, sync_type: Any | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
837684
def script_kill(self) -> Pipeline[_StrType]: ... # type: ignore[override]
838685
def script_load(self, script) -> Pipeline[_StrType]: ... # type: ignore[override]
839-
def register_script(self, script: str | _StrType) -> Script: ... # type: ignore[override]
840686
def pubsub_channels(self, pattern: _Key = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
841687
def pubsub_numsub(self, *args: _Key) -> Pipeline[_StrType]: ... # type: ignore[override]
842688
def pubsub_numpat(self) -> Pipeline[_StrType]: ... # type: ignore[override]
843689
def monitor(self) -> Monitor: ...
844690
def cluster(self, cluster_arg: str, *args: Any) -> Pipeline[_StrType]: ... # type: ignore[override]
845691
def client(self) -> Any: ...
846692

847-
class Script:
848-
registered_client: Any
849-
script: Any
850-
sha: Any
851-
def __init__(self, registered_client, script) -> None: ...
852-
def __call__(self, keys=..., args=..., client=...): ...
853-
854693
class Monitor(object):
855694
command_re: Pattern[str]
856695
monitor_re: Pattern[str]

0 commit comments

Comments
 (0)