Skip to content

Commit 07fc339

Browse files
authored
Update black version to 24.3.0 (#3193)
* Update black version to 24.3.0 * fix black changes
1 parent 037d108 commit 07fc339

File tree

13 files changed

+55
-56
lines changed

13 files changed

+55
-56
lines changed

.flake8

+2
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@ exclude =
1616
ignore =
1717
E126
1818
E203
19+
E701
20+
E704
1921
F405
2022
N801
2123
N802

dev_requirements.txt

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
click==8.0.4
2-
black==22.3.0
2+
black==24.3.0
33
flake8==5.0.4
44
flake8-isort==6.0.0
55
flynt~=0.69.0

redis/_parsers/helpers.py

+16-15
Original file line numberDiff line numberDiff line change
@@ -819,30 +819,31 @@ def string_keys_to_dict(key_string, callback):
819819
lambda r, **kwargs: r,
820820
),
821821
**string_keys_to_dict("XREAD XREADGROUP", parse_xread_resp3),
822-
"ACL LOG": lambda r: [
823-
{str_if_bytes(key): str_if_bytes(value) for key, value in x.items()} for x in r
824-
]
825-
if isinstance(r, list)
826-
else bool_ok(r),
822+
"ACL LOG": lambda r: (
823+
[
824+
{str_if_bytes(key): str_if_bytes(value) for key, value in x.items()}
825+
for x in r
826+
]
827+
if isinstance(r, list)
828+
else bool_ok(r)
829+
),
827830
"COMMAND": parse_command_resp3,
828831
"CONFIG GET": lambda r: {
829-
str_if_bytes(key)
830-
if key is not None
831-
else None: str_if_bytes(value)
832-
if value is not None
833-
else None
832+
str_if_bytes(key) if key is not None else None: (
833+
str_if_bytes(value) if value is not None else None
834+
)
834835
for key, value in r.items()
835836
},
836837
"MEMORY STATS": lambda r: {str_if_bytes(key): value for key, value in r.items()},
837838
"SENTINEL MASTER": parse_sentinel_state_resp3,
838839
"SENTINEL MASTERS": parse_sentinel_masters_resp3,
839840
"SENTINEL SENTINELS": parse_sentinel_slaves_and_sentinels_resp3,
840841
"SENTINEL SLAVES": parse_sentinel_slaves_and_sentinels_resp3,
841-
"STRALGO": lambda r, **options: {
842-
str_if_bytes(key): str_if_bytes(value) for key, value in r.items()
843-
}
844-
if isinstance(r, dict)
845-
else str_if_bytes(r),
842+
"STRALGO": lambda r, **options: (
843+
{str_if_bytes(key): str_if_bytes(value) for key, value in r.items()}
844+
if isinstance(r, dict)
845+
else str_if_bytes(r)
846+
),
846847
"XINFO CONSUMERS": lambda r: [
847848
{str_if_bytes(key): value for key, value in x.items()} for x in r
848849
],

redis/asyncio/client.py

+4-8
Original file line numberDiff line numberDiff line change
@@ -88,13 +88,11 @@
8888

8989

9090
class ResponseCallbackProtocol(Protocol):
91-
def __call__(self, response: Any, **kwargs):
92-
...
91+
def __call__(self, response: Any, **kwargs): ...
9392

9493

9594
class AsyncResponseCallbackProtocol(Protocol):
96-
async def __call__(self, response: Any, **kwargs):
97-
...
95+
async def __call__(self, response: Any, **kwargs): ...
9896

9997

10098
ResponseCallbackT = Union[ResponseCallbackProtocol, AsyncResponseCallbackProtocol]
@@ -1220,13 +1218,11 @@ async def run(
12201218

12211219

12221220
class PubsubWorkerExceptionHandler(Protocol):
1223-
def __call__(self, e: BaseException, pubsub: PubSub):
1224-
...
1221+
def __call__(self, e: BaseException, pubsub: PubSub): ...
12251222

12261223

12271224
class AsyncPubsubWorkerExceptionHandler(Protocol):
1228-
async def __call__(self, e: BaseException, pubsub: PubSub):
1229-
...
1225+
async def __call__(self, e: BaseException, pubsub: PubSub): ...
12301226

12311227

12321228
PSWorkerThreadExcHandlerT = Union[

redis/asyncio/cluster.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -402,10 +402,10 @@ def __init__(
402402
self.command_flags = self.__class__.COMMAND_FLAGS.copy()
403403
self.response_callbacks = kwargs["response_callbacks"]
404404
self.result_callbacks = self.__class__.RESULT_CALLBACKS.copy()
405-
self.result_callbacks[
406-
"CLUSTER SLOTS"
407-
] = lambda cmd, res, **kwargs: parse_cluster_slots(
408-
list(res.values())[0], **kwargs
405+
self.result_callbacks["CLUSTER SLOTS"] = (
406+
lambda cmd, res, **kwargs: parse_cluster_slots(
407+
list(res.values())[0], **kwargs
408+
)
409409
)
410410

411411
self._initialize = True
@@ -1318,9 +1318,9 @@ async def initialize(self) -> None:
13181318
)
13191319
tmp_slots[i].append(target_replica_node)
13201320
# add this node to the nodes cache
1321-
tmp_nodes_cache[
1322-
target_replica_node.name
1323-
] = target_replica_node
1321+
tmp_nodes_cache[target_replica_node.name] = (
1322+
target_replica_node
1323+
)
13241324
else:
13251325
# Validate that 2 nodes want to use the same slot cache
13261326
# setup

redis/asyncio/connection.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -87,13 +87,11 @@ class _Sentinel(enum.Enum):
8787

8888

8989
class ConnectCallbackProtocol(Protocol):
90-
def __call__(self, connection: "AbstractConnection"):
91-
...
90+
def __call__(self, connection: "AbstractConnection"): ...
9291

9392

9493
class AsyncConnectCallbackProtocol(Protocol):
95-
async def __call__(self, connection: "AbstractConnection"):
96-
...
94+
async def __call__(self, connection: "AbstractConnection"): ...
9795

9896

9997
ConnectCallbackT = Union[ConnectCallbackProtocol, AsyncConnectCallbackProtocol]
@@ -319,9 +317,11 @@ async def connect(self):
319317
await self.on_connect()
320318
else:
321319
# Use the passed function redis_connect_func
322-
await self.redis_connect_func(self) if asyncio.iscoroutinefunction(
323-
self.redis_connect_func
324-
) else self.redis_connect_func(self)
320+
(
321+
await self.redis_connect_func(self)
322+
if asyncio.iscoroutinefunction(self.redis_connect_func)
323+
else self.redis_connect_func(self)
324+
)
325325
except RedisError:
326326
# clean up after any error in on_connect
327327
await self.disconnect()

redis/asyncio/sentinel.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -108,9 +108,11 @@ class SentinelConnectionPool(ConnectionPool):
108108
def __init__(self, service_name, sentinel_manager, **kwargs):
109109
kwargs["connection_class"] = kwargs.get(
110110
"connection_class",
111-
SentinelManagedSSLConnection
112-
if kwargs.pop("ssl", False)
113-
else SentinelManagedConnection,
111+
(
112+
SentinelManagedSSLConnection
113+
if kwargs.pop("ssl", False)
114+
else SentinelManagedConnection
115+
),
114116
)
115117
self.is_master = kwargs.pop("is_master", True)
116118
self.check_connection = kwargs.pop("check_connection", False)

redis/cluster.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -1582,9 +1582,9 @@ def initialize(self):
15821582
)
15831583
tmp_slots[i].append(target_replica_node)
15841584
# add this node to the nodes cache
1585-
tmp_nodes_cache[
1586-
target_replica_node.name
1587-
] = target_replica_node
1585+
tmp_nodes_cache[target_replica_node.name] = (
1586+
target_replica_node
1587+
)
15881588
else:
15891589
# Validate that 2 nodes want to use the same slot cache
15901590
# setup

redis/commands/core.py

+1-3
Original file line numberDiff line numberDiff line change
@@ -3399,9 +3399,7 @@ def smembers(self, name: str) -> Union[Awaitable[Set], Set]:
33993399
"""
34003400
return self.execute_command("SMEMBERS", name, keys=[name])
34013401

3402-
def smismember(
3403-
self, name: str, values: List, *args: List
3404-
) -> Union[
3402+
def smismember(self, name: str, values: List, *args: List) -> Union[
34053403
Awaitable[List[Union[Literal[0], Literal[1]]]],
34063404
List[Union[Literal[0], Literal[1]]],
34073405
]:

redis/exceptions.py

+1-2
Original file line numberDiff line numberDiff line change
@@ -217,5 +217,4 @@ class SlotNotCoveredError(RedisClusterException):
217217
pass
218218

219219

220-
class MaxConnectionsError(ConnectionError):
221-
...
220+
class MaxConnectionsError(ConnectionError): ...

redis/sentinel.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -145,9 +145,11 @@ class SentinelConnectionPool(ConnectionPool):
145145
def __init__(self, service_name, sentinel_manager, **kwargs):
146146
kwargs["connection_class"] = kwargs.get(
147147
"connection_class",
148-
SentinelManagedSSLConnection
149-
if kwargs.pop("ssl", False)
150-
else SentinelManagedConnection,
148+
(
149+
SentinelManagedSSLConnection
150+
if kwargs.pop("ssl", False)
151+
else SentinelManagedConnection
152+
),
151153
)
152154
self.is_master = kwargs.pop("is_master", True)
153155
self.check_connection = kwargs.pop("check_connection", False)

redis/typing.py

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

57-
def execute_command(self, *args, **options):
58-
...
57+
def execute_command(self, *args, **options): ...
5958

6059

6160
class ClusterCommandsProtocol(CommandsProtocol, Protocol):
6261
encoder: "Encoder"
6362

64-
def execute_command(self, *args, **options) -> Union[Any, Awaitable]:
65-
...
63+
def execute_command(self, *args, **options) -> Union[Any, Awaitable]: ...

tests/test_asyncio/test_commands.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
"""
22
Tests async overrides of commands from their mixins
33
"""
4+
45
import asyncio
56
import binascii
67
import datetime

0 commit comments

Comments
 (0)