diff --git a/benchmarks/basic_operations.py b/benchmarks/basic_operations.py index 1dc4a87cc8..c9f5853652 100644 --- a/benchmarks/basic_operations.py +++ b/benchmarks/basic_operations.py @@ -13,7 +13,7 @@ def parse_args(): parser.add_argument( "-P", type=int, - help=("Pipeline requests." " Default 1 (no pipeline)."), + help=("Pipeline requests. Default 1 (no pipeline)."), default=1, ) parser.add_argument( diff --git a/redis/asyncio/client.py b/redis/asyncio/client.py index abe7d67463..5a2c496661 100644 --- a/redis/asyncio/client.py +++ b/redis/asyncio/client.py @@ -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 @@ -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 @@ -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 diff --git a/redis/asyncio/lock.py b/redis/asyncio/lock.py index 7f45c8be66..2f78d69aee 100644 --- a/redis/asyncio/lock.py +++ b/redis/asyncio/lock.py @@ -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 @@ -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]: @@ -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 diff --git a/redis/client.py b/redis/client.py index ed857c8fba..1a9b96b83d 100755 --- a/redis/client.py +++ b/redis/client.py @@ -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 @@ -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 @@ -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 @@ -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 diff --git a/redis/cluster.py b/redis/cluster.py index 0b2c4f1387..a55872de00 100644 --- a/redis/cluster.py +++ b/redis/cluster.py @@ -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 @@ -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]) diff --git a/redis/commands/core.py b/redis/commands/core.py index 1625e10d9c..633bdda5e6 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -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) @@ -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) @@ -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: @@ -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) @@ -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: @@ -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 @@ -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 " @@ -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: @@ -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") @@ -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: @@ -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") @@ -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"]]) @@ -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: @@ -5587,7 +5581,7 @@ 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"): @@ -5595,7 +5589,7 @@ def _geosearchgeneric( 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"]: @@ -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 ( diff --git a/redis/commands/graph/node.py b/redis/commands/graph/node.py index c5f842906b..0ebe510ada 100644 --- a/redis/commands/graph/node.py +++ b/redis/commands/graph/node.py @@ -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 {} diff --git a/redis/commands/search/commands.py b/redis/commands/search/commands.py index f02805ee2b..3bd7d47aa8 100644 --- a/redis/commands/search/commands.py +++ b/redis/commands/search/commands.py @@ -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) diff --git a/redis/connection.py b/redis/connection.py index 9c5b536f89..dce0735450 100755 --- a/redis/connection.py +++ b/redis/connection.py @@ -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 " diff --git a/redis/lock.py b/redis/lock.py index 912ff57819..4cca102d10 100644 --- a/redis/lock.py +++ b/redis/lock.py @@ -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: """ diff --git a/tests/conftest.py b/tests/conftest.py index 3d40375052..27dcc741a7 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -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( @@ -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( diff --git a/tests/test_asyncio/test_cluster.py b/tests/test_asyncio/test_cluster.py index 1997c9520b..13e5e26ae3 100644 --- a/tests/test_asyncio/test_cluster.py +++ b/tests/test_asyncio/test_cluster.py @@ -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: @@ -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: @@ -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: diff --git a/tests/test_asyncio/test_commands.py b/tests/test_asyncio/test_commands.py index 67471bb4b3..7c6fd45ab9 100644 --- a/tests/test_asyncio/test_commands.py +++ b/tests/test_asyncio/test_commands.py @@ -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] diff --git a/tests/test_asyncio/test_connection_pool.py b/tests/test_asyncio/test_connection_pool.py index 35f23f44cc..5de25f265b 100644 --- a/tests/test_asyncio/test_connection_pool.py +++ b/tests/test_asyncio/test_connection_pool.py @@ -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): diff --git a/tests/test_asyncio/test_pipeline.py b/tests/test_asyncio/test_pipeline.py index d613f490a5..3df57eb90f 100644 --- a/tests/test_asyncio/test_pipeline.py +++ b/tests/test_asyncio/test_pipeline.py @@ -124,7 +124,7 @@ async def test_exec_error_raised(self, r): with pytest.raises(redis.ResponseError) as ex: await pipe.execute() assert str(ex.value).startswith( - "Command # 3 (LPUSH c 3) of " "pipeline caused error: " + "Command # 3 (LPUSH c 3) of pipeline caused error: " ) # make sure the pipe was restored to a working state @@ -169,7 +169,7 @@ async def test_parse_error_raised(self, r): await pipe.execute() assert str(ex.value).startswith( - "Command # 2 (ZREM b) of " "pipeline caused error: " + "Command # 2 (ZREM b) of pipeline caused error: " ) # make sure the pipe was restored to a working state @@ -186,7 +186,7 @@ async def test_parse_error_raised_transaction(self, r): await pipe.execute() assert str(ex.value).startswith( - "Command # 2 (ZREM b) of " "pipeline caused error: " + "Command # 2 (ZREM b) of pipeline caused error: " ) # make sure the pipe was restored to a working state @@ -333,7 +333,7 @@ async def test_exec_error_in_no_transaction_pipeline(self, r): await pipe.execute() assert str(ex.value).startswith( - "Command # 1 (LLEN a) of " "pipeline caused error: " + "Command # 1 (LLEN a) of pipeline caused error: " ) assert await r.get("a") == b"1" diff --git a/tests/test_asyncio/test_pubsub.py b/tests/test_asyncio/test_pubsub.py index 6dedca9ab5..37b7206720 100644 --- a/tests/test_asyncio/test_pubsub.py +++ b/tests/test_asyncio/test_pubsub.py @@ -411,7 +411,7 @@ async def test_get_message_without_subscribe(self, r: redis.Redis, pubsub): with pytest.raises(RuntimeError) as info: await p.get_message() expect = ( - "connection not set: " "did you forget to call subscribe() or psubscribe()?" + "connection not set: did you forget to call subscribe() or psubscribe()?" ) assert expect in info.exconly() diff --git a/tests/test_cluster.py b/tests/test_cluster.py index 43aeb9e045..e45780d119 100644 --- a/tests/test_cluster.py +++ b/tests/test_cluster.py @@ -176,7 +176,7 @@ def moved_redirection_helper(request, failover=False): 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: @@ -244,7 +244,7 @@ def test_empty_startup_nodes(self): 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) def test_from_url(self, r): @@ -265,7 +265,7 @@ def test_execute_command_errors(self, r): with pytest.raises(RedisClusterException) as ex: 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." ) def test_execute_command_node_flag_primaries(self, r): @@ -2789,7 +2789,7 @@ def test_asking_error(self, r): ask_node = node break if ask_node is None: - warnings.warn("skipping this test since the cluster has only one " "node") + warnings.warn("skipping this test since the cluster has only one node") return ask_msg = f"{r.keyslot(key)} {ask_node.host}:{ask_node.port}" diff --git a/tests/test_commands.py b/tests/test_commands.py index aa6745b34b..06f5eaffaf 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -274,7 +274,7 @@ def teardown(): # Resets and tests that hashed passwords are set properly. hashed_password = ( - "5e884898da28047151d0e56f8dc629" "2773603d0d6aabbdd62a11ef721d1542d8" + "5e884898da28047151d0e56f8dc6292773603d0d6aabbdd62a11ef721d1542d8" ) assert r.acl_setuser( username, enabled=True, reset=True, hashed_passwords=["+" + hashed_password] diff --git a/tests/test_connection_pool.py b/tests/test_connection_pool.py index 73eb6e198f..e8a42692a1 100644 --- a/tests/test_connection_pool.py +++ b/tests/test_connection_pool.py @@ -314,7 +314,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): diff --git a/tests/test_pipeline.py b/tests/test_pipeline.py index 03377d8350..716cd0fbf6 100644 --- a/tests/test_pipeline.py +++ b/tests/test_pipeline.py @@ -122,7 +122,7 @@ def test_exec_error_raised(self, r): with pytest.raises(redis.ResponseError) as ex: pipe.execute() assert str(ex.value).startswith( - "Command # 3 (LPUSH c 3) of " "pipeline caused error: " + "Command # 3 (LPUSH c 3) of pipeline caused error: " ) # make sure the pipe was restored to a working state @@ -167,7 +167,7 @@ def test_parse_error_raised(self, r): pipe.execute() assert str(ex.value).startswith( - "Command # 2 (ZREM b) of " "pipeline caused error: " + "Command # 2 (ZREM b) of pipeline caused error: " ) # make sure the pipe was restored to a working state @@ -184,7 +184,7 @@ def test_parse_error_raised_transaction(self, r): pipe.execute() assert str(ex.value).startswith( - "Command # 2 (ZREM b) of " "pipeline caused error: " + "Command # 2 (ZREM b) of pipeline caused error: " ) # make sure the pipe was restored to a working state @@ -331,7 +331,7 @@ def test_exec_error_in_no_transaction_pipeline(self, r): pipe.execute() assert str(ex.value).startswith( - "Command # 1 (LLEN a) of " "pipeline caused error: " + "Command # 1 (LLEN a) of pipeline caused error: " ) assert r["a"] == b"1"