Skip to content

Commit 11ec84b

Browse files
committed
Fixed linters
1 parent 5f6e9f0 commit 11ec84b

File tree

4 files changed

+47
-32
lines changed

4 files changed

+47
-32
lines changed

redis/commands/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,4 @@
1212
'list_or_args',
1313
'RedisModuleCommands',
1414
'SentinelCommands'
15-
]
15+
]

redis/commands/core.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -374,7 +374,7 @@ def client_info(self, **kwargs):
374374
For more information check https://redis.io/commands/client-info
375375
"""
376376
return self.execute_command('CLIENT INFO', **kwargs)
377-
377+
378378
def client_list(self, _type=None, client_id=[], **kwargs):
379379
"""
380380
Returns a list of currently connected clients.

tests/test_cluster.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,6 @@
3131
from redis.utils import str_if_bytes
3232
from tests.test_pubsub import wait_for_message
3333

34-
from redis.crc import key_slot
3534
from .conftest import (
3635
_get_client,
3736
skip_if_redis_enterprise,

tests/test_connection_pool.py

Lines changed: 45 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,8 @@
99
import redis
1010
from redis.connection import ssl_available, to_bool
1111

12-
from .conftest import _get_client, skip_if_redis_enterprise, skip_if_server_version_lt
12+
from .conftest import _get_client, skip_if_redis_enterprise, \
13+
skip_if_server_version_lt
1314
from .test_pubsub import wait_for_message
1415

1516

@@ -45,7 +46,8 @@ def get_pool(
4546
def test_connection_creation(self):
4647
connection_kwargs = {"foo": "bar", "biz": "baz"}
4748
pool = self.get_pool(
48-
connection_kwargs=connection_kwargs, connection_class=DummyConnection
49+
connection_kwargs=connection_kwargs,
50+
connection_class=DummyConnection
4951
)
5052
connection = pool.get_connection("_")
5153
assert isinstance(connection, DummyConnection)
@@ -60,7 +62,8 @@ def test_multiple_connections(self, master_host):
6062

6163
def test_max_connections(self, master_host):
6264
connection_kwargs = {"host": master_host[0], "port": master_host[1]}
63-
pool = self.get_pool(max_connections=2, connection_kwargs=connection_kwargs)
65+
pool = self.get_pool(max_connections=2,
66+
connection_kwargs=connection_kwargs)
6467
pool.get_connection("_")
6568
pool.get_connection("_")
6669
with pytest.raises(redis.ConnectionError):
@@ -82,7 +85,8 @@ def test_repr_contains_db_info_tcp(self):
8285
"client_name": "test-client",
8386
}
8487
pool = self.get_pool(
85-
connection_kwargs=connection_kwargs, connection_class=redis.Connection
88+
connection_kwargs=connection_kwargs,
89+
connection_class=redis.Connection
8690
)
8791
expected = (
8892
"ConnectionPool<Connection<"
@@ -91,7 +95,8 @@ def test_repr_contains_db_info_tcp(self):
9195
assert repr(pool) == expected
9296

9397
def test_repr_contains_db_info_unix(self):
94-
connection_kwargs = {"path": "/abc", "db": 1, "client_name": "test-client"}
98+
connection_kwargs = {"path": "/abc", "db": 1,
99+
"client_name": "test-client"}
95100
pool = self.get_pool(
96101
connection_kwargs=connection_kwargs,
97102
connection_class=redis.UnixDomainSocketConnection,
@@ -330,7 +335,8 @@ def test_boolean_parsing(self):
330335
assert expected is to_bool(value)
331336

332337
def test_client_name_in_querystring(self):
333-
pool = redis.ConnectionPool.from_url("redis://location?client_name=test-client")
338+
pool = redis.ConnectionPool.from_url(
339+
"redis://location?client_name=test-client")
334340
assert pool.connection_kwargs["client_name"] == "test-client"
335341

336342
def test_invalid_extra_typed_querystring_options(self):
@@ -342,7 +348,8 @@ def test_invalid_extra_typed_querystring_options(self):
342348
def test_extra_querystring_options(self):
343349
pool = redis.ConnectionPool.from_url("redis://localhost?a=1&b=2")
344350
assert pool.connection_class == redis.Connection
345-
assert pool.connection_kwargs == {"host": "localhost", "a": "1", "b": "2"}
351+
assert pool.connection_kwargs == {"host": "localhost", "a": "1",
352+
"b": "2"}
346353

347354
def test_calling_from_subclass_returns_correct_instance(self):
348355
pool = redis.BlockingConnectionPool.from_url("redis://localhost")
@@ -437,13 +444,15 @@ def test_db_in_querystring(self):
437444
}
438445

439446
def test_client_name_in_querystring(self):
440-
pool = redis.ConnectionPool.from_url("redis://location?client_name=test-client")
447+
pool = redis.ConnectionPool.from_url(
448+
"redis://location?client_name=test-client")
441449
assert pool.connection_kwargs["client_name"] == "test-client"
442450

443451
def test_extra_querystring_options(self):
444452
pool = redis.ConnectionPool.from_url("unix:///socket?a=1&b=2")
445453
assert pool.connection_class == redis.UnixDomainSocketConnection
446-
assert pool.connection_kwargs == {"path": "/socket", "a": "1", "b": "2"}
454+
assert pool.connection_kwargs == {"path": "/socket", "a": "1",
455+
"b": "2"}
447456

448457

449458
@pytest.mark.skipif(not ssl_available, reason="SSL not installed")
@@ -471,10 +480,12 @@ def get_connection(self, *args, **kwargs):
471480
pool = DummyConnectionPool.from_url("rediss://?ssl_cert_reqs=required")
472481
assert pool.get_connection("_").cert_reqs == ssl.CERT_REQUIRED
473482

474-
pool = DummyConnectionPool.from_url("rediss://?ssl_check_hostname=False")
483+
pool = DummyConnectionPool.from_url(
484+
"rediss://?ssl_check_hostname=False")
475485
assert pool.get_connection("_").check_hostname is False
476486

477-
pool = DummyConnectionPool.from_url("rediss://?ssl_check_hostname=True")
487+
pool = DummyConnectionPool.from_url(
488+
"rediss://?ssl_check_hostname=True")
478489
assert pool.get_connection("_").check_hostname is True
479490

480491

@@ -497,7 +508,6 @@ def test_on_connect_error(self):
497508
@pytest.mark.onlynoncluster
498509
@skip_if_server_version_lt('2.8.8')
499510
@skip_if_redis_enterprise()
500-
501511
def test_busy_loading_disconnects_socket(self, r):
502512
"""
503513
If Redis raises a LOADING error, the connection should be
@@ -510,15 +520,15 @@ def test_busy_loading_disconnects_socket(self, r):
510520
@pytest.mark.onlynoncluster
511521
@skip_if_server_version_lt('2.8.8')
512522
@skip_if_redis_enterprise()
513-
514523
def test_busy_loading_from_pipeline_immediate_command(self, r):
515524
"""
516525
BusyLoadingErrors should raise from Pipelines that execute a
517526
command immediately, like WATCH does.
518527
"""
519528
pipe = r.pipeline()
520529
with pytest.raises(redis.BusyLoadingError):
521-
pipe.immediate_execute_command("DEBUG", "ERROR", "LOADING fake message")
530+
pipe.immediate_execute_command("DEBUG", "ERROR",
531+
"LOADING fake message")
522532
pool = r.connection_pool
523533
assert not pipe.connection
524534
assert len(pool._available_connections) == 1
@@ -527,7 +537,6 @@ def test_busy_loading_from_pipeline_immediate_command(self, r):
527537
@pytest.mark.onlynoncluster
528538
@skip_if_server_version_lt('2.8.8')
529539
@skip_if_redis_enterprise()
530-
531540
def test_busy_loading_from_pipeline(self, r):
532541
"""
533542
BusyLoadingErrors should be raised from a pipeline execution
@@ -544,7 +553,6 @@ def test_busy_loading_from_pipeline(self, r):
544553

545554
@skip_if_server_version_lt('2.8.8')
546555
@skip_if_redis_enterprise()
547-
548556
def test_read_only_error(self, r):
549557
"READONLY errors get turned in ReadOnlyError exceptions"
550558
with pytest.raises(redis.ReadOnlyError):
@@ -578,7 +586,8 @@ def test_connect_no_auth_supplied_when_required(self, r):
578586
"""
579587
with pytest.raises(redis.AuthenticationError):
580588
r.execute_command(
581-
"DEBUG", "ERROR", "ERR Client sent AUTH, but no password is set"
589+
"DEBUG", "ERROR",
590+
"ERR Client sent AUTH, but no password is set"
582591
)
583592

584593
@skip_if_redis_enterprise()
@@ -592,7 +601,8 @@ def test_connect_invalid_password_supplied(self, r):
592601
class TestMultiConnectionClient:
593602
@pytest.fixture()
594603
def r(self, request):
595-
return _get_client(redis.Redis, request, single_connection_client=False)
604+
return _get_client(redis.Redis, request,
605+
single_connection_client=False)
596606

597607
def test_multi_connection_command(self, r):
598608
assert not r.connection
@@ -606,7 +616,8 @@ class TestHealthCheck:
606616

607617
@pytest.fixture()
608618
def r(self, request):
609-
return _get_client(redis.Redis, request, health_check_interval=self.interval)
619+
return _get_client(redis.Redis, request,
620+
health_check_interval=self.interval)
610621

611622
def assert_interval_advanced(self, connection):
612623
diff = connection.next_health_check - time.time()
@@ -622,7 +633,7 @@ def test_arbitrary_command_invokes_health_check(self, r):
622633
r.get("foo")
623634
r.connection.next_health_check = time.time()
624635
with mock.patch.object(
625-
r.connection, "send_command", wraps=r.connection.send_command
636+
r.connection, "send_command", wraps=r.connection.send_command
626637
) as m:
627638
r.get("foo")
628639
m.assert_called_with("PING", check_health=False)
@@ -638,7 +649,7 @@ def test_arbitrary_command_advances_next_health_check(self, r):
638649
def test_health_check_not_invoked_within_interval(self, r):
639650
r.get("foo")
640651
with mock.patch.object(
641-
r.connection, "send_command", wraps=r.connection.send_command
652+
r.connection, "send_command", wraps=r.connection.send_command
642653
) as m:
643654
r.get("foo")
644655
ping_call_spec = (("PING",), {"check_health": False})
@@ -649,7 +660,8 @@ def test_health_check_in_pipeline(self, r):
649660
pipe.connection = pipe.connection_pool.get_connection("_")
650661
pipe.connection.next_health_check = 0
651662
with mock.patch.object(
652-
pipe.connection, "send_command", wraps=pipe.connection.send_command
663+
pipe.connection, "send_command",
664+
wraps=pipe.connection.send_command
653665
) as m:
654666
responses = pipe.set("foo", "bar").get("foo").execute()
655667
m.assert_any_call("PING", check_health=False)
@@ -660,7 +672,8 @@ def test_health_check_in_transaction(self, r):
660672
pipe.connection = pipe.connection_pool.get_connection("_")
661673
pipe.connection.next_health_check = 0
662674
with mock.patch.object(
663-
pipe.connection, "send_command", wraps=pipe.connection.send_command
675+
pipe.connection, "send_command",
676+
wraps=pipe.connection.send_command
664677
) as m:
665678
responses = pipe.set("foo", "bar").get("foo").execute()
666679
m.assert_any_call("PING", check_health=False)
@@ -672,7 +685,8 @@ def test_health_check_in_watched_pipeline(self, r):
672685
pipe.connection = pipe.connection_pool.get_connection("_")
673686
pipe.connection.next_health_check = 0
674687
with mock.patch.object(
675-
pipe.connection, "send_command", wraps=pipe.connection.send_command
688+
pipe.connection, "send_command",
689+
wraps=pipe.connection.send_command
676690
) as m:
677691
pipe.watch("foo")
678692
# the health check should be called when watching
@@ -696,7 +710,7 @@ def test_health_check_in_pubsub_before_subscribe(self, r):
696710
p.connection = p.connection_pool.get_connection("_")
697711
p.connection.next_health_check = 0
698712
with mock.patch.object(
699-
p.connection, "send_command", wraps=p.connection.send_command
713+
p.connection, "send_command", wraps=p.connection.send_command
700714
) as m:
701715
assert not p.subscribed
702716
p.subscribe("foo")
@@ -718,7 +732,7 @@ def test_health_check_in_pubsub_after_subscribed(self, r):
718732
p.connection = p.connection_pool.get_connection("_")
719733
p.connection.next_health_check = 0
720734
with mock.patch.object(
721-
p.connection, "send_command", wraps=p.connection.send_command
735+
p.connection, "send_command", wraps=p.connection.send_command
722736
) as m:
723737
p.subscribe("foo")
724738
subscribe_message = wait_for_message(p)
@@ -746,7 +760,8 @@ def test_health_check_in_pubsub_after_subscribed(self, r):
746760
assert wait_for_message(p) is None
747761
# now that the connection is subscribed, the pubsub health
748762
# check should have taken over and include the HEALTH_CHECK_MESSAGE
749-
m.assert_any_call("PING", p.HEALTH_CHECK_MESSAGE, check_health=False)
763+
m.assert_any_call("PING", p.HEALTH_CHECK_MESSAGE,
764+
check_health=False)
750765
self.assert_interval_advanced(p.connection)
751766

752767
def test_health_check_in_pubsub_poll(self, r):
@@ -757,7 +772,7 @@ def test_health_check_in_pubsub_poll(self, r):
757772
p = r.pubsub()
758773
p.connection = p.connection_pool.get_connection("_")
759774
with mock.patch.object(
760-
p.connection, "send_command", wraps=p.connection.send_command
775+
p.connection, "send_command", wraps=p.connection.send_command
761776
) as m:
762777
p.subscribe("foo")
763778
subscribe_message = wait_for_message(p)
@@ -777,5 +792,6 @@ def test_health_check_in_pubsub_poll(self, r):
777792
# should be advanced
778793
p.connection.next_health_check = 0
779794
assert wait_for_message(p) is None
780-
m.assert_called_with("PING", p.HEALTH_CHECK_MESSAGE, check_health=False)
795+
m.assert_called_with("PING", p.HEALTH_CHECK_MESSAGE,
796+
check_health=False)
781797
self.assert_interval_advanced(p.connection)

0 commit comments

Comments
 (0)