Skip to content

Commit 990604b

Browse files
committed
Replace black with ruff format; run it
1 parent bca7242 commit 990604b

13 files changed

+30
-33
lines changed

benchmarks/command_packer_benchmark.py

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1522,7 +1522,6 @@ def _disconnect_raise_reset(
15221522
conn.retry_on_error is None
15231523
or isinstance(error, tuple(conn.retry_on_error)) is False
15241524
):
1525-
15261525
self.reset()
15271526
raise error
15281527

redis/commands/core.py

Lines changed: 3 additions & 1 deletion
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

Lines changed: 1 addition & 3 deletions
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

Lines changed: 3 additions & 0 deletions
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

Lines changed: 1 addition & 1 deletion
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_cache.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,6 @@ async def test_execute_command_keys_not_provided(self, r):
371371
@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
372372
@pytest.mark.onlynoncluster
373373
class TestSentinelLocalCache:
374-
375374
async def test_get_from_cache(self, local_cache, master):
376375
await master.set("foo", "bar")
377376
# get key from redis and save in local cache

tests/test_asyncio/test_cluster.py

Lines changed: 5 additions & 6 deletions
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()
@@ -1580,23 +1579,23 @@ async def test_cluster_bitop_not_empty_string(self, r: RedisCluster) -> None:
15801579

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

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

15971596
@skip_if_server_version_lt("2.6.0")
15981597
async def test_cluster_bitop_single_string(self, r: RedisCluster) -> None:
1599-
test_str = b"\x01\x02\xFF"
1598+
test_str = b"\x01\x02\xff"
16001599
await r.set("{foo}a", test_str)
16011600
await r.bitop("and", "{foo}res1", "{foo}a")
16021601
await r.bitop("or", "{foo}res2", "{foo}a")
@@ -1607,8 +1606,8 @@ async def test_cluster_bitop_single_string(self, r: RedisCluster) -> None:
16071606

16081607
@skip_if_server_version_lt("2.6.0")
16091608
async def test_cluster_bitop_string_operands(self, r: RedisCluster) -> None:
1610-
await r.set("{foo}a", b"\x01\x02\xFF\xFF")
1611-
await r.set("{foo}b", b"\x01\x02\xFF")
1609+
await r.set("{foo}a", b"\x01\x02\xff\xff")
1610+
await r.set("{foo}b", b"\x01\x02\xff")
16121611
await r.bitop("and", "{foo}res1", "{foo}a", "{foo}b")
16131612
await r.bitop("or", "{foo}res2", "{foo}a", "{foo}b")
16141613
await r.bitop("xor", "{foo}res3", "{foo}a", "{foo}b")

tests/test_asyncio/test_commands.py

Lines changed: 5 additions & 5 deletions
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_cache.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,6 @@ def test_execute_command_keys_not_provided(self, r):
487487
@pytest.mark.skipif(HIREDIS_AVAILABLE, reason="PythonParser only")
488488
@pytest.mark.onlynoncluster
489489
class TestSentinelLocalCache:
490-
491490
def test_get_from_cache(self, local_cache, master):
492491
master.set("foo", "bar")
493492
# get key from redis and save in local cache

tests/test_cluster.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1694,23 +1694,23 @@ def test_cluster_bitop_not_empty_string(self, r):
16941694

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

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

17111711
@skip_if_server_version_lt("2.6.0")
17121712
def test_cluster_bitop_single_string(self, r):
1713-
test_str = b"\x01\x02\xFF"
1713+
test_str = b"\x01\x02\xff"
17141714
r["{foo}a"] = test_str
17151715
r.bitop("and", "{foo}res1", "{foo}a")
17161716
r.bitop("or", "{foo}res2", "{foo}a")
@@ -1721,8 +1721,8 @@ def test_cluster_bitop_single_string(self, r):
17211721

17221722
@skip_if_server_version_lt("2.6.0")
17231723
def test_cluster_bitop_string_operands(self, r):
1724-
r["{foo}a"] = b"\x01\x02\xFF\xFF"
1725-
r["{foo}b"] = b"\x01\x02\xFF"
1724+
r["{foo}a"] = b"\x01\x02\xff\xff"
1725+
r["{foo}b"] = b"\x01\x02\xff"
17261726
r.bitop("and", "{foo}res1", "{foo}a", "{foo}b")
17271727
r.bitop("or", "{foo}res2", "{foo}a", "{foo}b")
17281728
r.bitop("xor", "{foo}res3", "{foo}a", "{foo}b")

tests/test_commands.py

Lines changed: 7 additions & 7 deletions
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):

0 commit comments

Comments
 (0)