Skip to content

Commit 92381c3

Browse files
author
Gabriel Erzse
committed
Upgrade Flake8
Use the latest available Flake8. Fix some linter errors that surfaced. Take the opportunity to fix typing hints and remove code duplication around CommandsProtocol.
1 parent 9607608 commit 92381c3

File tree

9 files changed

+8
-15
lines changed

9 files changed

+8
-15
lines changed

dev_requirements.txt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
black==24.3.0
22
cachetools
33
click==8.0.4
4-
flake8-isort==6.0.0
5-
flake8==5.0.4
4+
flake8-isort
5+
flake8
66
flynt~=0.69.0
77
invoke==2.2.0
88
mock

redis/_parsers/helpers.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,7 @@ def parse_geosearch_generic(response, **options):
507507
except KeyError: # it means the command was sent via execute_command
508508
return response
509509

510-
if type(response) != list:
510+
if not isinstance(response, list):
511511
response_list = [response]
512512
else:
513513
response_list = response

redis/commands/core.py

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1380,9 +1380,6 @@ def failover(self):
13801380
)
13811381

13821382

1383-
AsyncManagementCommands = ManagementCommands
1384-
1385-
13861383
class AsyncManagementCommands(ManagementCommands):
13871384
async def command_info(self, **kwargs) -> None:
13881385
return super().command_info(**kwargs)

redis/commands/timeseries/info.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ def __init__(self, args):
7878
self.chunk_size = response["chunkSize"]
7979
if "duplicatePolicy" in response:
8080
self.duplicate_policy = response["duplicatePolicy"]
81-
if type(self.duplicate_policy) == bytes:
81+
if isinstance(self.duplicate_policy, bytes):
8282
self.duplicate_policy = self.duplicate_policy.decode()
8383

8484
def get(self, item):

redis/typing.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -54,10 +54,8 @@
5454
class CommandsProtocol(Protocol):
5555
connection_pool: Union["AsyncConnectionPool", "ConnectionPool"]
5656

57-
def execute_command(self, *args, **options): ...
57+
def execute_command(self, *args, **options) -> ResponseT: ...
5858

5959

60-
class ClusterCommandsProtocol(CommandsProtocol, Protocol):
60+
class ClusterCommandsProtocol(CommandsProtocol):
6161
encoder: "Encoder"
62-
63-
def execute_command(self, *args, **options) -> Union[Any, Awaitable]: ...

tests/test_asyncio/test_connection_pool.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -647,7 +647,6 @@ def test_connect_from_url_tcp(self):
647647
connection = redis.Redis.from_url("redis://localhost")
648648
pool = connection.connection_pool
649649

650-
print(repr(pool))
651650
assert re.match(
652651
r"< .*?([^\.]+) \( < .*?([^\.]+) \( (.+) \) > \) >", repr(pool), re.VERBOSE
653652
).groups() == (

tests/test_asyncio/test_lock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,4 +237,4 @@ def __init__(self, *args, **kwargs):
237237
pass
238238

239239
lock = r.lock("foo", lock_class=MyLock)
240-
assert type(lock) == MyLock
240+
assert isinstance(lock, MyLock)

tests/test_json.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -446,7 +446,6 @@ def test_json_forget_with_dollar(client):
446446
client.json().forget("not_a_document", "..a")
447447

448448

449-
@pytest.mark.onlynoncluster
450449
@pytest.mark.redismod
451450
def test_json_mget_dollar(client):
452451
# Test mget with multi paths

tests/test_lock.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -257,4 +257,4 @@ def __init__(self, *args, **kwargs):
257257
pass
258258

259259
lock = r.lock("foo", lock_class=MyLock)
260-
assert type(lock) == MyLock
260+
assert isinstance(lock, MyLock)

0 commit comments

Comments
 (0)