Skip to content

Commit a336639

Browse files
committed
Fixing linter errors - dues to backporting from master where formatter is updated
1 parent b928f97 commit a336639

File tree

5 files changed

+34
-26
lines changed

5 files changed

+34
-26
lines changed

redis/asyncio/cluster.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -139,11 +139,13 @@ class RedisCluster(AbstractRedis, AbstractRedisCluster, AsyncRedisClusterCommand
139139
| Enable read from replicas in READONLY mode.
140140
When set to true, read commands will be assigned between the primary and
141141
its replications in a Round-Robin manner.
142-
The data read from replicas is eventually consistent with the data in primary nodes.
142+
The data read from replicas is eventually consistent
143+
with the data in primary nodes.
143144
:param load_balancing_strategy:
144145
| Enable read from replicas in READONLY mode and defines the load balancing
145146
strategy that will be used for cluster node selection.
146-
The data read from replicas is eventually consistent with the data in primary nodes.
147+
The data read from replicas is eventually consistent
148+
with the data in primary nodes.
147149
:param reinitialize_steps:
148150
| Specifies the number of MOVED errors that need to occur before reinitializing
149151
the whole cluster topology. If a MOVED error occurs and the cluster does not
@@ -800,9 +802,11 @@ async def _execute_command(
800802
target_node = self.nodes_manager.get_node_from_slot(
801803
slot,
802804
self.read_from_replicas and args[0] in READ_COMMANDS,
803-
self.load_balancing_strategy
804-
if args[0] in READ_COMMANDS
805-
else None,
805+
(
806+
self.load_balancing_strategy
807+
if args[0] in READ_COMMANDS
808+
else None
809+
),
806810
)
807811
moved = False
808812

@@ -1276,7 +1280,8 @@ def get_node_from_slot(
12761280

12771281
try:
12781282
if len(self.slots_cache[slot]) > 1 and load_balancing_strategy:
1279-
# get the server index using the strategy defined in load_balancing_strategy
1283+
# get the server index using the strategy defined
1284+
# in load_balancing_strategy
12801285
primary_name = self.slots_cache[slot][0].name
12811286
node_idx = self.read_load_balancer.get_server_index(
12821287
primary_name, len(self.slots_cache[slot]), load_balancing_strategy

redis/cluster.py

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -558,7 +558,8 @@ def __init__(
558558
:param load_balancing_strategy:
559559
Enable read from replicas in READONLY mode and defines the load balancing
560560
strategy that will be used for cluster node selection.
561-
The data read from replicas is eventually consistent with the data in primary nodes.
561+
The data read from replicas is eventually consistent
562+
with the data in primary nodes.
562563
:param dynamic_startup_nodes:
563564
Set the RedisCluster's startup nodes to all of the discovered nodes.
564565
If true (default value), the cluster's discovered nodes will be used to
@@ -1190,9 +1191,11 @@ def _execute_command(self, target_node, *args, **kwargs):
11901191
target_node = self.nodes_manager.get_node_from_slot(
11911192
slot,
11921193
self.read_from_replicas and command in READ_COMMANDS,
1193-
self.load_balancing_strategy
1194-
if command in READ_COMMANDS
1195-
else None,
1194+
(
1195+
self.load_balancing_strategy
1196+
if command in READ_COMMANDS
1197+
else None
1198+
),
11961199
)
11971200
moved = False
11981201

@@ -1366,7 +1369,7 @@ def get_server_index(
13661369
self,
13671370
primary: str,
13681371
list_size: int,
1369-
load_balancing_strategy: LoadBalancingStrategy = LoadBalancingStrategy.ROUND_ROBIN,
1372+
load_balancing_strategy: LoadBalancingStrategy = LoadBalancingStrategy.ROUND_ROBIN, # noqa: line too long ignored
13701373
) -> int:
13711374
if load_balancing_strategy == LoadBalancingStrategy.RANDOM_REPLICA:
13721375
return self._get_random_replica_index(list_size)

tests/test_asyncio/test_cluster.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ async def get_mocked_redis_client(
152152
with mock.patch.object(ClusterNode, "execute_command") as execute_command_mock:
153153

154154
async def execute_command(*_args, **_kwargs):
155-
156155
if _args[0] == "CLUSTER SLOTS":
157156
if cluster_slots_raise_error:
158157
raise ResponseError()
@@ -197,7 +196,8 @@ def __del__(self):
197196
@property
198197
def connection_pool(self):
199198
# Required abstract property implementation
200-
return self.nodes_manager.get_default_node().redis_connection.connection_pool
199+
default_node = self.nodes_manager.get_default_node()
200+
return default_node.redis_connection.connection_pool
201201

202202
return await MockedRedisCluster(*args, **kwargs)
203203

@@ -1643,23 +1643,23 @@ async def test_cluster_bitop_not_empty_string(self, r: RedisCluster) -> None:
16431643

16441644
@skip_if_server_version_lt("2.6.0")
16451645
async def test_cluster_bitop_not(self, r: RedisCluster) -> None:
1646-
test_str = b"\xAA\x00\xFF\x55"
1646+
test_str = b"\xaa\x00\xff\x55"
16471647
correct = ~0xAA00FF55 & 0xFFFFFFFF
16481648
await r.set("{foo}a", test_str)
16491649
await r.bitop("not", "{foo}r", "{foo}a")
16501650
assert int(binascii.hexlify(await r.get("{foo}r")), 16) == correct
16511651

16521652
@skip_if_server_version_lt("2.6.0")
16531653
async def test_cluster_bitop_not_in_place(self, r: RedisCluster) -> None:
1654-
test_str = b"\xAA\x00\xFF\x55"
1654+
test_str = b"\xaa\x00\xff\x55"
16551655
correct = ~0xAA00FF55 & 0xFFFFFFFF
16561656
await r.set("{foo}a", test_str)
16571657
await r.bitop("not", "{foo}a", "{foo}a")
16581658
assert int(binascii.hexlify(await r.get("{foo}a")), 16) == correct
16591659

16601660
@skip_if_server_version_lt("2.6.0")
16611661
async def test_cluster_bitop_single_string(self, r: RedisCluster) -> None:
1662-
test_str = b"\x01\x02\xFF"
1662+
test_str = b"\x01\x02\xff"
16631663
await r.set("{foo}a", test_str)
16641664
await r.bitop("and", "{foo}res1", "{foo}a")
16651665
await r.bitop("or", "{foo}res2", "{foo}a")
@@ -1670,8 +1670,8 @@ async def test_cluster_bitop_single_string(self, r: RedisCluster) -> None:
16701670

16711671
@skip_if_server_version_lt("2.6.0")
16721672
async def test_cluster_bitop_string_operands(self, r: RedisCluster) -> None:
1673-
await r.set("{foo}a", b"\x01\x02\xFF\xFF")
1674-
await r.set("{foo}b", b"\x01\x02\xFF")
1673+
await r.set("{foo}a", b"\x01\x02\xff\xff")
1674+
await r.set("{foo}b", b"\x01\x02\xff")
16751675
await r.bitop("and", "{foo}res1", "{foo}a", "{foo}b")
16761676
await r.bitop("or", "{foo}res2", "{foo}a", "{foo}b")
16771677
await r.bitop("xor", "{foo}res3", "{foo}a", "{foo}b")

tests/test_backoff.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
from unittest.mock import Mock
22

33
import pytest
4-
54
from redis.backoff import ExponentialWithJitterBackoff
65

76

tests/test_cluster.py

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,10 @@
44
import socket
55
import socketserver
66
import threading
7-
from typing import List
87
import warnings
98
from queue import LifoQueue, Queue
109
from time import sleep
10+
from typing import List
1111
from unittest.mock import DEFAULT, Mock, call, patch
1212

1313
import pytest
@@ -213,7 +213,8 @@ def __del__(self):
213213
@property
214214
def connection_pool(self):
215215
# Required abstract property implementation
216-
return self.nodes_manager.get_default_node().redis_connection.connection_pool
216+
default_node = self.nodes_manager.get_default_node()
217+
return default_node.redis_connection.connection_pool
217218

218219
return MockedRedisCluster(*args, **kwargs)
219220

@@ -1766,23 +1767,23 @@ def test_cluster_bitop_not_empty_string(self, r):
17661767

17671768
@skip_if_server_version_lt("2.6.0")
17681769
def test_cluster_bitop_not(self, r):
1769-
test_str = b"\xAA\x00\xFF\x55"
1770+
test_str = b"\xaa\x00\xff\x55"
17701771
correct = ~0xAA00FF55 & 0xFFFFFFFF
17711772
r["{foo}a"] = test_str
17721773
r.bitop("not", "{foo}r", "{foo}a")
17731774
assert int(binascii.hexlify(r["{foo}r"]), 16) == correct
17741775

17751776
@skip_if_server_version_lt("2.6.0")
17761777
def test_cluster_bitop_not_in_place(self, r):
1777-
test_str = b"\xAA\x00\xFF\x55"
1778+
test_str = b"\xaa\x00\xff\x55"
17781779
correct = ~0xAA00FF55 & 0xFFFFFFFF
17791780
r["{foo}a"] = test_str
17801781
r.bitop("not", "{foo}a", "{foo}a")
17811782
assert int(binascii.hexlify(r["{foo}a"]), 16) == correct
17821783

17831784
@skip_if_server_version_lt("2.6.0")
17841785
def test_cluster_bitop_single_string(self, r):
1785-
test_str = b"\x01\x02\xFF"
1786+
test_str = b"\x01\x02\xff"
17861787
r["{foo}a"] = test_str
17871788
r.bitop("and", "{foo}res1", "{foo}a")
17881789
r.bitop("or", "{foo}res2", "{foo}a")
@@ -1793,8 +1794,8 @@ def test_cluster_bitop_single_string(self, r):
17931794

17941795
@skip_if_server_version_lt("2.6.0")
17951796
def test_cluster_bitop_string_operands(self, r):
1796-
r["{foo}a"] = b"\x01\x02\xFF\xFF"
1797-
r["{foo}b"] = b"\x01\x02\xFF"
1797+
r["{foo}a"] = b"\x01\x02\xff\xff"
1798+
r["{foo}b"] = b"\x01\x02\xff"
17981799
r.bitop("and", "{foo}res1", "{foo}a", "{foo}b")
17991800
r.bitop("or", "{foo}res2", "{foo}a", "{foo}b")
18001801
r.bitop("xor", "{foo}res3", "{foo}a", "{foo}b")

0 commit comments

Comments
 (0)