Skip to content

Commit 6a36b35

Browse files
Merge branch 'master' into kristjan/python-parser-state2
2 parents 5f3efe3 + 3fb65de commit 6a36b35

20 files changed

+94
-66
lines changed

benchmarks/basic_operations.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ def parse_args():
1313
parser.add_argument(
1414
"-P",
1515
type=int,
16-
help=("Pipeline <numreq> requests." " Default 1 (no pipeline)."),
16+
help=("Pipeline <numreq> requests. Default 1 (no pipeline)."),
1717
default=1,
1818
)
1919
parser.add_argument(

redis/asyncio/client.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1132,7 +1132,7 @@ def multi(self):
11321132
raise RedisError("Cannot issue nested calls to MULTI")
11331133
if self.command_stack:
11341134
raise RedisError(
1135-
"Commands without an initial WATCH have already " "been issued"
1135+
"Commands without an initial WATCH have already been issued"
11361136
)
11371137
self.explicit_transaction = True
11381138

@@ -1157,7 +1157,7 @@ async def _disconnect_reset_raise(self, conn, error):
11571157
if self.watching:
11581158
await self.reset()
11591159
raise WatchError(
1160-
"A ConnectionError occurred on while " "watching one or more keys"
1160+
"A ConnectionError occurred on while watching one or more keys"
11611161
)
11621162
# if retry_on_timeout is not set, or the error is not
11631163
# a TimeoutError, raise it
@@ -1345,7 +1345,7 @@ async def _disconnect_raise_reset(self, conn: Connection, error: Exception):
13451345
# indicates the user should retry this transaction.
13461346
if self.watching:
13471347
raise WatchError(
1348-
"A ConnectionError occurred on while " "watching one or more keys"
1348+
"A ConnectionError occurred on while watching one or more keys"
13491349
)
13501350
# if retry_on_timeout is not set, or the error is not
13511351
# a TimeoutError, raise it

redis/asyncio/lock.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -259,7 +259,7 @@ async def do_release(self, expected_token: bytes) -> None:
259259
keys=[self.name], args=[expected_token], client=self.redis
260260
)
261261
):
262-
raise LockNotOwnedError("Cannot release a lock" " that's no longer owned")
262+
raise LockNotOwnedError("Cannot release a lock that's no longer owned")
263263

264264
def extend(
265265
self, additional_time: float, replace_ttl: bool = False
@@ -289,7 +289,7 @@ async def do_extend(self, additional_time, replace_ttl) -> bool:
289289
client=self.redis,
290290
)
291291
):
292-
raise LockNotOwnedError("Cannot extend a lock that's" " no longer owned")
292+
raise LockNotOwnedError("Cannot extend a lock that's no longer owned")
293293
return True
294294

295295
def reacquire(self) -> Awaitable[bool]:
@@ -309,5 +309,5 @@ async def do_reacquire(self) -> bool:
309309
keys=[self.name], args=[self.local.token, timeout], client=self.redis
310310
)
311311
):
312-
raise LockNotOwnedError("Cannot reacquire a lock that's" " no longer owned")
312+
raise LockNotOwnedError("Cannot reacquire a lock that's no longer owned")
313313
return True

redis/client.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -1881,7 +1881,7 @@ def multi(self):
18811881
raise RedisError("Cannot issue nested calls to MULTI")
18821882
if self.command_stack:
18831883
raise RedisError(
1884-
"Commands without an initial WATCH have already " "been issued"
1884+
"Commands without an initial WATCH have already been issued"
18851885
)
18861886
self.explicit_transaction = True
18871887

@@ -1904,7 +1904,7 @@ def _disconnect_reset_raise(self, conn, error):
19041904
if self.watching:
19051905
self.reset()
19061906
raise WatchError(
1907-
"A ConnectionError occurred on while " "watching one or more keys"
1907+
"A ConnectionError occurred on while watching one or more keys"
19081908
)
19091909
# if retry_on_timeout is not set, or the error is not
19101910
# a TimeoutError, raise it
@@ -1997,7 +1997,7 @@ def _execute_transaction(self, connection, commands, raise_on_error):
19971997
if len(response) != len(commands):
19981998
self.connection.disconnect()
19991999
raise ResponseError(
2000-
"Wrong number of response items from " "pipeline execution"
2000+
"Wrong number of response items from pipeline execution"
20012001
)
20022002

20032003
# find any errors in the response and raise if necessary
@@ -2078,7 +2078,7 @@ def _disconnect_raise_reset(self, conn, error):
20782078
# indicates the user should retry this transaction.
20792079
if self.watching:
20802080
raise WatchError(
2081-
"A ConnectionError occurred on while " "watching one or more keys"
2081+
"A ConnectionError occurred on while watching one or more keys"
20822082
)
20832083
# if retry_on_timeout is not set, or the error is not
20842084
# a TimeoutError, raise it

redis/cluster.py

+5-2
Original file line numberDiff line numberDiff line change
@@ -265,6 +265,9 @@ class AbstractRedisCluster:
265265
"READWRITE",
266266
"TIME",
267267
"GRAPH.CONFIG",
268+
"LATENCY HISTORY",
269+
"LATENCY LATEST",
270+
"LATENCY RESET",
268271
],
269272
DEFAULT_NODE,
270273
),
@@ -1645,7 +1648,7 @@ def set_pubsub_node(self, cluster, node=None, host=None, port=None):
16451648
pubsub_node = node
16461649
elif any([host, port]) is True:
16471650
# only 'host' or 'port' passed
1648-
raise DataError("Passing a host requires passing a port, " "and vice versa")
1651+
raise DataError("Passing a host requires passing a port, and vice versa")
16491652
else:
16501653
# nothing passed by the user. set node to None
16511654
pubsub_node = None
@@ -2123,7 +2126,7 @@ def delete(self, *names):
21232126
"""
21242127
if len(names) != 1:
21252128
raise RedisClusterException(
2126-
"deleting multiple keys is not " "implemented in pipeline command"
2129+
"deleting multiple keys is not implemented in pipeline command"
21272130
)
21282131

21292132
return self.execute_command("DEL", names[0])

redis/commands/core.py

+42-24
Original file line numberDiff line numberDiff line change
@@ -101,7 +101,7 @@ def acl_genpass(self, bits: Union[int, None] = None, **kwargs) -> ResponseT:
101101
raise ValueError
102102
except ValueError:
103103
raise DataError(
104-
"genpass optionally accepts a bits argument, " "between 0 and 4096."
104+
"genpass optionally accepts a bits argument, between 0 and 4096."
105105
)
106106
return self.execute_command("ACL GENPASS", *pieces, **kwargs)
107107

@@ -142,7 +142,7 @@ def acl_log(self, count: Union[int, None] = None, **kwargs) -> ResponseT:
142142
args = []
143143
if count is not None:
144144
if not isinstance(count, int):
145-
raise DataError("ACL LOG count must be an " "integer")
145+
raise DataError("ACL LOG count must be an integer")
146146
args.append(count)
147147

148148
return self.execute_command("ACL LOG", *args, **kwargs)
@@ -276,7 +276,7 @@ def acl_setuser(
276276

277277
if (passwords or hashed_passwords) and nopass:
278278
raise DataError(
279-
"Cannot set 'nopass' and supply " "'passwords' or 'hashed_passwords'"
279+
"Cannot set 'nopass' and supply 'passwords' or 'hashed_passwords'"
280280
)
281281

282282
if passwords:
@@ -1151,6 +1151,30 @@ def latency_histogram(self, *args):
11511151
"LATENCY HISTOGRAM is intentionally not implemented in the client."
11521152
)
11531153

1154+
def latency_history(self, event: str) -> ResponseT:
1155+
"""
1156+
Returns the raw data of the ``event``'s latency spikes time series.
1157+
1158+
For more information see https://redis.io/commands/latency-history
1159+
"""
1160+
return self.execute_command("LATENCY HISTORY", event)
1161+
1162+
def latency_latest(self) -> ResponseT:
1163+
"""
1164+
Reports the latest latency events logged.
1165+
1166+
For more information see https://redis.io/commands/latency-latest
1167+
"""
1168+
return self.execute_command("LATENCY LATEST")
1169+
1170+
def latency_reset(self, *events: str) -> ResponseT:
1171+
"""
1172+
Resets the latency spikes time series of all, or only some, events.
1173+
1174+
For more information see https://redis.io/commands/latency-reset
1175+
"""
1176+
return self.execute_command("LATENCY RESET", *events)
1177+
11541178
def ping(self, **kwargs) -> ResponseT:
11551179
"""
11561180
Ping the Redis server
@@ -1589,7 +1613,7 @@ def bitpos(
15891613
if start is not None and end is not None:
15901614
params.append(end)
15911615
elif start is None and end is not None:
1592-
raise DataError("start argument is not set, " "when end is specified")
1616+
raise DataError("start argument is not set, when end is specified")
15931617

15941618
if mode is not None:
15951619
params.append(mode)
@@ -3433,9 +3457,7 @@ def xadd(
34333457
"""
34343458
pieces: list[EncodableT] = []
34353459
if maxlen is not None and minid is not None:
3436-
raise DataError(
3437-
"Only one of ```maxlen``` or ```minid``` " "may be specified"
3438-
)
3460+
raise DataError("Only one of ```maxlen``` or ```minid``` may be specified")
34393461

34403462
if maxlen is not None:
34413463
if not isinstance(maxlen, int) or maxlen < 1:
@@ -3491,7 +3513,7 @@ def xautoclaim(
34913513
try:
34923514
if int(min_idle_time) < 0:
34933515
raise DataError(
3494-
"XAUTOCLAIM min_idle_time must be a non" "negative integer"
3516+
"XAUTOCLAIM min_idle_time must be a nonnegative integer"
34953517
)
34963518
except TypeError:
34973519
pass
@@ -3549,7 +3571,7 @@ def xclaim(
35493571
For more information see https://redis.io/commands/xclaim
35503572
"""
35513573
if not isinstance(min_idle_time, int) or min_idle_time < 0:
3552-
raise DataError("XCLAIM min_idle_time must be a non negative " "integer")
3574+
raise DataError("XCLAIM min_idle_time must be a non negative integer")
35533575
if not isinstance(message_ids, (list, tuple)) or not message_ids:
35543576
raise DataError(
35553577
"XCLAIM message_ids must be a non empty list or "
@@ -3882,7 +3904,7 @@ def xreadgroup(
38823904
pieces.append(str(count))
38833905
if block is not None:
38843906
if not isinstance(block, int) or block < 0:
3885-
raise DataError("XREADGROUP block must be a non-negative " "integer")
3907+
raise DataError("XREADGROUP block must be a non-negative integer")
38863908
pieces.append(b"BLOCK")
38873909
pieces.append(str(block))
38883910
if noack:
@@ -3944,7 +3966,7 @@ def xtrim(
39443966
"""
39453967
pieces: list[EncodableT] = []
39463968
if maxlen is not None and minid is not None:
3947-
raise DataError("Only one of ``maxlen`` or ``minid`` " "may be specified")
3969+
raise DataError("Only one of ``maxlen`` or ``minid`` may be specified")
39483970

39493971
if maxlen is None and minid is None:
39503972
raise DataError("One of ``maxlen`` or ``minid`` must be specified")
@@ -4318,14 +4340,12 @@ def _zrange(
43184340
num: Union[int, None] = None,
43194341
) -> ResponseT:
43204342
if byscore and bylex:
4321-
raise DataError(
4322-
"``byscore`` and ``bylex`` can not be " "specified together."
4323-
)
4343+
raise DataError("``byscore`` and ``bylex`` can not be specified together.")
43244344
if (offset is not None and num is None) or (num is not None and offset is None):
43254345
raise DataError("``offset`` and ``num`` must both be specified.")
43264346
if bylex and withscores:
43274347
raise DataError(
4328-
"``withscores`` not supported in combination " "with ``bylex``."
4348+
"``withscores`` not supported in combination with ``bylex``."
43294349
)
43304350
pieces = [command]
43314351
if dest:
@@ -5277,7 +5297,7 @@ def geoadd(
52775297
if nx and xx:
52785298
raise DataError("GEOADD allows either 'nx' or 'xx', not both")
52795299
if len(values) % 3 != 0:
5280-
raise DataError("GEOADD requires places with lon, lat and name" " values")
5300+
raise DataError("GEOADD requires places with lon, lat and name values")
52815301
pieces = [name]
52825302
if nx:
52835303
pieces.append("NX")
@@ -5463,7 +5483,7 @@ def _georadiusgeneric(
54635483
raise DataError("GEORADIUS invalid sort")
54645484

54655485
if kwargs["store"] and kwargs["store_dist"]:
5466-
raise DataError("GEORADIUS store and store_dist cant be set" " together")
5486+
raise DataError("GEORADIUS store and store_dist cant be set together")
54675487

54685488
if kwargs["store"]:
54695489
pieces.extend([b"STORE", kwargs["store"]])
@@ -5600,13 +5620,11 @@ def _geosearchgeneric(
56005620
# FROMMEMBER or FROMLONLAT
56015621
if kwargs["member"] is None:
56025622
if kwargs["longitude"] is None or kwargs["latitude"] is None:
5603-
raise DataError(
5604-
"GEOSEARCH must have member or" " longitude and latitude"
5605-
)
5623+
raise DataError("GEOSEARCH must have member or longitude and latitude")
56065624
if kwargs["member"]:
56075625
if kwargs["longitude"] or kwargs["latitude"]:
56085626
raise DataError(
5609-
"GEOSEARCH member and longitude or latitude" " cant be set together"
5627+
"GEOSEARCH member and longitude or latitude cant be set together"
56105628
)
56115629
pieces.extend([b"FROMMEMBER", kwargs["member"]])
56125630
if kwargs["longitude"] is not None and kwargs["latitude"] is not None:
@@ -5615,15 +5633,15 @@ def _geosearchgeneric(
56155633
# BYRADIUS or BYBOX
56165634
if kwargs["radius"] is None:
56175635
if kwargs["width"] is None or kwargs["height"] is None:
5618-
raise DataError("GEOSEARCH must have radius or" " width and height")
5636+
raise DataError("GEOSEARCH must have radius or width and height")
56195637
if kwargs["unit"] is None:
56205638
raise DataError("GEOSEARCH must have unit")
56215639
if kwargs["unit"].lower() not in ("m", "km", "mi", "ft"):
56225640
raise DataError("GEOSEARCH invalid unit")
56235641
if kwargs["radius"]:
56245642
if kwargs["width"] or kwargs["height"]:
56255643
raise DataError(
5626-
"GEOSEARCH radius and width or height" " cant be set together"
5644+
"GEOSEARCH radius and width or height cant be set together"
56275645
)
56285646
pieces.extend([b"BYRADIUS", kwargs["radius"], kwargs["unit"]])
56295647
if kwargs["width"] and kwargs["height"]:
@@ -5644,7 +5662,7 @@ def _geosearchgeneric(
56445662
if kwargs["any"]:
56455663
pieces.append(b"ANY")
56465664
elif kwargs["any"]:
5647-
raise DataError("GEOSEARCH ``any`` can't be provided " "without count")
5665+
raise DataError("GEOSEARCH ``any`` can't be provided without count")
56485666

56495667
# other properties
56505668
for arg_name, byte_repr in (

redis/commands/graph/node.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,7 @@ def __init__(self, node_id=None, alias=None, label=None, properties=None):
3232
self.labels = label
3333
else:
3434
raise AssertionError(
35-
"label should be either None, " "string or a list of strings"
35+
"label should be either None, string or a list of strings"
3636
)
3737

3838
self.properties = properties or {}

redis/commands/search/commands.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -527,7 +527,7 @@ def profile(
527527
cmd += query.get_args()
528528
cmd += self.get_params_args(query_params)
529529
else:
530-
raise ValueError("Must provide AggregateRequest object or " "Query object.")
530+
raise ValueError("Must provide AggregateRequest object or Query object.")
531531

532532
res = self.execute_command(*cmd)
533533

redis/connection.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@
6262
SERVER_CLOSED_CONNECTION_ERROR = "Connection closed by server."
6363

6464
SENTINEL = object()
65-
MODULE_LOAD_ERROR = "Error loading the extension. " "Please check the server logs."
65+
MODULE_LOAD_ERROR = "Error loading the extension. Please check the server logs."
6666
NO_SUCH_MODULE_ERROR = "Error unloading module: no such module with that name"
67-
MODULE_UNLOAD_NOT_POSSIBLE_ERROR = "Error unloading module: operation not " "possible."
67+
MODULE_UNLOAD_NOT_POSSIBLE_ERROR = "Error unloading module: operation not possible."
6868
MODULE_EXPORTS_DATA_TYPES_ERROR = (
6969
"Error unloading module: the module "
7070
"exports one or more module-side data "

redis/lock.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,7 @@ def do_release(self, expected_token: str) -> None:
256256
if not bool(
257257
self.lua_release(keys=[self.name], args=[expected_token], client=self.redis)
258258
):
259-
raise LockNotOwnedError("Cannot release a lock" " that's no longer owned")
259+
raise LockNotOwnedError("Cannot release a lock that's no longer owned")
260260

261261
def extend(self, additional_time: int, replace_ttl: bool = False) -> bool:
262262
"""

tests/conftest.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def pytest_addoption(parser):
7777
"--redis-url",
7878
default=default_redis_url,
7979
action="store",
80-
help="Redis connection string," " defaults to `%(default)s`",
80+
help="Redis connection string, defaults to `%(default)s`",
8181
)
8282

8383
parser.addoption(
@@ -93,7 +93,7 @@ def pytest_addoption(parser):
9393
"--redis-ssl-url",
9494
default=default_redis_ssl_url,
9595
action="store",
96-
help="Redis SSL connection string," " defaults to `%(default)s`",
96+
help="Redis SSL connection string, defaults to `%(default)s`",
9797
)
9898

9999
parser.addoption(

0 commit comments

Comments
 (0)