Skip to content

Commit 47822c3

Browse files
committed
Replace black with ruff format; run it
1 parent 629371b commit 47822c3

File tree

13 files changed

+30
-33
lines changed

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
@@ -3412,7 +3412,9 @@ def smembers(self, name: str) -> Union[Awaitable[Set], Set]:
34123412
"""
34133413
return self.execute_command("SMEMBERS", name, keys=[name])
34143414

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

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
run("flynt --fail-on-change --dry-run tests redis")
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
@@ -142,7 +142,6 @@ async def get_mocked_redis_client(
142142
with mock.patch.object(ClusterNode, "execute_command") as execute_command_mock:
143143

144144
async def execute_command(*_args, **_kwargs):
145-
146145
if _args[0] == "CLUSTER SLOTS":
147146
if cluster_slots_raise_error:
148147
raise ResponseError()
@@ -1574,23 +1573,23 @@ async def test_cluster_bitop_not_empty_string(self, r: RedisCluster) -> None:
15741573

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

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

15911590
@skip_if_server_version_lt("2.6.0")
15921591
async def test_cluster_bitop_single_string(self, r: RedisCluster) -> None:
1593-
test_str = b"\x01\x02\xFF"
1592+
test_str = b"\x01\x02\xff"
15941593
await r.set("{foo}a", test_str)
15951594
await r.bitop("and", "{foo}res1", "{foo}a")
15961595
await r.bitop("or", "{foo}res2", "{foo}a")
@@ -1601,8 +1600,8 @@ async def test_cluster_bitop_single_string(self, r: RedisCluster) -> None:
16011600

16021601
@skip_if_server_version_lt("2.6.0")
16031602
async def test_cluster_bitop_string_operands(self, r: RedisCluster) -> None:
1604-
await r.set("{foo}a", b"\x01\x02\xFF\xFF")
1605-
await r.set("{foo}b", b"\x01\x02\xFF")
1603+
await r.set("{foo}a", b"\x01\x02\xff\xff")
1604+
await r.set("{foo}b", b"\x01\x02\xff")
16061605
await r.bitop("and", "{foo}res1", "{foo}a", "{foo}b")
16071606
await r.bitop("or", "{foo}res2", "{foo}a", "{foo}b")
16081607
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
@@ -1035,7 +1035,7 @@ def test_bitop_not_empty_string(self, r):
10351035
@pytest.mark.onlynoncluster
10361036
@skip_if_server_version_lt("2.6.0")
10371037
def test_bitop_not(self, r):
1038-
test_str = b"\xAA\x00\xFF\x55"
1038+
test_str = b"\xaa\x00\xff\x55"
10391039
correct = ~0xAA00FF55 & 0xFFFFFFFF
10401040
r["a"] = test_str
10411041
r.bitop("not", "r", "a")
@@ -1044,7 +1044,7 @@ def test_bitop_not(self, r):
10441044
@pytest.mark.onlynoncluster
10451045
@skip_if_server_version_lt("2.6.0")
10461046
def test_bitop_not_in_place(self, r):
1047-
test_str = b"\xAA\x00\xFF\x55"
1047+
test_str = b"\xaa\x00\xff\x55"
10481048
correct = ~0xAA00FF55 & 0xFFFFFFFF
10491049
r["a"] = test_str
10501050
r.bitop("not", "a", "a")
@@ -1053,7 +1053,7 @@ def test_bitop_not_in_place(self, r):
10531053
@pytest.mark.onlynoncluster
10541054
@skip_if_server_version_lt("2.6.0")
10551055
def test_bitop_single_string(self, r):
1056-
test_str = b"\x01\x02\xFF"
1056+
test_str = b"\x01\x02\xff"
10571057
r["a"] = test_str
10581058
r.bitop("and", "res1", "a")
10591059
r.bitop("or", "res2", "a")
@@ -1065,8 +1065,8 @@ def test_bitop_single_string(self, r):
10651065
@pytest.mark.onlynoncluster
10661066
@skip_if_server_version_lt("2.6.0")
10671067
def test_bitop_string_operands(self, r):
1068-
r["a"] = b"\x01\x02\xFF\xFF"
1069-
r["b"] = b"\x01\x02\xFF"
1068+
r["a"] = b"\x01\x02\xff\xff"
1069+
r["b"] = b"\x01\x02\xff"
10701070
r.bitop("and", "res1", "a", "b")
10711071
r.bitop("or", "res2", "a", "b")
10721072
r.bitop("xor", "res3", "a", "b")
@@ -3207,8 +3207,8 @@ def test_hmget(self, r):
32073207
def test_hmset(self, r):
32083208
redis_class = type(r).__name__
32093209
warning_message = (
3210-
r"^{0}\.hmset\(\) is deprecated\. "
3211-
r"Use {0}\.hset\(\) instead\.$".format(redis_class)
3210+
rf"^{redis_class}\.hmset\(\) is deprecated\. "
3211+
rf"Use {redis_class}\.hset\(\) instead\.$"
32123212
)
32133213
h = {b"a": b"1", b"b": b"2", b"c": b"3"}
32143214
with pytest.warns(DeprecationWarning, match=warning_message):

0 commit comments

Comments
 (0)