Skip to content

Combine auto-concatenated strings #2482

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion benchmarks/basic_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ def parse_args():
parser.add_argument(
"-P",
type=int,
help=("Pipeline <numreq> requests." " Default 1 (no pipeline)."),
help=("Pipeline <numreq> requests. Default 1 (no pipeline)."),
default=1,
)
parser.add_argument(
Expand Down
6 changes: 3 additions & 3 deletions redis/asyncio/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1132,7 +1132,7 @@ def multi(self):
raise RedisError("Cannot issue nested calls to MULTI")
if self.command_stack:
raise RedisError(
"Commands without an initial WATCH have already " "been issued"
"Commands without an initial WATCH have already been issued"
)
self.explicit_transaction = True

Expand All @@ -1157,7 +1157,7 @@ async def _disconnect_reset_raise(self, conn, error):
if self.watching:
await self.reset()
raise WatchError(
"A ConnectionError occurred on while " "watching one or more keys"
"A ConnectionError occurred on while watching one or more keys"
)
# if retry_on_timeout is not set, or the error is not
# a TimeoutError, raise it
Expand Down Expand Up @@ -1345,7 +1345,7 @@ async def _disconnect_raise_reset(self, conn: Connection, error: Exception):
# indicates the user should retry this transaction.
if self.watching:
raise WatchError(
"A ConnectionError occurred on while " "watching one or more keys"
"A ConnectionError occurred on while watching one or more keys"
)
# if retry_on_timeout is not set, or the error is not
# a TimeoutError, raise it
Expand Down
6 changes: 3 additions & 3 deletions redis/asyncio/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -259,7 +259,7 @@ async def do_release(self, expected_token: bytes) -> None:
keys=[self.name], args=[expected_token], client=self.redis
)
):
raise LockNotOwnedError("Cannot release a lock" " that's no longer owned")
raise LockNotOwnedError("Cannot release a lock that's no longer owned")

def extend(
self, additional_time: float, replace_ttl: bool = False
Expand Down Expand Up @@ -289,7 +289,7 @@ async def do_extend(self, additional_time, replace_ttl) -> bool:
client=self.redis,
)
):
raise LockNotOwnedError("Cannot extend a lock that's" " no longer owned")
raise LockNotOwnedError("Cannot extend a lock that's no longer owned")
return True

def reacquire(self) -> Awaitable[bool]:
Expand All @@ -309,5 +309,5 @@ async def do_reacquire(self) -> bool:
keys=[self.name], args=[self.local.token, timeout], client=self.redis
)
):
raise LockNotOwnedError("Cannot reacquire a lock that's" " no longer owned")
raise LockNotOwnedError("Cannot reacquire a lock that's no longer owned")
return True
8 changes: 4 additions & 4 deletions redis/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1881,7 +1881,7 @@ def multi(self):
raise RedisError("Cannot issue nested calls to MULTI")
if self.command_stack:
raise RedisError(
"Commands without an initial WATCH have already " "been issued"
"Commands without an initial WATCH have already been issued"
)
self.explicit_transaction = True

Expand All @@ -1904,7 +1904,7 @@ def _disconnect_reset_raise(self, conn, error):
if self.watching:
self.reset()
raise WatchError(
"A ConnectionError occurred on while " "watching one or more keys"
"A ConnectionError occurred on while watching one or more keys"
)
# if retry_on_timeout is not set, or the error is not
# a TimeoutError, raise it
Expand Down Expand Up @@ -1997,7 +1997,7 @@ def _execute_transaction(self, connection, commands, raise_on_error):
if len(response) != len(commands):
self.connection.disconnect()
raise ResponseError(
"Wrong number of response items from " "pipeline execution"
"Wrong number of response items from pipeline execution"
)

# find any errors in the response and raise if necessary
Expand Down Expand Up @@ -2078,7 +2078,7 @@ def _disconnect_raise_reset(self, conn, error):
# indicates the user should retry this transaction.
if self.watching:
raise WatchError(
"A ConnectionError occurred on while " "watching one or more keys"
"A ConnectionError occurred on while watching one or more keys"
)
# if retry_on_timeout is not set, or the error is not
# a TimeoutError, raise it
Expand Down
4 changes: 2 additions & 2 deletions redis/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -1645,7 +1645,7 @@ def set_pubsub_node(self, cluster, node=None, host=None, port=None):
pubsub_node = node
elif any([host, port]) is True:
# only 'host' or 'port' passed
raise DataError("Passing a host requires passing a port, " "and vice versa")
raise DataError("Passing a host requires passing a port, and vice versa")
else:
# nothing passed by the user. set node to None
pubsub_node = None
Expand Down Expand Up @@ -2123,7 +2123,7 @@ def delete(self, *names):
"""
if len(names) != 1:
raise RedisClusterException(
"deleting multiple keys is not " "implemented in pipeline command"
"deleting multiple keys is not implemented in pipeline command"
)

return self.execute_command("DEL", names[0])
Expand Down
42 changes: 18 additions & 24 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ def acl_genpass(self, bits: Union[int, None] = None, **kwargs) -> ResponseT:
raise ValueError
except ValueError:
raise DataError(
"genpass optionally accepts a bits argument, " "between 0 and 4096."
"genpass optionally accepts a bits argument, between 0 and 4096."
)
return self.execute_command("ACL GENPASS", *pieces, **kwargs)

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

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

if (passwords or hashed_passwords) and nopass:
raise DataError(
"Cannot set 'nopass' and supply " "'passwords' or 'hashed_passwords'"
"Cannot set 'nopass' and supply 'passwords' or 'hashed_passwords'"
)

if passwords:
Expand Down Expand Up @@ -1561,7 +1561,7 @@ def bitpos(
if start is not None and end is not None:
params.append(end)
elif start is None and end is not None:
raise DataError("start argument is not set, " "when end is specified")
raise DataError("start argument is not set, when end is specified")

if mode is not None:
params.append(mode)
Expand Down Expand Up @@ -3405,9 +3405,7 @@ def xadd(
"""
pieces: list[EncodableT] = []
if maxlen is not None and minid is not None:
raise DataError(
"Only one of ```maxlen``` or ```minid``` " "may be specified"
)
raise DataError("Only one of ```maxlen``` or ```minid``` may be specified")

if maxlen is not None:
if not isinstance(maxlen, int) or maxlen < 1:
Expand Down Expand Up @@ -3463,7 +3461,7 @@ def xautoclaim(
try:
if int(min_idle_time) < 0:
raise DataError(
"XAUTOCLAIM min_idle_time must be a non" "negative integer"
"XAUTOCLAIM min_idle_time must be a nonnegative integer"
)
except TypeError:
pass
Expand Down Expand Up @@ -3521,7 +3519,7 @@ def xclaim(
For more information see https://redis.io/commands/xclaim
"""
if not isinstance(min_idle_time, int) or min_idle_time < 0:
raise DataError("XCLAIM min_idle_time must be a non negative " "integer")
raise DataError("XCLAIM min_idle_time must be a non negative integer")
if not isinstance(message_ids, (list, tuple)) or not message_ids:
raise DataError(
"XCLAIM message_ids must be a non empty list or "
Expand Down Expand Up @@ -3854,7 +3852,7 @@ def xreadgroup(
pieces.append(str(count))
if block is not None:
if not isinstance(block, int) or block < 0:
raise DataError("XREADGROUP block must be a non-negative " "integer")
raise DataError("XREADGROUP block must be a non-negative integer")
pieces.append(b"BLOCK")
pieces.append(str(block))
if noack:
Expand Down Expand Up @@ -3916,7 +3914,7 @@ def xtrim(
"""
pieces: list[EncodableT] = []
if maxlen is not None and minid is not None:
raise DataError("Only one of ``maxlen`` or ``minid`` " "may be specified")
raise DataError("Only one of ``maxlen`` or ``minid`` may be specified")

if maxlen is None and minid is None:
raise DataError("One of ``maxlen`` or ``minid`` must be specified")
Expand Down Expand Up @@ -4290,14 +4288,12 @@ def _zrange(
num: Union[int, None] = None,
) -> ResponseT:
if byscore and bylex:
raise DataError(
"``byscore`` and ``bylex`` can not be " "specified together."
)
raise DataError("``byscore`` and ``bylex`` can not be specified together.")
if (offset is not None and num is None) or (num is not None and offset is None):
raise DataError("``offset`` and ``num`` must both be specified.")
if bylex and withscores:
raise DataError(
"``withscores`` not supported in combination " "with ``bylex``."
"``withscores`` not supported in combination with ``bylex``."
)
pieces = [command]
if dest:
Expand Down Expand Up @@ -5249,7 +5245,7 @@ def geoadd(
if nx and xx:
raise DataError("GEOADD allows either 'nx' or 'xx', not both")
if len(values) % 3 != 0:
raise DataError("GEOADD requires places with lon, lat and name" " values")
raise DataError("GEOADD requires places with lon, lat and name values")
pieces = [name]
if nx:
pieces.append("NX")
Expand Down Expand Up @@ -5435,7 +5431,7 @@ def _georadiusgeneric(
raise DataError("GEORADIUS invalid sort")

if kwargs["store"] and kwargs["store_dist"]:
raise DataError("GEORADIUS store and store_dist cant be set" " together")
raise DataError("GEORADIUS store and store_dist cant be set together")

if kwargs["store"]:
pieces.extend([b"STORE", kwargs["store"]])
Expand Down Expand Up @@ -5572,13 +5568,11 @@ def _geosearchgeneric(
# FROMMEMBER or FROMLONLAT
if kwargs["member"] is None:
if kwargs["longitude"] is None or kwargs["latitude"] is None:
raise DataError(
"GEOSEARCH must have member or" " longitude and latitude"
)
raise DataError("GEOSEARCH must have member or longitude and latitude")
if kwargs["member"]:
if kwargs["longitude"] or kwargs["latitude"]:
raise DataError(
"GEOSEARCH member and longitude or latitude" " cant be set together"
"GEOSEARCH member and longitude or latitude cant be set together"
)
pieces.extend([b"FROMMEMBER", kwargs["member"]])
if kwargs["longitude"] is not None and kwargs["latitude"] is not None:
Expand All @@ -5587,15 +5581,15 @@ def _geosearchgeneric(
# BYRADIUS or BYBOX
if kwargs["radius"] is None:
if kwargs["width"] is None or kwargs["height"] is None:
raise DataError("GEOSEARCH must have radius or" " width and height")
raise DataError("GEOSEARCH must have radius or width and height")
if kwargs["unit"] is None:
raise DataError("GEOSEARCH must have unit")
if kwargs["unit"].lower() not in ("m", "km", "mi", "ft"):
raise DataError("GEOSEARCH invalid unit")
if kwargs["radius"]:
if kwargs["width"] or kwargs["height"]:
raise DataError(
"GEOSEARCH radius and width or height" " cant be set together"
"GEOSEARCH radius and width or height cant be set together"
)
pieces.extend([b"BYRADIUS", kwargs["radius"], kwargs["unit"]])
if kwargs["width"] and kwargs["height"]:
Expand All @@ -5616,7 +5610,7 @@ def _geosearchgeneric(
if kwargs["any"]:
pieces.append(b"ANY")
elif kwargs["any"]:
raise DataError("GEOSEARCH ``any`` can't be provided " "without count")
raise DataError("GEOSEARCH ``any`` can't be provided without count")

# other properties
for arg_name, byte_repr in (
Expand Down
2 changes: 1 addition & 1 deletion redis/commands/graph/node.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def __init__(self, node_id=None, alias=None, label=None, properties=None):
self.labels = label
else:
raise AssertionError(
"label should be either None, " "string or a list of strings"
"label should be either None, string or a list of strings"
)

self.properties = properties or {}
Expand Down
2 changes: 1 addition & 1 deletion redis/commands/search/commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -527,7 +527,7 @@ def profile(
cmd += query.get_args()
cmd += self.get_params_args(query_params)
else:
raise ValueError("Must provide AggregateRequest object or " "Query object.")
raise ValueError("Must provide AggregateRequest object or Query object.")

res = self.execute_command(*cmd)

Expand Down
4 changes: 2 additions & 2 deletions redis/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@
SERVER_CLOSED_CONNECTION_ERROR = "Connection closed by server."

SENTINEL = object()
MODULE_LOAD_ERROR = "Error loading the extension. " "Please check the server logs."
MODULE_LOAD_ERROR = "Error loading the extension. Please check the server logs."
NO_SUCH_MODULE_ERROR = "Error unloading module: no such module with that name"
MODULE_UNLOAD_NOT_POSSIBLE_ERROR = "Error unloading module: operation not " "possible."
MODULE_UNLOAD_NOT_POSSIBLE_ERROR = "Error unloading module: operation not possible."
MODULE_EXPORTS_DATA_TYPES_ERROR = (
"Error unloading module: the module "
"exports one or more module-side data "
Expand Down
2 changes: 1 addition & 1 deletion redis/lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -256,7 +256,7 @@ def do_release(self, expected_token: str) -> None:
if not bool(
self.lua_release(keys=[self.name], args=[expected_token], client=self.redis)
):
raise LockNotOwnedError("Cannot release a lock" " that's no longer owned")
raise LockNotOwnedError("Cannot release a lock that's no longer owned")

def extend(self, additional_time: int, replace_ttl: bool = False) -> bool:
"""
Expand Down
4 changes: 2 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ def pytest_addoption(parser):
"--redis-url",
default=default_redis_url,
action="store",
help="Redis connection string," " defaults to `%(default)s`",
help="Redis connection string, defaults to `%(default)s`",
)

parser.addoption(
Expand All @@ -93,7 +93,7 @@ def pytest_addoption(parser):
"--redis-ssl-url",
default=default_redis_ssl_url,
action="store",
help="Redis SSL connection string," " defaults to `%(default)s`",
help="Redis SSL connection string, defaults to `%(default)s`",
)

parser.addoption(
Expand Down
6 changes: 3 additions & 3 deletions tests/test_asyncio/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -171,7 +171,7 @@ async def moved_redirection_helper(
prev_primary = rc.nodes_manager.get_node_from_slot(slot)
if failover:
if len(rc.nodes_manager.slots_cache[slot]) < 2:
warnings.warn("Skipping this test since it requires to have a " "replica")
warnings.warn("Skipping this test since it requires to have a replica")
return
redirect_node = rc.nodes_manager.slots_cache[slot][1]
else:
Expand Down Expand Up @@ -327,7 +327,7 @@ async def test_empty_startup_nodes(self) -> None:
RedisCluster(startup_nodes=[])

assert str(ex.value).startswith(
"RedisCluster requires at least one node to discover the " "cluster"
"RedisCluster requires at least one node to discover the cluster"
), str_if_bytes(ex.value)

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

async def test_execute_command_node_flag_primaries(self, r: RedisCluster) -> None:
Expand Down
2 changes: 1 addition & 1 deletion tests/test_asyncio/test_commands.py
Original file line number Diff line number Diff line change
Expand Up @@ -199,7 +199,7 @@ async def test_acl_getuser_setuser(self, r_teardown):

# Resets and tests that hashed passwords are set properly.
hashed_password = (
"5e884898da28047151d0e56f8dc629" "2773603d0d6aabbdd62a11ef721d1542d8"
"5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8"
)
assert await r.acl_setuser(
username, enabled=True, reset=True, hashed_passwords=["+" + hashed_password]
Expand Down
2 changes: 1 addition & 1 deletion tests/test_asyncio/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -416,7 +416,7 @@ def test_client_name_in_querystring(self):
def test_invalid_extra_typed_querystring_options(self):
with pytest.raises(ValueError):
redis.ConnectionPool.from_url(
"redis://localhost/2?socket_timeout=_&" "socket_connect_timeout=abc"
"redis://localhost/2?socket_timeout=_&socket_connect_timeout=abc"
)

def test_extra_querystring_options(self):
Expand Down
Loading