Skip to content

Commit 3fb65de

Browse files
Combine auto-concatenated strings (#2482)
1 parent 6487f95 commit 3fb65de

20 files changed

+58
-64
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

+2-2
Original file line numberDiff line numberDiff line change
@@ -1648,7 +1648,7 @@ def set_pubsub_node(self, cluster, node=None, host=None, port=None):
16481648
pubsub_node = node
16491649
elif any([host, port]) is True:
16501650
# only 'host' or 'port' passed
1651-
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")
16521652
else:
16531653
# nothing passed by the user. set node to None
16541654
pubsub_node = None
@@ -2126,7 +2126,7 @@ def delete(self, *names):
21262126
"""
21272127
if len(names) != 1:
21282128
raise RedisClusterException(
2129-
"deleting multiple keys is not " "implemented in pipeline command"
2129+
"deleting multiple keys is not implemented in pipeline command"
21302130
)
21312131

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

redis/commands/core.py

+18-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:
@@ -1613,7 +1613,7 @@ def bitpos(
16131613
if start is not None and end is not None:
16141614
params.append(end)
16151615
elif start is None and end is not None:
1616-
raise DataError("start argument is not set, " "when end is specified")
1616+
raise DataError("start argument is not set, when end is specified")
16171617

16181618
if mode is not None:
16191619
params.append(mode)
@@ -3457,9 +3457,7 @@ def xadd(
34573457
"""
34583458
pieces: list[EncodableT] = []
34593459
if maxlen is not None and minid is not None:
3460-
raise DataError(
3461-
"Only one of ```maxlen``` or ```minid``` " "may be specified"
3462-
)
3460+
raise DataError("Only one of ```maxlen``` or ```minid``` may be specified")
34633461

34643462
if maxlen is not None:
34653463
if not isinstance(maxlen, int) or maxlen < 1:
@@ -3515,7 +3513,7 @@ def xautoclaim(
35153513
try:
35163514
if int(min_idle_time) < 0:
35173515
raise DataError(
3518-
"XAUTOCLAIM min_idle_time must be a non" "negative integer"
3516+
"XAUTOCLAIM min_idle_time must be a nonnegative integer"
35193517
)
35203518
except TypeError:
35213519
pass
@@ -3573,7 +3571,7 @@ def xclaim(
35733571
For more information see https://redis.io/commands/xclaim
35743572
"""
35753573
if not isinstance(min_idle_time, int) or min_idle_time < 0:
3576-
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")
35773575
if not isinstance(message_ids, (list, tuple)) or not message_ids:
35783576
raise DataError(
35793577
"XCLAIM message_ids must be a non empty list or "
@@ -3906,7 +3904,7 @@ def xreadgroup(
39063904
pieces.append(str(count))
39073905
if block is not None:
39083906
if not isinstance(block, int) or block < 0:
3909-
raise DataError("XREADGROUP block must be a non-negative " "integer")
3907+
raise DataError("XREADGROUP block must be a non-negative integer")
39103908
pieces.append(b"BLOCK")
39113909
pieces.append(str(block))
39123910
if noack:
@@ -3968,7 +3966,7 @@ def xtrim(
39683966
"""
39693967
pieces: list[EncodableT] = []
39703968
if maxlen is not None and minid is not None:
3971-
raise DataError("Only one of ``maxlen`` or ``minid`` " "may be specified")
3969+
raise DataError("Only one of ``maxlen`` or ``minid`` may be specified")
39723970

39733971
if maxlen is None and minid is None:
39743972
raise DataError("One of ``maxlen`` or ``minid`` must be specified")
@@ -4342,14 +4340,12 @@ def _zrange(
43424340
num: Union[int, None] = None,
43434341
) -> ResponseT:
43444342
if byscore and bylex:
4345-
raise DataError(
4346-
"``byscore`` and ``bylex`` can not be " "specified together."
4347-
)
4343+
raise DataError("``byscore`` and ``bylex`` can not be specified together.")
43484344
if (offset is not None and num is None) or (num is not None and offset is None):
43494345
raise DataError("``offset`` and ``num`` must both be specified.")
43504346
if bylex and withscores:
43514347
raise DataError(
4352-
"``withscores`` not supported in combination " "with ``bylex``."
4348+
"``withscores`` not supported in combination with ``bylex``."
43534349
)
43544350
pieces = [command]
43554351
if dest:
@@ -5301,7 +5297,7 @@ def geoadd(
53015297
if nx and xx:
53025298
raise DataError("GEOADD allows either 'nx' or 'xx', not both")
53035299
if len(values) % 3 != 0:
5304-
raise DataError("GEOADD requires places with lon, lat and name" " values")
5300+
raise DataError("GEOADD requires places with lon, lat and name values")
53055301
pieces = [name]
53065302
if nx:
53075303
pieces.append("NX")
@@ -5487,7 +5483,7 @@ def _georadiusgeneric(
54875483
raise DataError("GEORADIUS invalid sort")
54885484

54895485
if kwargs["store"] and kwargs["store_dist"]:
5490-
raise DataError("GEORADIUS store and store_dist cant be set" " together")
5486+
raise DataError("GEORADIUS store and store_dist cant be set together")
54915487

54925488
if kwargs["store"]:
54935489
pieces.extend([b"STORE", kwargs["store"]])
@@ -5624,13 +5620,11 @@ def _geosearchgeneric(
56245620
# FROMMEMBER or FROMLONLAT
56255621
if kwargs["member"] is None:
56265622
if kwargs["longitude"] is None or kwargs["latitude"] is None:
5627-
raise DataError(
5628-
"GEOSEARCH must have member or" " longitude and latitude"
5629-
)
5623+
raise DataError("GEOSEARCH must have member or longitude and latitude")
56305624
if kwargs["member"]:
56315625
if kwargs["longitude"] or kwargs["latitude"]:
56325626
raise DataError(
5633-
"GEOSEARCH member and longitude or latitude" " cant be set together"
5627+
"GEOSEARCH member and longitude or latitude cant be set together"
56345628
)
56355629
pieces.extend([b"FROMMEMBER", kwargs["member"]])
56365630
if kwargs["longitude"] is not None and kwargs["latitude"] is not None:
@@ -5639,15 +5633,15 @@ def _geosearchgeneric(
56395633
# BYRADIUS or BYBOX
56405634
if kwargs["radius"] is None:
56415635
if kwargs["width"] is None or kwargs["height"] is None:
5642-
raise DataError("GEOSEARCH must have radius or" " width and height")
5636+
raise DataError("GEOSEARCH must have radius or width and height")
56435637
if kwargs["unit"] is None:
56445638
raise DataError("GEOSEARCH must have unit")
56455639
if kwargs["unit"].lower() not in ("m", "km", "mi", "ft"):
56465640
raise DataError("GEOSEARCH invalid unit")
56475641
if kwargs["radius"]:
56485642
if kwargs["width"] or kwargs["height"]:
56495643
raise DataError(
5650-
"GEOSEARCH radius and width or height" " cant be set together"
5644+
"GEOSEARCH radius and width or height cant be set together"
56515645
)
56525646
pieces.extend([b"BYRADIUS", kwargs["radius"], kwargs["unit"]])
56535647
if kwargs["width"] and kwargs["height"]:
@@ -5668,7 +5662,7 @@ def _geosearchgeneric(
56685662
if kwargs["any"]:
56695663
pieces.append(b"ANY")
56705664
elif kwargs["any"]:
5671-
raise DataError("GEOSEARCH ``any`` can't be provided " "without count")
5665+
raise DataError("GEOSEARCH ``any`` can't be provided without count")
56725666

56735667
# other properties
56745668
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(

tests/test_asyncio/test_cluster.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -171,7 +171,7 @@ async def moved_redirection_helper(
171171
prev_primary = rc.nodes_manager.get_node_from_slot(slot)
172172
if failover:
173173
if len(rc.nodes_manager.slots_cache[slot]) < 2:
174-
warnings.warn("Skipping this test since it requires to have a " "replica")
174+
warnings.warn("Skipping this test since it requires to have a replica")
175175
return
176176
redirect_node = rc.nodes_manager.slots_cache[slot][1]
177177
else:
@@ -327,7 +327,7 @@ async def test_empty_startup_nodes(self) -> None:
327327
RedisCluster(startup_nodes=[])
328328

329329
assert str(ex.value).startswith(
330-
"RedisCluster requires at least one node to discover the " "cluster"
330+
"RedisCluster requires at least one node to discover the cluster"
331331
), str_if_bytes(ex.value)
332332

333333
async def test_from_url(self, request: FixtureRequest) -> None:
@@ -371,7 +371,7 @@ async def test_execute_command_errors(self, r: RedisCluster) -> None:
371371
with pytest.raises(RedisClusterException) as ex:
372372
await r.execute_command("GET")
373373
assert str(ex.value).startswith(
374-
"No way to dispatch this command to " "Redis Cluster. Missing key."
374+
"No way to dispatch this command to Redis Cluster. Missing key."
375375
)
376376

377377
async def test_execute_command_node_flag_primaries(self, r: RedisCluster) -> None:

tests/test_asyncio/test_commands.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ async def test_acl_getuser_setuser(self, r_teardown):
199199

200200
# Resets and tests that hashed passwords are set properly.
201201
hashed_password = (
202-
"5e884898da28047151d0e56f8dc629" "2773603d0d6aabbdd62a11ef721d1542d8"
202+
"5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"
203203
)
204204
assert await r.acl_setuser(
205205
username, enabled=True, reset=True, hashed_passwords=["+" + hashed_password]

tests/test_asyncio/test_connection_pool.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,7 @@ def test_client_name_in_querystring(self):
416416
def test_invalid_extra_typed_querystring_options(self):
417417
with pytest.raises(ValueError):
418418
redis.ConnectionPool.from_url(
419-
"redis://localhost/2?socket_timeout=_&" "socket_connect_timeout=abc"
419+
"redis://localhost/2?socket_timeout=_&socket_connect_timeout=abc"
420420
)
421421

422422
def test_extra_querystring_options(self):

0 commit comments

Comments
 (0)