Skip to content

Commit c54dfa4

Browse files
update black to 22.3.0 (#2171)
1 parent f704281 commit c54dfa4

29 files changed

+156
-525
lines changed

benchmarks/cluster_async.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -206,8 +206,8 @@ async def main(loop, gather=None):
206206
host=host,
207207
port=port,
208208
password=password,
209-
max_connections=2 ** 31,
210-
max_connections_per_node=2 ** 31,
209+
max_connections=2**31,
210+
max_connections_per_node=2**31,
211211
readonly=False,
212212
reinitialize_steps=count,
213213
skip_full_coverage_check=True,
@@ -224,7 +224,7 @@ async def main(loop, gather=None):
224224
password=password,
225225
state_reload_interval=count,
226226
idle_connection_timeout=count,
227-
pool_maxsize=2 ** 31,
227+
pool_maxsize=2**31,
228228
)
229229
print(f"{loop} {gather} {await warmup(aiorc)} aioredis-cluster")
230230
print(await run(aiorc, gather=gather))
@@ -238,7 +238,7 @@ async def main(loop, gather=None):
238238
reinitialize_steps=count,
239239
read_from_replicas=False,
240240
decode_responses=False,
241-
max_connections=2 ** 31,
241+
max_connections=2**31,
242242
) as rca:
243243
print(f"{loop} {gather} {await warmup(rca)} redispy")
244244
print(await run(rca, gather=gather))

dev_requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
click==8.0.4
2-
black==21.11b1
2+
black==22.3.0
33
flake8==4.0.1
44
flynt~=0.69.0
55
isort==5.10.1

redis/asyncio/cluster.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -746,7 +746,7 @@ def __init__(
746746
host: str,
747747
port: int,
748748
server_type: Optional[str] = None,
749-
max_connections: int = 2 ** 31,
749+
max_connections: int = 2**31,
750750
connection_class: Type[Connection] = Connection,
751751
response_callbacks: Dict[str, Any] = RedisCluster.RESPONSE_CALLBACKS,
752752
**connection_kwargs: Any,

redis/asyncio/connection.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1390,7 +1390,7 @@ def __init__(
13901390
max_connections: Optional[int] = None,
13911391
**connection_kwargs,
13921392
):
1393-
max_connections = max_connections or 2 ** 31
1393+
max_connections = max_connections or 2**31
13941394
if not isinstance(max_connections, int) or max_connections < 0:
13951395
raise ValueError('"max_connections" must be a positive integer')
13961396

redis/backoff.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def __init__(self, cap, base):
4949
self._base = base
5050

5151
def compute(self, failures):
52-
return min(self._cap, self._base * 2 ** failures)
52+
return min(self._cap, self._base * 2**failures)
5353

5454

5555
class FullJitterBackoff(AbstractBackoff):
@@ -64,7 +64,7 @@ def __init__(self, cap, base):
6464
self._base = base
6565

6666
def compute(self, failures):
67-
return random.uniform(0, min(self._cap, self._base * 2 ** failures))
67+
return random.uniform(0, min(self._cap, self._base * 2**failures))
6868

6969

7070
class EqualJitterBackoff(AbstractBackoff):
@@ -79,7 +79,7 @@ def __init__(self, cap, base):
7979
self._base = base
8080

8181
def compute(self, failures):
82-
temp = min(self._cap, self._base * 2 ** failures) / 2
82+
temp = min(self._cap, self._base * 2**failures) / 2
8383
return temp + random.uniform(0, temp)
8484

8585

redis/commands/core.py

Lines changed: 24 additions & 107 deletions
Original file line numberDiff line numberDiff line change
@@ -502,10 +502,7 @@ def client_info(self, **kwargs) -> ResponseT:
502502
return self.execute_command("CLIENT INFO", **kwargs)
503503

504504
def client_list(
505-
self,
506-
_type: Union[str, None] = None,
507-
client_id: List[EncodableT] = [],
508-
**kwargs,
505+
self, _type: Union[str, None] = None, client_id: List[EncodableT] = [], **kwargs
509506
) -> ResponseT:
510507
"""
511508
Returns a list of currently connected clients.
@@ -548,9 +545,7 @@ def client_getredir(self, **kwargs) -> ResponseT:
548545
return self.execute_command("CLIENT GETREDIR", **kwargs)
549546

550547
def client_reply(
551-
self,
552-
reply: Union[Literal["ON"], Literal["OFF"], Literal["SKIP"]],
553-
**kwargs,
548+
self, reply: Union[Literal["ON"], Literal["OFF"], Literal["SKIP"]], **kwargs
554549
) -> ResponseT:
555550
"""
556551
Enable and disable redis server replies.
@@ -696,10 +691,7 @@ def client_setname(self, name: str, **kwargs) -> ResponseT:
696691
return self.execute_command("CLIENT SETNAME", name, **kwargs)
697692

698693
def client_unblock(
699-
self,
700-
client_id: int,
701-
error: bool = False,
702-
**kwargs,
694+
self, client_id: int, error: bool = False, **kwargs
703695
) -> ResponseT:
704696
"""
705697
Unblocks a connection by its client id.
@@ -1475,12 +1467,7 @@ def bitfield(
14751467
"""
14761468
return BitFieldOperation(self, key, default_overflow=default_overflow)
14771469

1478-
def bitop(
1479-
self,
1480-
operation: str,
1481-
dest: KeyT,
1482-
*keys: KeyT,
1483-
) -> ResponseT:
1470+
def bitop(self, operation: str, dest: KeyT, *keys: KeyT) -> ResponseT:
14841471
"""
14851472
Perform a bitwise operation using ``operation`` between ``keys`` and
14861473
store the result in ``dest``.
@@ -1826,11 +1813,7 @@ def keys(self, pattern: PatternT = "*", **kwargs) -> ResponseT:
18261813
return self.execute_command("KEYS", pattern, **kwargs)
18271814

18281815
def lmove(
1829-
self,
1830-
first_list: str,
1831-
second_list: str,
1832-
src: str = "LEFT",
1833-
dest: str = "RIGHT",
1816+
self, first_list: str, second_list: str, src: str = "LEFT", dest: str = "RIGHT"
18341817
) -> ResponseT:
18351818
"""
18361819
Atomically returns and removes the first/last element of a list,
@@ -1996,12 +1979,7 @@ def pexpiretime(self, key: str) -> int:
19961979
"""
19971980
return self.execute_command("PEXPIRETIME", key)
19981981

1999-
def psetex(
2000-
self,
2001-
name: KeyT,
2002-
time_ms: ExpiryT,
2003-
value: EncodableT,
2004-
):
1982+
def psetex(self, name: KeyT, time_ms: ExpiryT, value: EncodableT):
20051983
"""
20061984
Set the value of key ``name`` to ``value`` that expires in ``time_ms``
20071985
milliseconds. ``time_ms`` can be represented by an integer or a Python
@@ -2022,10 +2000,7 @@ def pttl(self, name: KeyT) -> ResponseT:
20222000
return self.execute_command("PTTL", name)
20232001

20242002
def hrandfield(
2025-
self,
2026-
key: str,
2027-
count: int = None,
2028-
withvalues: bool = False,
2003+
self, key: str, count: int = None, withvalues: bool = False
20292004
) -> ResponseT:
20302005
"""
20312006
Return a random field from the hash value stored at key.
@@ -2240,12 +2215,7 @@ def setnx(self, name: KeyT, value: EncodableT) -> ResponseT:
22402215
"""
22412216
return self.execute_command("SETNX", name, value)
22422217

2243-
def setrange(
2244-
self,
2245-
name: KeyT,
2246-
offset: int,
2247-
value: EncodableT,
2248-
) -> ResponseT:
2218+
def setrange(self, name: KeyT, offset: int, value: EncodableT) -> ResponseT:
22492219
"""
22502220
Overwrite bytes in the value of ``name`` starting at ``offset`` with
22512221
``value``. If ``offset`` plus the length of ``value`` exceeds the
@@ -3259,10 +3229,7 @@ def smembers(self, name: str) -> Union[Awaitable[list], list]:
32593229
return self.execute_command("SMEMBERS", name)
32603230

32613231
def smismember(
3262-
self,
3263-
name: str,
3264-
values: List,
3265-
*args: List,
3232+
self, name: str, values: List, *args: List
32663233
) -> Union[Awaitable[List[bool]], List[bool]]:
32673234
"""
32683235
Return whether each value in ``values`` is a member of the set ``name``
@@ -3291,9 +3258,7 @@ def spop(self, name: str, count: Optional[int] = None) -> Union[str, List, None]
32913258
return self.execute_command("SPOP", name, *args)
32923259

32933260
def srandmember(
3294-
self,
3295-
name: str,
3296-
number: Optional[int] = None,
3261+
self, name: str, number: Optional[int] = None
32973262
) -> Union[str, List, None]:
32983263
"""
32993264
If ``number`` is None, returns a random member of set ``name``.
@@ -3346,12 +3311,7 @@ class StreamCommands(CommandsProtocol):
33463311
see: https://redis.io/topics/streams-intro
33473312
"""
33483313

3349-
def xack(
3350-
self,
3351-
name: KeyT,
3352-
groupname: GroupT,
3353-
*ids: StreamIdT,
3354-
) -> ResponseT:
3314+
def xack(self, name: KeyT, groupname: GroupT, *ids: StreamIdT) -> ResponseT:
33553315
"""
33563316
Acknowledges the successful processing of one or more messages.
33573317
name: name of the stream.
@@ -3576,10 +3536,7 @@ def xgroup_create(
35763536
return self.execute_command(*pieces)
35773537

35783538
def xgroup_delconsumer(
3579-
self,
3580-
name: KeyT,
3581-
groupname: GroupT,
3582-
consumername: ConsumerT,
3539+
self, name: KeyT, groupname: GroupT, consumername: ConsumerT
35833540
) -> ResponseT:
35843541
"""
35853542
Remove a specific consumer from a consumer group.
@@ -3604,10 +3561,7 @@ def xgroup_destroy(self, name: KeyT, groupname: GroupT) -> ResponseT:
36043561
return self.execute_command("XGROUP DESTROY", name, groupname)
36053562

36063563
def xgroup_createconsumer(
3607-
self,
3608-
name: KeyT,
3609-
groupname: GroupT,
3610-
consumername: ConsumerT,
3564+
self, name: KeyT, groupname: GroupT, consumername: ConsumerT
36113565
) -> ResponseT:
36123566
"""
36133567
Consumers in a consumer group are auto-created every time a new
@@ -4052,12 +4006,7 @@ def zdiffstore(self, dest: KeyT, keys: KeysT) -> ResponseT:
40524006
pieces = [len(keys), *keys]
40534007
return self.execute_command("ZDIFFSTORE", dest, *pieces)
40544008

4055-
def zincrby(
4056-
self,
4057-
name: KeyT,
4058-
amount: float,
4059-
value: EncodableT,
4060-
) -> ResponseT:
4009+
def zincrby(self, name: KeyT, amount: float, value: EncodableT) -> ResponseT:
40614010
"""
40624011
Increment the score of ``value`` in sorted set ``name`` by ``amount``
40634012
@@ -4066,10 +4015,7 @@ def zincrby(
40664015
return self.execute_command("ZINCRBY", name, amount, value)
40674016

40684017
def zinter(
4069-
self,
4070-
keys: KeysT,
4071-
aggregate: Union[str, None] = None,
4072-
withscores: bool = False,
4018+
self, keys: KeysT, aggregate: Union[str, None] = None, withscores: bool = False
40734019
) -> ResponseT:
40744020
"""
40754021
Return the intersect of multiple sorted sets specified by ``keys``.
@@ -4127,11 +4073,7 @@ def zlexcount(self, name, min, max):
41274073
"""
41284074
return self.execute_command("ZLEXCOUNT", name, min, max)
41294075

4130-
def zpopmax(
4131-
self,
4132-
name: KeyT,
4133-
count: Union[int, None] = None,
4134-
) -> ResponseT:
4076+
def zpopmax(self, name: KeyT, count: Union[int, None] = None) -> ResponseT:
41354077
"""
41364078
Remove and return up to ``count`` members with the highest scores
41374079
from the sorted set ``name``.
@@ -4142,11 +4084,7 @@ def zpopmax(
41424084
options = {"withscores": True}
41434085
return self.execute_command("ZPOPMAX", name, *args, **options)
41444086

4145-
def zpopmin(
4146-
self,
4147-
name: KeyT,
4148-
count: Union[int, None] = None,
4149-
) -> ResponseT:
4087+
def zpopmin(self, name: KeyT, count: Union[int, None] = None) -> ResponseT:
41504088
"""
41514089
Remove and return up to ``count`` members with the lowest scores
41524090
from the sorted set ``name``.
@@ -4158,10 +4096,7 @@ def zpopmin(
41584096
return self.execute_command("ZPOPMIN", name, *args, **options)
41594097

41604098
def zrandmember(
4161-
self,
4162-
key: KeyT,
4163-
count: int = None,
4164-
withscores: bool = False,
4099+
self, key: KeyT, count: int = None, withscores: bool = False
41654100
) -> ResponseT:
41664101
"""
41674102
Return a random element from the sorted set value stored at key.
@@ -4675,11 +4610,7 @@ def zunionstore(
46754610
"""
46764611
return self._zaggregate("ZUNIONSTORE", dest, keys, aggregate)
46774612

4678-
def zmscore(
4679-
self,
4680-
key: KeyT,
4681-
members: List[str],
4682-
) -> ResponseT:
4613+
def zmscore(self, key: KeyT, members: List[str]) -> ResponseT:
46834614
"""
46844615
Returns the scores associated with the specified members
46854616
in the sorted set stored at key.
@@ -5264,11 +5195,7 @@ def geoadd(
52645195
return self.execute_command("GEOADD", *pieces)
52655196

52665197
def geodist(
5267-
self,
5268-
name: KeyT,
5269-
place1: FieldT,
5270-
place2: FieldT,
5271-
unit: Union[str, None] = None,
5198+
self, name: KeyT, place1: FieldT, place2: FieldT, unit: Union[str, None] = None
52725199
) -> ResponseT:
52735200
"""
52745201
Return the distance between ``place1`` and ``place2`` members of the
@@ -5407,20 +5334,15 @@ def georadiusbymember(
54075334
)
54085335

54095336
def _georadiusgeneric(
5410-
self,
5411-
command: str,
5412-
*args: EncodableT,
5413-
**kwargs: Union[EncodableT, None],
5337+
self, command: str, *args: EncodableT, **kwargs: Union[EncodableT, None]
54145338
) -> ResponseT:
54155339
pieces = list(args)
54165340
if kwargs["unit"] and kwargs["unit"] not in ("m", "km", "mi", "ft"):
54175341
raise DataError("GEORADIUS invalid unit")
54185342
elif kwargs["unit"]:
54195343
pieces.append(kwargs["unit"])
54205344
else:
5421-
pieces.append(
5422-
"m",
5423-
)
5345+
pieces.append("m")
54245346

54255347
if kwargs["any"] and kwargs["count"] is None:
54265348
raise DataError("``any`` can't be provided without ``count``")
@@ -5577,10 +5499,7 @@ def geosearchstore(
55775499
)
55785500

55795501
def _geosearchgeneric(
5580-
self,
5581-
command: str,
5582-
*args: EncodableT,
5583-
**kwargs: Union[EncodableT, None],
5502+
self, command: str, *args: EncodableT, **kwargs: Union[EncodableT, None]
55845503
) -> ResponseT:
55855504
pieces = list(args)
55865505

@@ -5814,9 +5733,7 @@ class FunctionCommands:
58145733
"""
58155734

58165735
def function_load(
5817-
self,
5818-
code: str,
5819-
replace: Optional[bool] = False,
5736+
self, code: str, replace: Optional[bool] = False
58205737
) -> Union[Awaitable[str], str]:
58215738
"""
58225739
Load a library to Redis.

redis/commands/json/__init__.py

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,7 @@ class JSON(JSONCommands):
1919
"""
2020

2121
def __init__(
22-
self,
23-
client,
24-
version=None,
25-
decoder=JSONDecoder(),
26-
encoder=JSONEncoder(),
22+
self, client, version=None, decoder=JSONDecoder(), encoder=JSONEncoder()
2723
):
2824
"""
2925
Create a client for talking to json.

0 commit comments

Comments
 (0)