Skip to content

Commit

Permalink
Upgrade Flake8 (#3323)
Browse files Browse the repository at this point in the history
Use the latest available Flake8. Fix some linter errors that surfaced.

Take the opportunity to fix typing hints and remove code duplication
around CommandsProtocol.
  • Loading branch information
gerzse authored Jul 18, 2024
1 parent 9607608 commit 7e2b4fb
Show file tree
Hide file tree
Showing 9 changed files with 8 additions and 15 deletions.
4 changes: 2 additions & 2 deletions dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
black==24.3.0
cachetools
click==8.0.4
flake8-isort==6.0.0
flake8==5.0.4
flake8-isort
flake8
flynt~=0.69.0
invoke==2.2.0
mock
Expand Down
2 changes: 1 addition & 1 deletion redis/_parsers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -507,7 +507,7 @@ def parse_geosearch_generic(response, **options):
except KeyError: # it means the command was sent via execute_command
return response

if type(response) != list:
if not isinstance(response, list):
response_list = [response]
else:
response_list = response
Expand Down
3 changes: 0 additions & 3 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -1380,9 +1380,6 @@ def failover(self):
)


AsyncManagementCommands = ManagementCommands


class AsyncManagementCommands(ManagementCommands):
async def command_info(self, **kwargs) -> None:
return super().command_info(**kwargs)
Expand Down
2 changes: 1 addition & 1 deletion redis/commands/timeseries/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ def __init__(self, args):
self.chunk_size = response["chunkSize"]
if "duplicatePolicy" in response:
self.duplicate_policy = response["duplicatePolicy"]
if type(self.duplicate_policy) == bytes:
if isinstance(self.duplicate_policy, bytes):
self.duplicate_policy = self.duplicate_policy.decode()

def get(self, item):
Expand Down
6 changes: 2 additions & 4 deletions redis/typing.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,10 +54,8 @@
class CommandsProtocol(Protocol):
connection_pool: Union["AsyncConnectionPool", "ConnectionPool"]

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


class ClusterCommandsProtocol(CommandsProtocol, Protocol):
class ClusterCommandsProtocol(CommandsProtocol):
encoder: "Encoder"

def execute_command(self, *args, **options) -> Union[Any, Awaitable]: ...
1 change: 0 additions & 1 deletion tests/test_asyncio/test_connection_pool.py
Original file line number Diff line number Diff line change
Expand Up @@ -647,7 +647,6 @@ def test_connect_from_url_tcp(self):
connection = redis.Redis.from_url("redis://localhost")
pool = connection.connection_pool

print(repr(pool))
assert re.match(
r"< .*?([^\.]+) \( < .*?([^\.]+) \( (.+) \) > \) >", repr(pool), re.VERBOSE
).groups() == (
Expand Down
2 changes: 1 addition & 1 deletion tests/test_asyncio/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -237,4 +237,4 @@ def __init__(self, *args, **kwargs):
pass

lock = r.lock("foo", lock_class=MyLock)
assert type(lock) == MyLock
assert isinstance(lock, MyLock)
1 change: 0 additions & 1 deletion tests/test_json.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,6 @@ def test_json_forget_with_dollar(client):
client.json().forget("not_a_document", "..a")


@pytest.mark.onlynoncluster
@pytest.mark.redismod
def test_json_mget_dollar(client):
# Test mget with multi paths
Expand Down
2 changes: 1 addition & 1 deletion tests/test_lock.py
Original file line number Diff line number Diff line change
Expand Up @@ -257,4 +257,4 @@ def __init__(self, *args, **kwargs):
pass

lock = r.lock("foo", lock_class=MyLock)
assert type(lock) == MyLock
assert isinstance(lock, MyLock)

0 comments on commit 7e2b4fb

Please sign in to comment.