Skip to content

Commit 49b5c45

Browse files
author
Shubham Kaudewar
committed
linter checks
1 parent 728c205 commit 49b5c45

File tree

3 files changed

+42
-11
lines changed

3 files changed

+42
-11
lines changed

redis/cache.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@ class CacheKey:
2828
when commands have the same keys but different arguments.
2929
Changing this field will affect cache key uniqueness.
3030
"""
31+
3132
command: str
3233
redis_keys: tuple
3334
redis_args: tuple = () # Additional arguments for the Redis command; affects cache key uniqueness.

redis/connection.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1214,7 +1214,9 @@ def send_command(self, *args, **kwargs):
12141214
with self._cache_lock:
12151215
# Command is write command or not allowed
12161216
# to be cached.
1217-
if not self._cache.is_cachable(CacheKey(command=args[0], redis_keys=(), redis_args=())):
1217+
if not self._cache.is_cachable(
1218+
CacheKey(command=args[0], redis_keys=(), redis_args=())
1219+
):
12181220
self._current_command_cache_key = None
12191221
self._conn.send_command(*args, **kwargs)
12201222
return

tests/test_connection.py

Lines changed: 38 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -357,7 +357,7 @@ def test_network_connection_failure():
357357

358358
@pytest.mark.skipif(
359359
not hasattr(socket, "AF_UNIX"),
360-
reason="Unix domain sockets not supported on this platform"
360+
reason="Unix domain sockets not supported on this platform",
361361
)
362362
def test_unix_socket_connection_failure():
363363
exp_err = "Error 2 connecting to unix:///tmp/a.sock. No such file or directory."
@@ -468,25 +468,33 @@ def test_read_response_returns_cached_reply(self, mock_cache, mock_connection):
468468
None,
469469
None,
470470
CacheEntry(
471-
cache_key=CacheKey(command="GET", redis_keys=("foo",), redis_args=("GET", "foo")),
471+
cache_key=CacheKey(
472+
command="GET", redis_keys=("foo",), redis_args=("GET", "foo")
473+
),
472474
cache_value=CacheProxyConnection.DUMMY_CACHE_VALUE,
473475
status=CacheEntryStatus.IN_PROGRESS,
474476
connection_ref=mock_connection,
475477
),
476478
CacheEntry(
477-
cache_key=CacheKey(command="GET", redis_keys=("foo",), redis_args=("GET", "foo")),
479+
cache_key=CacheKey(
480+
command="GET", redis_keys=("foo",), redis_args=("GET", "foo")
481+
),
478482
cache_value=b"bar",
479483
status=CacheEntryStatus.VALID,
480484
connection_ref=mock_connection,
481485
),
482486
CacheEntry(
483-
cache_key=CacheKey(command="GET", redis_keys=("foo",), redis_args=("GET", "foo")),
487+
cache_key=CacheKey(
488+
command="GET", redis_keys=("foo",), redis_args=("GET", "foo")
489+
),
484490
cache_value=b"bar",
485491
status=CacheEntryStatus.VALID,
486492
connection_ref=mock_connection,
487493
),
488494
CacheEntry(
489-
cache_key=CacheKey(command="GET", redis_keys=("foo",), redis_args=("GET", "foo")),
495+
cache_key=CacheKey(
496+
command="GET", redis_keys=("foo",), redis_args=("GET", "foo")
497+
),
490498
cache_value=b"bar",
491499
status=CacheEntryStatus.VALID,
492500
connection_ref=mock_connection,
@@ -508,15 +516,23 @@ def test_read_response_returns_cached_reply(self, mock_cache, mock_connection):
508516
[
509517
call(
510518
CacheEntry(
511-
cache_key=CacheKey(command="GET", redis_keys=("foo",), redis_args=("GET", "foo")),
519+
cache_key=CacheKey(
520+
command="GET",
521+
redis_keys=("foo",),
522+
redis_args=("GET", "foo"),
523+
),
512524
cache_value=CacheProxyConnection.DUMMY_CACHE_VALUE,
513525
status=CacheEntryStatus.IN_PROGRESS,
514526
connection_ref=mock_connection,
515527
)
516528
),
517529
call(
518530
CacheEntry(
519-
cache_key=CacheKey(command="GET", redis_keys=("foo",), redis_args=("GET", "foo")),
531+
cache_key=CacheKey(
532+
command="GET",
533+
redis_keys=("foo",),
534+
redis_args=("GET", "foo"),
535+
),
520536
cache_value=b"bar",
521537
status=CacheEntryStatus.VALID,
522538
connection_ref=mock_connection,
@@ -527,9 +543,21 @@ def test_read_response_returns_cached_reply(self, mock_cache, mock_connection):
527543

528544
mock_cache.get.assert_has_calls(
529545
[
530-
call(CacheKey(command="GET", redis_keys=("foo",), redis_args=("GET", "foo"))),
531-
call(CacheKey(command="GET", redis_keys=("foo",), redis_args=("GET", "foo"))),
532-
call(CacheKey(command="GET", redis_keys=("foo",), redis_args=("GET", "foo"))),
546+
call(
547+
CacheKey(
548+
command="GET", redis_keys=("foo",), redis_args=("GET", "foo")
549+
)
550+
),
551+
call(
552+
CacheKey(
553+
command="GET", redis_keys=("foo",), redis_args=("GET", "foo")
554+
)
555+
),
556+
call(
557+
CacheKey(
558+
command="GET", redis_keys=("foo",), redis_args=("GET", "foo")
559+
)
560+
),
533561
]
534562
)
535563

0 commit comments

Comments
 (0)