Skip to content

Commit 8fc3612

Browse files
committed
Replace black with ruff format; run it
1 parent 1c55580 commit 8fc3612

12 files changed

+30
-32
lines changed

benchmarks/command_packer_benchmark.py

-1
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ def pack_command(self, *args):
7878

7979

8080
class CommandPackerBenchmark(Benchmark):
81-
8281
ARGUMENTS = (
8382
{
8483
"name": "connection_class",

benchmarks/socket_read_size.py

-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@
44

55

66
class SocketReadBenchmark(Benchmark):
7-
87
ARGUMENTS = (
98
{"name": "parser", "values": [PythonParser, _HiredisParser]},
109
{

redis/client.py

-1
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,6 @@ def _disconnect_raise_reset(
15031503
conn.retry_on_error is None
15041504
or isinstance(error, tuple(conn.retry_on_error)) is False
15051505
):
1506-
15071506
self.reset()
15081507
raise error
15091508

redis/commands/core.py

+3-1
Original file line numberDiff line numberDiff line change
@@ -3413,7 +3413,9 @@ def smembers(self, name: str) -> Union[Awaitable[Set], Set]:
34133413
"""
34143414
return self.execute_command("SMEMBERS", name, keys=[name])
34153415

3416-
def smismember(self, name: str, values: List, *args: List) -> Union[
3416+
def smismember(
3417+
self, name: str, values: List, *args: List
3418+
) -> Union[
34173419
Awaitable[List[Union[Literal[0], Literal[1]]]],
34183420
List[Union[Literal[0], Literal[1]]],
34193421
]:

redis/commands/graph/commands.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -171,9 +171,7 @@ def config(self, name, value=None, set=False):
171171
if set:
172172
params.append(value)
173173
else:
174-
raise DataError(
175-
"``value`` can be provided only when ``set`` is True"
176-
) # noqa
174+
raise DataError("``value`` can be provided only when ``set`` is True") # noqa
177175
return self.execute_command(CONFIG_CMD, *params)
178176

179177
def list_keys(self):

redis/exceptions.py

+3
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ class ModuleError(ResponseError):
7979

8080
class LockError(RedisError, ValueError):
8181
"Errors acquiring or releasing a lock"
82+
8283
# NOTE: For backwards compatibility, this class derives from ValueError.
8384
# This was originally chosen to behave like threading.Lock.
8485

@@ -89,11 +90,13 @@ def __init__(self, message=None, lock_name=None):
8990

9091
class LockNotOwnedError(LockError):
9192
"Error trying to extend or release a lock that is (no longer) owned"
93+
9294
pass
9395

9496

9597
class ChildDeadlockedError(Exception):
9698
"Error indicating that a child process is deadlocked after a fork()"
99+
97100
pass
98101

99102

tasks.py

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ def build_docs(c):
2828
def linters(c):
2929
"""Run code linters"""
3030
run("ruff check tests redis")
31-
run("black --target-version py37 --check --diff tests redis")
31+
run("ruff format --check --diff tests redis")
3232
run("vulture redis whitelist.py --min-confidence 80")
3333

3434

tests/test_asyncio/test_cluster.py

+5-6
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,6 @@ async def get_mocked_redis_client(
147147
with mock.patch.object(ClusterNode, "execute_command") as execute_command_mock:
148148

149149
async def execute_command(*_args, **_kwargs):
150-
151150
if _args[0] == "CLUSTER SLOTS":
152151
if cluster_slots_raise_error:
153152
raise ResponseError()
@@ -1578,23 +1577,23 @@ async def test_cluster_bitop_not_empty_string(self, r: RedisCluster) -> None:
15781577

15791578
@skip_if_server_version_lt("2.6.0")
15801579
async def test_cluster_bitop_not(self, r: RedisCluster) -> None:
1581-
test_str = b"\xAA\x00\xFF\x55"
1580+
test_str = b"\xaa\x00\xff\x55"
15821581
correct = ~0xAA00FF55 & 0xFFFFFFFF
15831582
await r.set("{foo}a", test_str)
15841583
await r.bitop("not", "{foo}r", "{foo}a")
15851584
assert int(binascii.hexlify(await r.get("{foo}r")), 16) == correct
15861585

15871586
@skip_if_server_version_lt("2.6.0")
15881587
async def test_cluster_bitop_not_in_place(self, r: RedisCluster) -> None:
1589-
test_str = b"\xAA\x00\xFF\x55"
1588+
test_str = b"\xaa\x00\xff\x55"
15901589
correct = ~0xAA00FF55 & 0xFFFFFFFF
15911590
await r.set("{foo}a", test_str)
15921591
await r.bitop("not", "{foo}a", "{foo}a")
15931592
assert int(binascii.hexlify(await r.get("{foo}a")), 16) == correct
15941593

15951594
@skip_if_server_version_lt("2.6.0")
15961595
async def test_cluster_bitop_single_string(self, r: RedisCluster) -> None:
1597-
test_str = b"\x01\x02\xFF"
1596+
test_str = b"\x01\x02\xff"
15981597
await r.set("{foo}a", test_str)
15991598
await r.bitop("and", "{foo}res1", "{foo}a")
16001599
await r.bitop("or", "{foo}res2", "{foo}a")
@@ -1605,8 +1604,8 @@ async def test_cluster_bitop_single_string(self, r: RedisCluster) -> None:
16051604

16061605
@skip_if_server_version_lt("2.6.0")
16071606
async def test_cluster_bitop_string_operands(self, r: RedisCluster) -> None:
1608-
await r.set("{foo}a", b"\x01\x02\xFF\xFF")
1609-
await r.set("{foo}b", b"\x01\x02\xFF")
1607+
await r.set("{foo}a", b"\x01\x02\xff\xff")
1608+
await r.set("{foo}b", b"\x01\x02\xff")
16101609
await r.bitop("and", "{foo}res1", "{foo}a", "{foo}b")
16111610
await r.bitop("or", "{foo}res2", "{foo}a", "{foo}b")
16121611
await r.bitop("xor", "{foo}res3", "{foo}a", "{foo}b")

tests/test_asyncio/test_commands.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -634,7 +634,7 @@ async def test_bitop_not_empty_string(self, r: redis.Redis):
634634
@skip_if_server_version_lt("2.6.0")
635635
@pytest.mark.onlynoncluster
636636
async def test_bitop_not(self, r: redis.Redis):
637-
test_str = b"\xAA\x00\xFF\x55"
637+
test_str = b"\xaa\x00\xff\x55"
638638
correct = ~0xAA00FF55 & 0xFFFFFFFF
639639
await r.set("a", test_str)
640640
await r.bitop("not", "r", "a")
@@ -643,7 +643,7 @@ async def test_bitop_not(self, r: redis.Redis):
643643
@skip_if_server_version_lt("2.6.0")
644644
@pytest.mark.onlynoncluster
645645
async def test_bitop_not_in_place(self, r: redis.Redis):
646-
test_str = b"\xAA\x00\xFF\x55"
646+
test_str = b"\xaa\x00\xff\x55"
647647
correct = ~0xAA00FF55 & 0xFFFFFFFF
648648
await r.set("a", test_str)
649649
await r.bitop("not", "a", "a")
@@ -652,7 +652,7 @@ async def test_bitop_not_in_place(self, r: redis.Redis):
652652
@skip_if_server_version_lt("2.6.0")
653653
@pytest.mark.onlynoncluster
654654
async def test_bitop_single_string(self, r: redis.Redis):
655-
test_str = b"\x01\x02\xFF"
655+
test_str = b"\x01\x02\xff"
656656
await r.set("a", test_str)
657657
await r.bitop("and", "res1", "a")
658658
await r.bitop("or", "res2", "a")
@@ -664,8 +664,8 @@ async def test_bitop_single_string(self, r: redis.Redis):
664664
@skip_if_server_version_lt("2.6.0")
665665
@pytest.mark.onlynoncluster
666666
async def test_bitop_string_operands(self, r: redis.Redis):
667-
await r.set("a", b"\x01\x02\xFF\xFF")
668-
await r.set("b", b"\x01\x02\xFF")
667+
await r.set("a", b"\x01\x02\xff\xff")
668+
await r.set("b", b"\x01\x02\xff")
669669
await r.bitop("and", "res1", "a", "b")
670670
await r.bitop("or", "res2", "a", "b")
671671
await r.bitop("xor", "res3", "a", "b")

tests/test_cluster.py

+5-5
Original file line numberDiff line numberDiff line change
@@ -1691,23 +1691,23 @@ def test_cluster_bitop_not_empty_string(self, r):
16911691

16921692
@skip_if_server_version_lt("2.6.0")
16931693
def test_cluster_bitop_not(self, r):
1694-
test_str = b"\xAA\x00\xFF\x55"
1694+
test_str = b"\xaa\x00\xff\x55"
16951695
correct = ~0xAA00FF55 & 0xFFFFFFFF
16961696
r["{foo}a"] = test_str
16971697
r.bitop("not", "{foo}r", "{foo}a")
16981698
assert int(binascii.hexlify(r["{foo}r"]), 16) == correct
16991699

17001700
@skip_if_server_version_lt("2.6.0")
17011701
def test_cluster_bitop_not_in_place(self, r):
1702-
test_str = b"\xAA\x00\xFF\x55"
1702+
test_str = b"\xaa\x00\xff\x55"
17031703
correct = ~0xAA00FF55 & 0xFFFFFFFF
17041704
r["{foo}a"] = test_str
17051705
r.bitop("not", "{foo}a", "{foo}a")
17061706
assert int(binascii.hexlify(r["{foo}a"]), 16) == correct
17071707

17081708
@skip_if_server_version_lt("2.6.0")
17091709
def test_cluster_bitop_single_string(self, r):
1710-
test_str = b"\x01\x02\xFF"
1710+
test_str = b"\x01\x02\xff"
17111711
r["{foo}a"] = test_str
17121712
r.bitop("and", "{foo}res1", "{foo}a")
17131713
r.bitop("or", "{foo}res2", "{foo}a")
@@ -1718,8 +1718,8 @@ def test_cluster_bitop_single_string(self, r):
17181718

17191719
@skip_if_server_version_lt("2.6.0")
17201720
def test_cluster_bitop_string_operands(self, r):
1721-
r["{foo}a"] = b"\x01\x02\xFF\xFF"
1722-
r["{foo}b"] = b"\x01\x02\xFF"
1721+
r["{foo}a"] = b"\x01\x02\xff\xff"
1722+
r["{foo}b"] = b"\x01\x02\xff"
17231723
r.bitop("and", "{foo}res1", "{foo}a", "{foo}b")
17241724
r.bitop("or", "{foo}res2", "{foo}a", "{foo}b")
17251725
r.bitop("xor", "{foo}res3", "{foo}a", "{foo}b")

tests/test_commands.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -1040,7 +1040,7 @@ def test_bitop_not_empty_string(self, r):
10401040
@pytest.mark.onlynoncluster
10411041
@skip_if_server_version_lt("2.6.0")
10421042
def test_bitop_not(self, r):
1043-
test_str = b"\xAA\x00\xFF\x55"
1043+
test_str = b"\xaa\x00\xff\x55"
10441044
correct = ~0xAA00FF55 & 0xFFFFFFFF
10451045
r["a"] = test_str
10461046
r.bitop("not", "r", "a")
@@ -1049,7 +1049,7 @@ def test_bitop_not(self, r):
10491049
@pytest.mark.onlynoncluster
10501050
@skip_if_server_version_lt("2.6.0")
10511051
def test_bitop_not_in_place(self, r):
1052-
test_str = b"\xAA\x00\xFF\x55"
1052+
test_str = b"\xaa\x00\xff\x55"
10531053
correct = ~0xAA00FF55 & 0xFFFFFFFF
10541054
r["a"] = test_str
10551055
r.bitop("not", "a", "a")
@@ -1058,7 +1058,7 @@ def test_bitop_not_in_place(self, r):
10581058
@pytest.mark.onlynoncluster
10591059
@skip_if_server_version_lt("2.6.0")
10601060
def test_bitop_single_string(self, r):
1061-
test_str = b"\x01\x02\xFF"
1061+
test_str = b"\x01\x02\xff"
10621062
r["a"] = test_str
10631063
r.bitop("and", "res1", "a")
10641064
r.bitop("or", "res2", "a")
@@ -1070,8 +1070,8 @@ def test_bitop_single_string(self, r):
10701070
@pytest.mark.onlynoncluster
10711071
@skip_if_server_version_lt("2.6.0")
10721072
def test_bitop_string_operands(self, r):
1073-
r["a"] = b"\x01\x02\xFF\xFF"
1074-
r["b"] = b"\x01\x02\xFF"
1073+
r["a"] = b"\x01\x02\xff\xff"
1074+
r["b"] = b"\x01\x02\xff"
10751075
r.bitop("and", "res1", "a", "b")
10761076
r.bitop("or", "res2", "a", "b")
10771077
r.bitop("xor", "res3", "a", "b")
@@ -3214,8 +3214,8 @@ def test_hmget(self, r):
32143214
def test_hmset(self, r):
32153215
redis_class = type(r).__name__
32163216
warning_message = (
3217-
r"^{0}\.hmset\(\) is deprecated\. "
3218-
r"Use {0}\.hset\(\) instead\.$".format(redis_class)
3217+
rf"^{redis_class}\.hmset\(\) is deprecated\. "
3218+
rf"Use {redis_class}\.hset\(\) instead\.$"
32193219
)
32203220
h = {b"a": b"1", b"b": b"2", b"c": b"3"}
32213221
with pytest.warns(DeprecationWarning, match=warning_message):

tests/test_connection.py

-1
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,6 @@ def test_unix_socket_connection_failure():
363363

364364

365365
class TestUnitConnectionPool:
366-
367366
@pytest.mark.parametrize(
368367
"max_conn", (-1, "str"), ids=("non-positive", "wrong type")
369368
)

0 commit comments

Comments
 (0)