diff --git a/.flake8 b/.flake8 deleted file mode 100644 index b1bd1d0b75..0000000000 --- a/.flake8 +++ /dev/null @@ -1,28 +0,0 @@ -[flake8] -max-line-length = 88 -exclude = - *.egg-info, - *.pyc, - .git, - .venv*, - build, - docs/*, - dist, - docker, - venv*, - .venv*, - whitelist.py, - tasks.py -ignore = - E126 - E203 - E231 - E701 - E704 - F405 - N801 - N802 - N803 - N806 - N815 - W503 diff --git a/.isort.cfg b/.isort.cfg deleted file mode 100644 index 039f0337a2..0000000000 --- a/.isort.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[settings] -profile=black -multi_line_output=3 -src_paths = ["redis", "tests"] -skip_glob=benchmarks/* \ No newline at end of file diff --git a/benchmarks/basic_operations.py b/benchmarks/basic_operations.py index c9f5853652..66cd6b320d 100644 --- a/benchmarks/basic_operations.py +++ b/benchmarks/basic_operations.py @@ -54,7 +54,7 @@ def wrapper(*args, **kwargs): count = args[1] print(f"{func.__name__} - {count} Requests") print(f"Duration = {duration}") - print(f"Rate = {count/duration}") + print(f"Rate = {count / duration}") print() return ret diff --git a/benchmarks/command_packer_benchmark.py b/benchmarks/command_packer_benchmark.py index e66dbbcbf9..4fb7196422 100644 --- a/benchmarks/command_packer_benchmark.py +++ b/benchmarks/command_packer_benchmark.py @@ -78,7 +78,6 @@ def pack_command(self, *args): class CommandPackerBenchmark(Benchmark): - ARGUMENTS = ( { "name": "connection_class", diff --git a/benchmarks/socket_read_size.py b/benchmarks/socket_read_size.py index 544c733178..37ffa97812 100644 --- a/benchmarks/socket_read_size.py +++ b/benchmarks/socket_read_size.py @@ -4,7 +4,6 @@ class SocketReadBenchmark(Benchmark): - ARGUMENTS = ( {"name": "parser", "values": [PythonParser, _HiredisParser]}, { diff --git a/dev_requirements.txt b/dev_requirements.txt index 7ee7ac2b75..11797c98e5 100644 --- a/dev_requirements.txt +++ b/dev_requirements.txt @@ -1,9 +1,5 @@ build -black==24.3.0 click==8.0.4 -flake8-isort -flake8 -flynt~=0.69.0 invoke==2.2.0 mock packaging>=20.4 @@ -12,6 +8,7 @@ pytest-asyncio>=0.23.0,<0.24.0 pytest-cov pytest-profiling==1.8.1 pytest-timeout +ruff==0.9.6 ujson>=4.2.0 uvloop vulture>=2.3.0 diff --git a/doctests/README.md b/doctests/README.md index 15664f1bcd..b5deff7ff3 100644 --- a/doctests/README.md +++ b/doctests/README.md @@ -21,8 +21,8 @@ pip uninstall -y redis # uninstall Redis package installed via redis-entraid pip install -r doctests/requirements.txt ``` -Note - the CI process, runs the basic ```black``` and ```isort``` linters against the examples. Assuming -the requirements above have been installed you can run ```black yourfile.py``` and ```isort yourfile.py``` +Note - the CI process, runs linters against the examples. Assuming +the requirements above have been installed you can run ```ruff check yourfile.py``` and ```ruff format yourfile.py``` locally to validate the linting, prior to CI. Just include necessary assertions in the example file and run diff --git a/pyproject.toml b/pyproject.toml index 0ec38ed3b1..0ab1b61bb8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -96,3 +96,53 @@ filterwarnings = [ # Ignore a coverage warning when COVERAGE_CORE=sysmon for Pythons < 3.12. "ignore:sys.monitoring isn't available:coverage.exceptions.CoverageWarning", ] + +[tool.ruff] +target-version = "py38" +line-length = 88 +exclude = [ + "*.egg-info", + "*.pyc", + ".git", + ".venv*", + "build", + "dist", + "docker", + "docs/*", + "doctests/*", + "tasks.py", + "venv*", + "whitelist.py", +] + +[tool.ruff.lint] +ignore = [ + "E501", # line too long (taken care of with ruff format) + "E741", # ambiguous variable name + "N818", # Errors should have Error suffix +] + +select = [ + "E", + "F", + "FLY", + "I", + "N", + "W", +] + +[tool.ruff.lint.per-file-ignores] +"redis/commands/bf/*" = [ + # the `bf` module uses star imports, so this is required there. + "F405", # name may be undefined, or defined from star imports +] +"redis/commands/{bf,timeseries,json,search}/*" = [ + "N", +] +"tests/*" = [ + "I", # TODO: could be enabled, plenty of changes + "N801", # class name should use CapWords convention + "N803", # argument name should be lowercase + "N802", # function name should be lowercase + "N806", # variable name should be lowercase +] diff --git a/redis/_parsers/base.py b/redis/_parsers/base.py index 91a4f74199..ebc8313ce7 100644 --- a/redis/_parsers/base.py +++ b/redis/_parsers/base.py @@ -32,9 +32,9 @@ from .encoders import Encoder from .socket import SERVER_CLOSED_CONNECTION_ERROR, SocketBuffer -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/asyncio/cluster.py b/redis/asyncio/cluster.py index 87a2c16afa..f343e26b75 100644 --- a/redis/asyncio/cluster.py +++ b/redis/asyncio/cluster.py @@ -1154,9 +1154,7 @@ def get_node( return self.nodes_cache.get(node_name) else: raise DataError( - "get_node requires one of the following: " - "1. node name " - "2. host and port" + "get_node requires one of the following: 1. node name 2. host and port" ) def set_nodes( @@ -1338,7 +1336,7 @@ async def initialize(self) -> None: if len(disagreements) > 5: raise RedisClusterException( f"startup_nodes could not agree on a valid " - f'slots cache: {", ".join(disagreements)}' + f"slots cache: {', '.join(disagreements)}" ) # Validate if all slots are covered or if we should try next startup node diff --git a/redis/asyncio/connection.py b/redis/asyncio/connection.py index 2e2a2502c3..9b5d0d8eb9 100644 --- a/redis/asyncio/connection.py +++ b/redis/asyncio/connection.py @@ -842,7 +842,7 @@ def __init__( if cert_reqs is None: self.cert_reqs = ssl.CERT_NONE elif isinstance(cert_reqs, str): - CERT_REQS = { + CERT_REQS = { # noqa: N806 "none": ssl.CERT_NONE, "optional": ssl.CERT_OPTIONAL, "required": ssl.CERT_REQUIRED, diff --git a/redis/asyncio/utils.py b/redis/asyncio/utils.py index 5a55b36a33..fa014514ec 100644 --- a/redis/asyncio/utils.py +++ b/redis/asyncio/utils.py @@ -16,7 +16,7 @@ def from_url(url, **kwargs): return Redis.from_url(url, **kwargs) -class pipeline: +class pipeline: # noqa: N801 def __init__(self, redis_obj: "Redis"): self.p: "Pipeline" = redis_obj.pipeline() diff --git a/redis/auth/token.py b/redis/auth/token.py index 1c5246469b..1f613aff5f 100644 --- a/redis/auth/token.py +++ b/redis/auth/token.py @@ -76,7 +76,6 @@ def get_received_at_ms(self) -> float: class JWToken(TokenInterface): - REQUIRED_FIELDS = {"exp"} def __init__(self, token: str): diff --git a/redis/client.py b/redis/client.py index fc535c8ca0..2bacbe14ac 100755 --- a/redis/client.py +++ b/redis/client.py @@ -1514,8 +1514,7 @@ def raise_first_error(self, commands, response): def annotate_exception(self, exception, number, command): cmd = " ".join(map(safe_str, command)) msg = ( - f"Command # {number} ({cmd}) of pipeline " - f"caused error: {exception.args[0]}" + f"Command # {number} ({cmd}) of pipeline caused error: {exception.args[0]}" ) exception.args = (msg,) + exception.args[1:] diff --git a/redis/cluster.py b/redis/cluster.py index f518a1f184..ef4500f895 100644 --- a/redis/cluster.py +++ b/redis/cluster.py @@ -1628,7 +1628,7 @@ def initialize(self): if len(disagreements) > 5: raise RedisClusterException( f"startup_nodes could not agree on a valid " - f'slots cache: {", ".join(disagreements)}' + f"slots cache: {', '.join(disagreements)}" ) fully_covered = self.check_slots_coverage(tmp_slots) @@ -2047,8 +2047,7 @@ def annotate_exception(self, exception, number, command): """ cmd = " ".join(map(safe_str, command)) msg = ( - f"Command # {number} ({cmd}) of pipeline " - f"caused error: {exception.args[0]}" + f"Command # {number} ({cmd}) of pipeline caused error: {exception.args[0]}" ) exception.args = (msg,) + exception.args[1:] diff --git a/redis/commands/cluster.py b/redis/commands/cluster.py index f31b88bc4e..f0b65612e0 100644 --- a/redis/commands/cluster.py +++ b/redis/commands/cluster.py @@ -595,7 +595,7 @@ def cluster_setslot( "CLUSTER SETSLOT", slot_id, state, node_id, target_nodes=target_node ) elif state.upper() == "STABLE": - raise RedisError('For "stable" state please use ' "cluster_setslot_stable") + raise RedisError('For "stable" state please use cluster_setslot_stable') else: raise RedisError(f"Invalid slot state: {state}") diff --git a/redis/commands/core.py b/redis/commands/core.py index c3ffb955c4..b0e5dc6794 100644 --- a/redis/commands/core.py +++ b/redis/commands/core.py @@ -3415,7 +3415,9 @@ def smembers(self, name: str) -> Union[Awaitable[Set], Set]: """ return self.execute_command("SMEMBERS", name, keys=[name]) - def smismember(self, name: str, values: List, *args: List) -> Union[ + def smismember( + self, name: str, values: List, *args: List + ) -> Union[ Awaitable[List[Union[Literal[0], Literal[1]]]], List[Union[Literal[0], Literal[1]]], ]: @@ -4162,8 +4164,7 @@ def zadd( raise DataError("ZADD allows either 'gt' or 'lt', not both") if incr and len(mapping) != 1: raise DataError( - "ZADD option 'incr' only works when passing a " - "single element/score pair" + "ZADD option 'incr' only works when passing a single element/score pair" ) if nx and (gt or lt): raise DataError("Only one of 'nx', 'lt', or 'gr' may be defined.") diff --git a/redis/commands/graph/commands.py b/redis/commands/graph/commands.py index d92018f731..1e41a5fb1f 100644 --- a/redis/commands/graph/commands.py +++ b/redis/commands/graph/commands.py @@ -171,9 +171,7 @@ def config(self, name, value=None, set=False): if set: params.append(value) else: - raise DataError( - "``value`` can be provided only when ``set`` is True" - ) # noqa + raise DataError("``value`` can be provided only when ``set`` is True") # noqa return self.execute_command(CONFIG_CMD, *params) def list_keys(self): diff --git a/redis/commands/helpers.py b/redis/commands/helpers.py index 7d9095ea41..e11d34fb71 100644 --- a/redis/commands/helpers.py +++ b/redis/commands/helpers.py @@ -138,9 +138,9 @@ def stringify_param_value(value): elif value is None: return "null" elif isinstance(value, (list, tuple)): - return f'[{",".join(map(stringify_param_value, value))}]' + return f"[{','.join(map(stringify_param_value, value))}]" elif isinstance(value, dict): - return f'{{{",".join(f"{k}:{stringify_param_value(v)}" for k, v in value.items())}}}' # noqa + return f"{{{','.join(f'{k}:{stringify_param_value(v)}' for k, v in value.items())}}}" # noqa else: return str(value) diff --git a/redis/connection.py b/redis/connection.py index 2391e74d2c..43501800c8 100644 --- a/redis/connection.py +++ b/redis/connection.py @@ -622,9 +622,7 @@ def read_response( except OSError as e: if disconnect_on_error: self.disconnect() - raise ConnectionError( - f"Error while reading from {host_error}" f" : {e.args}" - ) + raise ConnectionError(f"Error while reading from {host_error} : {e.args}") except BaseException: # Also by default close in case of BaseException. A lot of code # relies on this behaviour when doing Command/Response pairs. @@ -1040,7 +1038,7 @@ def __init__( if ssl_cert_reqs is None: ssl_cert_reqs = ssl.CERT_NONE elif isinstance(ssl_cert_reqs, str): - CERT_REQS = { + CERT_REQS = { # noqa: N806 "none": ssl.CERT_NONE, "optional": ssl.CERT_OPTIONAL, "required": ssl.CERT_REQUIRED, diff --git a/redis/exceptions.py b/redis/exceptions.py index dcc06774b0..82f62730ab 100644 --- a/redis/exceptions.py +++ b/redis/exceptions.py @@ -79,6 +79,7 @@ class ModuleError(ResponseError): class LockError(RedisError, ValueError): "Errors acquiring or releasing a lock" + # NOTE: For backwards compatibility, this class derives from ValueError. # This was originally chosen to behave like threading.Lock. @@ -89,11 +90,13 @@ def __init__(self, message=None, lock_name=None): class LockNotOwnedError(LockError): "Error trying to extend or release a lock that is (no longer) owned" + pass class ChildDeadlockedError(Exception): "Error indicating that a child process is deadlocked after a fork()" + pass diff --git a/redis/ocsp.py b/redis/ocsp.py index 8819848fa9..d69c914dee 100644 --- a/redis/ocsp.py +++ b/redis/ocsp.py @@ -15,6 +15,7 @@ from cryptography.hazmat.primitives.hashes import SHA1, Hash from cryptography.hazmat.primitives.serialization import Encoding, PublicFormat from cryptography.x509 import ocsp + from redis.exceptions import AuthorizationError, ConnectionError @@ -56,7 +57,7 @@ def _check_certificate(issuer_cert, ocsp_bytes, validate=True): if ocsp_response.response_status == ocsp.OCSPResponseStatus.SUCCESSFUL: if ocsp_response.certificate_status != ocsp.OCSPCertStatus.GOOD: raise ConnectionError( - f'Received an {str(ocsp_response.certificate_status).split(".")[1]} ' + f"Received an {str(ocsp_response.certificate_status).split('.')[1]} " "ocsp certificate status" ) else: diff --git a/redis/sentinel.py b/redis/sentinel.py index 01e210794c..521ac24142 100644 --- a/redis/sentinel.py +++ b/redis/sentinel.py @@ -273,7 +273,7 @@ def __repr__(self): ) return ( f"<{type(self).__module__}.{type(self).__name__}" - f'(sentinels=[{",".join(sentinel_addresses)}])>' + f"(sentinels=[{','.join(sentinel_addresses)}])>" ) def check_master_state(self, state, service_name): diff --git a/tasks.py b/tasks.py index 8a5cae97b2..2d1a073437 100644 --- a/tasks.py +++ b/tasks.py @@ -27,11 +27,9 @@ def build_docs(c): @task def linters(c): """Run code linters""" - run("flake8 tests redis") - run("black --target-version py37 --check --diff tests redis") - run("isort --check-only --diff tests redis") + run("ruff check tests redis") + run("ruff format --check --diff tests redis") run("vulture redis whitelist.py --min-confidence 80") - run("flynt --fail-on-change --dry-run tests redis") @task diff --git a/tests/conftest.py b/tests/conftest.py index e5eea4d582..c485d626ca 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -646,7 +646,7 @@ def wait_for_command(client, monitor, command, key=None): if Version(redis_version) >= Version("5.0.0"): id_str = str(client.client_id()) else: - id_str = f"{random.randrange(2 ** 32):08x}" + id_str = f"{random.randrange(2**32):08x}" key = f"__REDIS-PY-{id_str}__" client.get(key) while True: diff --git a/tests/test_asyncio/conftest.py b/tests/test_asyncio/conftest.py index 226b00aa45..60e447e6fd 100644 --- a/tests/test_asyncio/conftest.py +++ b/tests/test_asyncio/conftest.py @@ -242,7 +242,7 @@ async def wait_for_command( if Version(redis_version) >= Version("5.0.0"): id_str = str(await client.client_id()) else: - id_str = f"{random.randrange(2 ** 32):08x}" + id_str = f"{random.randrange(2**32):08x}" key = f"__REDIS-PY-{id_str}__" await client.get(key) while True: diff --git a/tests/test_asyncio/test_cluster.py b/tests/test_asyncio/test_cluster.py index c95babf687..9911eced27 100644 --- a/tests/test_asyncio/test_cluster.py +++ b/tests/test_asyncio/test_cluster.py @@ -146,7 +146,6 @@ async def get_mocked_redis_client( with mock.patch.object(ClusterNode, "execute_command") as execute_command_mock: async def execute_command(*_args, **_kwargs): - if _args[0] == "CLUSTER SLOTS": if cluster_slots_raise_error: raise ResponseError() @@ -1577,7 +1576,7 @@ async def test_cluster_bitop_not_empty_string(self, r: RedisCluster) -> None: @skip_if_server_version_lt("2.6.0") async def test_cluster_bitop_not(self, r: RedisCluster) -> None: - test_str = b"\xAA\x00\xFF\x55" + test_str = b"\xaa\x00\xff\x55" correct = ~0xAA00FF55 & 0xFFFFFFFF await r.set("{foo}a", test_str) await r.bitop("not", "{foo}r", "{foo}a") @@ -1585,7 +1584,7 @@ async def test_cluster_bitop_not(self, r: RedisCluster) -> None: @skip_if_server_version_lt("2.6.0") async def test_cluster_bitop_not_in_place(self, r: RedisCluster) -> None: - test_str = b"\xAA\x00\xFF\x55" + test_str = b"\xaa\x00\xff\x55" correct = ~0xAA00FF55 & 0xFFFFFFFF await r.set("{foo}a", test_str) await r.bitop("not", "{foo}a", "{foo}a") @@ -1593,7 +1592,7 @@ async def test_cluster_bitop_not_in_place(self, r: RedisCluster) -> None: @skip_if_server_version_lt("2.6.0") async def test_cluster_bitop_single_string(self, r: RedisCluster) -> None: - test_str = b"\x01\x02\xFF" + test_str = b"\x01\x02\xff" await r.set("{foo}a", test_str) await r.bitop("and", "{foo}res1", "{foo}a") await r.bitop("or", "{foo}res2", "{foo}a") @@ -1604,8 +1603,8 @@ async def test_cluster_bitop_single_string(self, r: RedisCluster) -> None: @skip_if_server_version_lt("2.6.0") async def test_cluster_bitop_string_operands(self, r: RedisCluster) -> None: - await r.set("{foo}a", b"\x01\x02\xFF\xFF") - await r.set("{foo}b", b"\x01\x02\xFF") + await r.set("{foo}a", b"\x01\x02\xff\xff") + await r.set("{foo}b", b"\x01\x02\xff") await r.bitop("and", "{foo}res1", "{foo}a", "{foo}b") await r.bitop("or", "{foo}res2", "{foo}a", "{foo}b") await r.bitop("xor", "{foo}res3", "{foo}a", "{foo}b") diff --git a/tests/test_asyncio/test_commands.py b/tests/test_asyncio/test_commands.py index 9f154cb273..08bd5810f4 100644 --- a/tests/test_asyncio/test_commands.py +++ b/tests/test_asyncio/test_commands.py @@ -711,8 +711,9 @@ async def test_config_set_for_search_module(self, r: redis.Redis): "search-default-dialect" ] == default_dialect_new assert ( - (await r.ft().config_get("*"))[b"DEFAULT_DIALECT"] - ).decode() == default_dialect_new + ((await r.ft().config_get("*"))[b"DEFAULT_DIALECT"]).decode() + == default_dialect_new + ) except AssertionError as ex: raise ex finally: @@ -844,7 +845,7 @@ async def test_bitop_not_empty_string(self, r: redis.Redis): @skip_if_server_version_lt("2.6.0") @pytest.mark.onlynoncluster async def test_bitop_not(self, r: redis.Redis): - test_str = b"\xAA\x00\xFF\x55" + test_str = b"\xaa\x00\xff\x55" correct = ~0xAA00FF55 & 0xFFFFFFFF await r.set("a", test_str) await r.bitop("not", "r", "a") @@ -853,7 +854,7 @@ async def test_bitop_not(self, r: redis.Redis): @skip_if_server_version_lt("2.6.0") @pytest.mark.onlynoncluster async def test_bitop_not_in_place(self, r: redis.Redis): - test_str = b"\xAA\x00\xFF\x55" + test_str = b"\xaa\x00\xff\x55" correct = ~0xAA00FF55 & 0xFFFFFFFF await r.set("a", test_str) await r.bitop("not", "a", "a") @@ -862,7 +863,7 @@ async def test_bitop_not_in_place(self, r: redis.Redis): @skip_if_server_version_lt("2.6.0") @pytest.mark.onlynoncluster async def test_bitop_single_string(self, r: redis.Redis): - test_str = b"\x01\x02\xFF" + test_str = b"\x01\x02\xff" await r.set("a", test_str) await r.bitop("and", "res1", "a") await r.bitop("or", "res2", "a") @@ -874,8 +875,8 @@ async def test_bitop_single_string(self, r: redis.Redis): @skip_if_server_version_lt("2.6.0") @pytest.mark.onlynoncluster async def test_bitop_string_operands(self, r: redis.Redis): - await r.set("a", b"\x01\x02\xFF\xFF") - await r.set("b", b"\x01\x02\xFF") + await r.set("a", b"\x01\x02\xff\xff") + await r.set("b", b"\x01\x02\xff") await r.bitop("and", "res1", "a", "b") await r.bitop("or", "res2", "a", "b") await r.bitop("xor", "res3", "a", "b") diff --git a/tests/test_asyncio/test_graph.py b/tests/test_asyncio/test_graph.py index 2a506d5e22..7b823265c3 100644 --- a/tests/test_asyncio/test_graph.py +++ b/tests/test_asyncio/test_graph.py @@ -44,8 +44,7 @@ async def test_graph_creation(decoded_r: redis.Redis): await graph.commit() query = ( - 'MATCH (p:person)-[v:visited {purpose:"pleasure"}]->(c:country) ' - "RETURN p, v, c" + 'MATCH (p:person)-[v:visited {purpose:"pleasure"}]->(c:country) RETURN p, v, c' ) result = await graph.query(query) diff --git a/tests/test_asyncio/test_search.py b/tests/test_asyncio/test_search.py index c0efcce882..c55d57f3b2 100644 --- a/tests/test_asyncio/test_search.py +++ b/tests/test_asyncio/test_search.py @@ -1797,10 +1797,10 @@ async def test_binary_and_text_fields(decoded_r: redis.Redis): docs[0]["vector_emb"], dtype=np.float32 ) - assert np.array_equal( - decoded_vec_from_search_results, fake_vec - ), "The vectors are not equal" + assert np.array_equal(decoded_vec_from_search_results, fake_vec), ( + "The vectors are not equal" + ) - assert ( - docs[0]["first_name"] == mixed_data["first_name"] - ), "The text field is not decoded correctly" + assert docs[0]["first_name"] == mixed_data["first_name"], ( + "The text field is not decoded correctly" + ) diff --git a/tests/test_auth/test_token.py b/tests/test_auth/test_token.py index 2d72e08895..97633e38e7 100644 --- a/tests/test_auth/test_token.py +++ b/tests/test_auth/test_token.py @@ -6,7 +6,6 @@ class TestToken: - def test_simple_token(self): token = SimpleToken( "value", diff --git a/tests/test_cluster.py b/tests/test_cluster.py index 908ac26211..bec9a8ecb0 100644 --- a/tests/test_cluster.py +++ b/tests/test_cluster.py @@ -1692,7 +1692,7 @@ def test_cluster_bitop_not_empty_string(self, r): @skip_if_server_version_lt("2.6.0") def test_cluster_bitop_not(self, r): - test_str = b"\xAA\x00\xFF\x55" + test_str = b"\xaa\x00\xff\x55" correct = ~0xAA00FF55 & 0xFFFFFFFF r["{foo}a"] = test_str r.bitop("not", "{foo}r", "{foo}a") @@ -1700,7 +1700,7 @@ def test_cluster_bitop_not(self, r): @skip_if_server_version_lt("2.6.0") def test_cluster_bitop_not_in_place(self, r): - test_str = b"\xAA\x00\xFF\x55" + test_str = b"\xaa\x00\xff\x55" correct = ~0xAA00FF55 & 0xFFFFFFFF r["{foo}a"] = test_str r.bitop("not", "{foo}a", "{foo}a") @@ -1708,7 +1708,7 @@ def test_cluster_bitop_not_in_place(self, r): @skip_if_server_version_lt("2.6.0") def test_cluster_bitop_single_string(self, r): - test_str = b"\x01\x02\xFF" + test_str = b"\x01\x02\xff" r["{foo}a"] = test_str r.bitop("and", "{foo}res1", "{foo}a") r.bitop("or", "{foo}res2", "{foo}a") @@ -1719,8 +1719,8 @@ def test_cluster_bitop_single_string(self, r): @skip_if_server_version_lt("2.6.0") def test_cluster_bitop_string_operands(self, r): - r["{foo}a"] = b"\x01\x02\xFF\xFF" - r["{foo}b"] = b"\x01\x02\xFF" + r["{foo}a"] = b"\x01\x02\xff\xff" + r["{foo}b"] = b"\x01\x02\xff" r.bitop("and", "{foo}res1", "{foo}a", "{foo}b") r.bitop("or", "{foo}res2", "{foo}a", "{foo}b") r.bitop("xor", "{foo}res3", "{foo}a", "{foo}b") diff --git a/tests/test_commands.py b/tests/test_commands.py index b6f13f6aa8..c6e39f565d 100644 --- a/tests/test_commands.py +++ b/tests/test_commands.py @@ -1025,8 +1025,9 @@ def test_config_set_for_search_module(self, r: redis.Redis): assert r.config_set("search-default-dialect", default_dialect_new) assert r.config_get("*")["search-default-dialect"] == default_dialect_new assert ( - r.ft().config_get("*")[b"DEFAULT_DIALECT"] - ).decode() == default_dialect_new + (r.ft().config_get("*")[b"DEFAULT_DIALECT"]).decode() + == default_dialect_new + ) except AssertionError as ex: raise ex finally: @@ -1268,7 +1269,7 @@ def test_bitop_not_empty_string(self, r): @pytest.mark.onlynoncluster @skip_if_server_version_lt("2.6.0") def test_bitop_not(self, r): - test_str = b"\xAA\x00\xFF\x55" + test_str = b"\xaa\x00\xff\x55" correct = ~0xAA00FF55 & 0xFFFFFFFF r["a"] = test_str r.bitop("not", "r", "a") @@ -1277,7 +1278,7 @@ def test_bitop_not(self, r): @pytest.mark.onlynoncluster @skip_if_server_version_lt("2.6.0") def test_bitop_not_in_place(self, r): - test_str = b"\xAA\x00\xFF\x55" + test_str = b"\xaa\x00\xff\x55" correct = ~0xAA00FF55 & 0xFFFFFFFF r["a"] = test_str r.bitop("not", "a", "a") @@ -1286,7 +1287,7 @@ def test_bitop_not_in_place(self, r): @pytest.mark.onlynoncluster @skip_if_server_version_lt("2.6.0") def test_bitop_single_string(self, r): - test_str = b"\x01\x02\xFF" + test_str = b"\x01\x02\xff" r["a"] = test_str r.bitop("and", "res1", "a") r.bitop("or", "res2", "a") @@ -1298,8 +1299,8 @@ def test_bitop_single_string(self, r): @pytest.mark.onlynoncluster @skip_if_server_version_lt("2.6.0") def test_bitop_string_operands(self, r): - r["a"] = b"\x01\x02\xFF\xFF" - r["b"] = b"\x01\x02\xFF" + r["a"] = b"\x01\x02\xff\xff" + r["b"] = b"\x01\x02\xff" r.bitop("and", "res1", "a", "b") r.bitop("or", "res2", "a", "b") r.bitop("xor", "res3", "a", "b") diff --git a/tests/test_connection.py b/tests/test_connection.py index 6c1498a329..9664146ce5 100644 --- a/tests/test_connection.py +++ b/tests/test_connection.py @@ -362,7 +362,6 @@ def test_unix_socket_connection_failure(): class TestUnitConnectionPool: - @pytest.mark.parametrize( "max_conn", (-1, "str"), ids=("non-positive", "wrong type") ) diff --git a/tests/test_graph.py b/tests/test_graph.py index efb10dada7..fd08385667 100644 --- a/tests/test_graph.py +++ b/tests/test_graph.py @@ -73,8 +73,7 @@ def test_graph_creation(client): graph.commit() query = ( - 'MATCH (p:person)-[v:visited {purpose:"pleasure"}]->(c:country) ' - "RETURN p, v, c" + 'MATCH (p:person)-[v:visited {purpose:"pleasure"}]->(c:country) RETURN p, v, c' ) result = graph.query(query) diff --git a/tests/test_search.py b/tests/test_search.py index c4598f3773..11f22ac805 100644 --- a/tests/test_search.py +++ b/tests/test_search.py @@ -1919,13 +1919,13 @@ def test_binary_and_text_fields(client): docs[0]["vector_emb"], dtype=np.float32 ) - assert np.array_equal( - decoded_vec_from_search_results, fake_vec - ), "The vectors are not equal" + assert np.array_equal(decoded_vec_from_search_results, fake_vec), ( + "The vectors are not equal" + ) - assert ( - docs[0]["first_name"] == mixed_data["first_name"] - ), "The text field is not decoded correctly" + assert docs[0]["first_name"] == mixed_data["first_name"], ( + "The text field is not decoded correctly" + ) @pytest.mark.redismod