Skip to content

Commit 3a98e8b

Browse files
authored
Update redis stubs to 4.2 (#7675)
Closes #7597
1 parent 02e0c98 commit 3a98e8b

File tree

13 files changed

+65
-54
lines changed

13 files changed

+65
-54
lines changed
Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
redis.Sentinel.master_for
2+
redis.Sentinel.slave_for
3+
redis.sentinel.Sentinel.master_for
4+
redis.sentinel.Sentinel.slave_for
15
redis.client.Pipeline.transaction # instance attribute has same name as superclass method
2-
redis.commands.search.commands.SearchCommands.explain # https://github.com/redis/redis-py/pull/1997
36
redis.ocsp # requires cryptography to be installed

stubs/redis/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
version = "4.1.*"
1+
version = "4.2.*"

stubs/redis/redis/client.pyi

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -167,6 +167,7 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener
167167
ssl_cert_reqs: str | int | None = ...,
168168
ssl_ca_certs: str | None = ...,
169169
ssl_ca_path: Any | None = ...,
170+
ssl_ca_data: Any | None = ...,
170171
ssl_check_hostname: bool = ...,
171172
ssl_password: Any | None = ...,
172173
ssl_validate_ocsp: bool = ...,
@@ -206,6 +207,7 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener
206207
ssl_certfile: str | None = ...,
207208
ssl_cert_reqs: str | int | None = ...,
208209
ssl_ca_certs: str | None = ...,
210+
ssl_ca_data: Any | None = ...,
209211
ssl_check_hostname: bool = ...,
210212
ssl_password: Any | None = ...,
211213
ssl_validate_ocsp: bool = ...,
@@ -244,6 +246,7 @@ class Redis(RedisModuleCommands, CoreCommands[_StrType], SentinelCommands, Gener
244246
ssl_certfile: str | None = ...,
245247
ssl_cert_reqs: str | int | None = ...,
246248
ssl_ca_certs: str | None = ...,
249+
ssl_ca_data: Any | None = ...,
247250
ssl_check_hostname: bool = ...,
248251
ssl_password: Any | None = ...,
249252
ssl_validate_ocsp: bool = ...,
@@ -451,17 +454,17 @@ class Pipeline(Redis[_StrType], Generic[_StrType]):
451454
def slowlog_reset(self) -> Pipeline[_StrType]: ... # type: ignore[override]
452455
def time(self) -> Pipeline[_StrType]: ... # type: ignore[override]
453456
def append(self, key, value) -> Pipeline[_StrType]: ... # type: ignore[override]
454-
def bitcount(self, key: _Key, start: int | None = ..., end: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
457+
def bitcount(self, key: _Key, start: int | None = ..., end: int | None = ..., mode: str | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
455458
def bitop(self, operation, dest, *keys) -> Pipeline[_StrType]: ... # type: ignore[override]
456-
def bitpos(self, key, bit, start=..., end=...) -> Pipeline[_StrType]: ... # type: ignore[override]
459+
def bitpos(self, key, bit, start=..., end=..., mode: str | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
457460
def decr(self, name, amount=...) -> Pipeline[_StrType]: ... # type: ignore[override]
458461
def delete(self, *names: _Key) -> Pipeline[_StrType]: ... # type: ignore[override]
459462
def __delitem__(self, _Key) -> None: ...
460463
def dump(self, name) -> Pipeline[_StrType]: ... # type: ignore[override]
461464
def exists(self, *names: _Key) -> Pipeline[_StrType]: ... # type: ignore[override]
462465
def __contains__(self, *names: _Key) -> Pipeline[_StrType]: ... # type: ignore[override]
463-
def expire(self, name: _Key, time: int | timedelta) -> Pipeline[_StrType]: ... # type: ignore[override]
464-
def expireat(self, name, when) -> Pipeline[_StrType]: ... # type: ignore[override]
466+
def expire(self, name: _Key, time: int | timedelta, nx: bool = ..., xx: bool = ..., gt: bool = ..., lt: bool = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
467+
def expireat(self, name, when, nx: bool = ..., xx: bool = ..., gt: bool = ..., lt: bool = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
465468
def get(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore[override]
466469
def __getitem__(self, name) -> Pipeline[_StrType]: ... # type: ignore[override]
467470
def getbit(self, name: _Key, offset: int) -> Pipeline[_StrType]: ... # type: ignore[override]
@@ -476,8 +479,8 @@ class Pipeline(Redis[_StrType], Generic[_StrType]):
476479
def msetnx(self, mapping: Mapping[_Key, _Value]) -> Pipeline[_StrType]: ... # type: ignore[override]
477480
def move(self, name: _Key, db: int) -> Pipeline[_StrType]: ... # type: ignore[override]
478481
def persist(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore[override]
479-
def pexpire(self, name: _Key, time: int | timedelta) -> Pipeline[_StrType]: ... # type: ignore[override]
480-
def pexpireat(self, name: _Key, when: int | datetime) -> Pipeline[_StrType]: ... # type: ignore[override]
482+
def pexpire(self, name: _Key, time: int | timedelta, nx: bool = ..., xx: bool = ..., gt: bool = ..., lt: bool = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
483+
def pexpireat(self, name: _Key, when: int | datetime, nx: bool = ..., xx: bool = ..., gt: bool = ..., lt: bool = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
481484
def psetex(self, name, time_ms, value) -> Pipeline[_StrType]: ... # type: ignore[override]
482485
def pttl(self, name) -> Pipeline[_StrType]: ... # type: ignore[override]
483486
def randomkey(self) -> Pipeline[_StrType]: ... # type: ignore[override]
@@ -588,12 +591,12 @@ class Pipeline(Redis[_StrType], Generic[_StrType]):
588591
def xinfo_stream(self, name, full: bool = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
589592
def xlen(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore[override]
590593
def xpending(self, name, groupname) -> Pipeline[_StrType]: ... # type: ignore[override]
591-
def xpending_range(self, name, groupname, idle: Any | None = ..., min: int | None = ..., max: int | None = ..., count: int | None = ..., consumername=...) -> Pipeline[_StrType]: ... # type: ignore[override]
594+
def xpending_range(self, name: _Key, groupname, min, max, count: int, consumername: Any | None = ..., idle: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
592595
def xrange(self, name, min=..., max=..., count=...) -> Pipeline[_StrType]: ... # type: ignore[override]
593596
def xread(self, streams, count=..., block=...) -> Pipeline[_StrType]: ... # type: ignore[override]
594597
def xreadgroup(self, groupname, consumername, streams, count=..., block=..., noack=...) -> Pipeline[_StrType]: ... # type: ignore[override]
595598
def xrevrange(self, name, max=..., min=..., count=...) -> Pipeline[_StrType]: ... # type: ignore[override]
596-
def xtrim(self, name, maxlen: int | None = ..., approximate: bool = ..., minid: Any | None = ..., limit: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
599+
def xtrim(self, name, maxlen: int, approximate: bool = ..., minid: Any | None = ..., limit: int | None = ...) -> Pipeline[_StrType]: ... # type: ignore[override]
597600
def zadd( # type: ignore[override]
598601
self,
599602
name: _Key,
@@ -674,11 +677,15 @@ class Pipeline(Redis[_StrType], Generic[_StrType]):
674677
def hkeys(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore[override]
675678
def hlen(self, name: _Key) -> Pipeline[_StrType]: ... # type: ignore[override]
676679
@overload # type: ignore[override]
677-
def hset(self, name: _Key, key: _Key, value: _Value, mapping: Mapping[_Key, _Value] | None = ...) -> Pipeline[_StrType]: ...
680+
def hset(
681+
self, name: _Key, key: _Key, value: _Value, mapping: Mapping[_Key, _Value] | None = ..., items: Any | None = ...
682+
) -> Pipeline[_StrType]: ...
678683
@overload # type: ignore[override]
679-
def hset(self, name: _Key, key: None, value: None, mapping: Mapping[_Key, _Value]) -> Pipeline[_StrType]: ...
684+
def hset(
685+
self, name: _Key, key: None, value: None, mapping: Mapping[_Key, _Value], items: Any | None = ...
686+
) -> Pipeline[_StrType]: ...
680687
@overload # type: ignore[override]
681-
def hset(self, name: _Key, *, mapping: Mapping[_Key, _Value]) -> Pipeline[_StrType]: ...
688+
def hset(self, name: _Key, *, mapping: Mapping[_Key, _Value], items: Any | None = ...) -> Pipeline[_StrType]: ...
682689
def hsetnx(self, name: _Key, key: _Key, value: _Value) -> Pipeline[_StrType]: ... # type: ignore[override]
683690
def hmset(self, name: _Key, mapping: Mapping[_Key, _Value]) -> Pipeline[_StrType]: ... # type: ignore[override]
684691
def hmget(self, name: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> Pipeline[_StrType]: ... # type: ignore[override]

stubs/redis/redis/cluster.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,6 +155,7 @@ class ClusterPipeline(RedisCluster[_StrType], Generic[_StrType]):
155155
def __init__(
156156
self,
157157
nodes_manager,
158+
commands_parser,
158159
result_callbacks: Any | None = ...,
159160
cluster_response_callbacks: Any | None = ...,
160161
startup_nodes: Any | None = ...,

stubs/redis/redis/commands/bf/__init__.pyi

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -5,27 +5,27 @@ from .info import BFInfo as BFInfo, CFInfo as CFInfo, CMSInfo as CMSInfo, TDiges
55

66
class AbstractBloom:
77
@staticmethod
8-
def appendItems(params, items) -> None: ...
8+
def append_items(params, items) -> None: ...
99
@staticmethod
10-
def appendError(params, error) -> None: ...
10+
def append_error(params, error) -> None: ...
1111
@staticmethod
12-
def appendCapacity(params, capacity) -> None: ...
12+
def append_capacity(params, capacity) -> None: ...
1313
@staticmethod
14-
def appendExpansion(params, expansion) -> None: ...
14+
def append_expansion(params, expansion) -> None: ...
1515
@staticmethod
16-
def appendNoScale(params, noScale) -> None: ...
16+
def append_no_scale(params, noScale) -> None: ...
1717
@staticmethod
18-
def appendWeights(params, weights) -> None: ...
18+
def append_weights(params, weights) -> None: ...
1919
@staticmethod
20-
def appendNoCreate(params, noCreate) -> None: ...
20+
def append_no_create(params, noCreate) -> None: ...
2121
@staticmethod
22-
def appendItemsAndIncrements(params, items, increments) -> None: ...
22+
def append_items_and_increments(params, items, increments) -> None: ...
2323
@staticmethod
24-
def appendValuesAndWeights(params, items, weights) -> None: ...
24+
def append_values_and_weights(params, items, weights) -> None: ...
2525
@staticmethod
26-
def appendMaxIterations(params, max_iterations) -> None: ...
26+
def append_max_iterations(params, max_iterations) -> None: ...
2727
@staticmethod
28-
def appendBucketSize(params, bucket_size) -> None: ...
28+
def append_bucket_size(params, bucket_size) -> None: ...
2929

3030
class CMSBloom(CMSCommands, AbstractBloom):
3131
client: Any

stubs/redis/redis/commands/core.pyi

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -137,10 +137,10 @@ class ManagementCommands:
137137

138138
class BasicKeyCommands(Generic[_StrType]):
139139
def append(self, key, value): ...
140-
def bitcount(self, key: _Key, start: int | None = ..., end: int | None = ...) -> int: ...
140+
def bitcount(self, key: _Key, start: int | None = ..., end: int | None = ..., mode: str | None = ...) -> int: ...
141141
def bitfield(self, key, default_overflow: Any | None = ...): ...
142142
def bitop(self, operation, dest, *keys): ...
143-
def bitpos(self, key, bit, start=..., end=...): ...
143+
def bitpos(self, key: _Key, bit: int, start: int | None = ..., end: int | None = ..., mode: str | None = ...): ...
144144
def copy(self, source, destination, destination_db: Any | None = ..., replace: bool = ...): ...
145145
def decr(self, name, amount: int = ...) -> int: ...
146146
def decrby(self, name, amount: int = ...) -> int: ...
@@ -149,8 +149,10 @@ class BasicKeyCommands(Generic[_StrType]):
149149
def dump(self, name: _Key) -> _StrType | None: ...
150150
def exists(self, *names: _Key) -> int: ...
151151
__contains__ = exists
152-
def expire(self, name: _Key, time: int | timedelta) -> bool: ...
153-
def expireat(self, name, when): ...
152+
def expire(
153+
self, name: _Key, time: int | timedelta, nx: bool = ..., xx: bool = ..., gt: bool = ..., lt: bool = ...
154+
) -> bool: ...
155+
def expireat(self, name, when, nx: bool = ..., xx: bool = ..., gt: bool = ..., lt: bool = ...): ...
154156
def get(self, name: _Key) -> _StrType | None: ...
155157
def getdel(self, name: _Key) -> _StrType | None: ...
156158
def getex(
@@ -186,8 +188,12 @@ class BasicKeyCommands(Generic[_StrType]):
186188
def msetnx(self, mapping: Mapping[_Key, _Value]) -> bool: ...
187189
def move(self, name: _Key, db: int) -> bool: ...
188190
def persist(self, name: _Key) -> bool: ...
189-
def pexpire(self, name: _Key, time: int | timedelta) -> Literal[1, 0]: ...
190-
def pexpireat(self, name: _Key, when: int | datetime) -> Literal[1, 0]: ...
191+
def pexpire(
192+
self, name: _Key, time: int | timedelta, nx: bool = ..., xx: bool = ..., gt: bool = ..., lt: bool = ...
193+
) -> Literal[1, 0]: ...
194+
def pexpireat(
195+
self, name: _Key, when: int | datetime, nx: bool = ..., xx: bool = ..., gt: bool = ..., lt: bool = ...
196+
) -> Literal[1, 0]: ...
191197
def psetex(self, name, time_ms, value): ...
192198
def pttl(self, name: _Key) -> int: ...
193199
def hrandfield(self, key, count: Any | None = ..., withvalues: bool = ...): ...
@@ -396,24 +402,15 @@ class StreamCommands:
396402
def xlen(self, name: _Key) -> int: ...
397403
def xpending(self, name, groupname): ...
398404
def xpending_range(
399-
self,
400-
name,
401-
groupname,
402-
idle: Any | None = ...,
403-
min: Any | None = ...,
404-
max: Any | None = ...,
405-
count: int | None = ...,
406-
consumername: Any | None = ...,
405+
self, name: _Key, groupname, min, max, count: int, consumername: Any | None = ..., idle: int | None = ...
407406
): ...
408407
def xrange(self, name, min: str = ..., max: str = ..., count: Any | None = ...): ...
409408
def xread(self, streams, count: Any | None = ..., block: Any | None = ...): ...
410409
def xreadgroup(
411410
self, groupname, consumername, streams, count: Any | None = ..., block: Any | None = ..., noack: bool = ...
412411
): ...
413412
def xrevrange(self, name, max: str = ..., min: str = ..., count: Any | None = ...): ...
414-
def xtrim(
415-
self, name, maxlen: Any | None = ..., approximate: bool = ..., minid: Any | None = ..., limit: Any | None = ...
416-
): ...
413+
def xtrim(self, name, maxlen: int, approximate: bool = ..., minid: Any | None = ..., limit: Any | None = ...): ...
417414

418415
class SortedSetCommands(Generic[_StrType]):
419416
def zadd(
@@ -592,11 +589,13 @@ class HashCommands(Generic[_StrType]):
592589
def hkeys(self, name: _Key) -> list[_StrType]: ...
593590
def hlen(self, name: _Key) -> int: ...
594591
@overload
595-
def hset(self, name: _Key, key: _Key, value: _Value, mapping: Mapping[_Key, _Value] | None = ...) -> int: ...
592+
def hset(
593+
self, name: _Key, key: _Key, value: _Value, mapping: Mapping[_Key, _Value] | None = ..., items: Any | None = ...
594+
) -> int: ...
596595
@overload
597-
def hset(self, name: _Key, key: None, value: None, mapping: Mapping[_Key, _Value]) -> int: ...
596+
def hset(self, name: _Key, key: None, value: None, mapping: Mapping[_Key, _Value], items: Any | None = ...) -> int: ...
598597
@overload
599-
def hset(self, name: _Key, *, mapping: Mapping[_Key, _Value]) -> int: ...
598+
def hset(self, name: _Key, *, mapping: Mapping[_Key, _Value], items: Any | None = ...) -> int: ...
600599
def hsetnx(self, name: _Key, key: _Key, value: _Value) -> int: ...
601600
def hmset(self, name: _Key, mapping: Mapping[_Key, _Value]) -> bool: ...
602601
def hmget(self, name: _Key, keys: _Key | Iterable[_Key], *args: _Key) -> list[_StrType | None]: ...

stubs/redis/redis/commands/graph/__init__.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,5 @@ class Graph(GraphCommands):
2222
def add_edge(self, edge) -> None: ...
2323
def call_procedure(self, procedure, *args, read_only: bool = ..., **kwagrs): ...
2424
def labels(self): ...
25-
def relationshipTypes(self): ...
26-
def propertyKeys(self): ...
25+
def relationship_types(self): ...
26+
def property_keys(self): ...

stubs/redis/redis/commands/graph/edge.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ class Edge:
77
src_node: Any
88
dest_node: Any
99
def __init__(self, src_node, relation, dest_node, edge_id: Any | None = ..., properties: Any | None = ...) -> None: ...
10-
def toString(self): ...
10+
def to_string(self): ...
1111
def __eq__(self, rhs): ...

stubs/redis/redis/commands/graph/node.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,5 @@ class Node:
1313
label: str | list[str] | None = ...,
1414
properties: Any | None = ...,
1515
) -> None: ...
16-
def toString(self): ...
16+
def to_string(self): ...
1717
def __eq__(self, rhs): ...

stubs/redis/redis/commands/helpers.pyi

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,5 +6,5 @@ def parse_list_to_dict(response): ...
66
def parse_to_dict(response): ...
77
def random_string(length: int = ...) -> str: ...
88
def quote_string(v): ...
9-
def decodeDictKeys(obj): ...
9+
def decode_dict_keys(obj): ...
1010
def stringify_param_value(value): ...
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
class Path:
22
strPath: str
33
@staticmethod
4-
def rootPath() -> str: ...
4+
def root_path() -> str: ...
55
def __init__(self, path: str) -> None: ...

stubs/redis/redis/connection.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -136,6 +136,7 @@ class SSLConnection(Connection):
136136
ssl_certfile=...,
137137
ssl_cert_reqs=...,
138138
ssl_ca_certs=...,
139+
ssl_ca_data: Any | None = ...,
139140
ssl_check_hostname: bool = ...,
140141
ssl_ca_path: Any | None = ...,
141142
ssl_password: Any | None = ...,

stubs/redis/redis/sentinel.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ from redis.commands.sentinel import SentinelCommands
66
from redis.connection import Connection, ConnectionPool, SSLConnection
77
from redis.exceptions import ConnectionError
88

9-
_Redis = TypeVar("_Redis", bound=Redis[Any])
9+
_RedisT = TypeVar("_RedisT", bound=Redis[Any])
1010

1111
class MasterNotFoundError(ConnectionError): ...
1212
class SlaveNotFoundError(ConnectionError): ...
@@ -47,9 +47,9 @@ class Sentinel(SentinelCommands):
4747
@overload
4848
def master_for(self, service_name: str, *, connection_pool_class=..., **kwargs) -> Redis[Any]: ...
4949
@overload
50-
def master_for(self, service_name: str, redis_class: type[_Redis] = ..., connection_pool_class=..., **kwargs) -> _Redis: ...
50+
def master_for(self, service_name: str, redis_class: type[_RedisT], connection_pool_class=..., **kwargs) -> _RedisT: ...
5151
@overload
52-
def slave_for(self, service_name: str, connection_pool_class=..., **kwargs) -> Redis[Any]: ...
52+
def slave_for(self, service_name: str, *, connection_pool_class=..., **kwargs) -> Redis[Any]: ...
5353
@overload
54-
def slave_for(self, service_name: str, redis_class: type[_Redis] = ..., connection_pool_class=..., **kwargs) -> _Redis: ...
54+
def slave_for(self, service_name: str, redis_class: type[_RedisT], connection_pool_class=..., **kwargs) -> _RedisT: ...
5555
def execute_command(self, *args, **kwargs) -> Literal[True]: ...

0 commit comments

Comments
 (0)