Skip to content

update black to 22.3.0 #2171

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
May 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions benchmarks/cluster_async.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,8 +206,8 @@ async def main(loop, gather=None):
host=host,
port=port,
password=password,
max_connections=2 ** 31,
max_connections_per_node=2 ** 31,
max_connections=2**31,
max_connections_per_node=2**31,
readonly=False,
reinitialize_steps=count,
skip_full_coverage_check=True,
Expand All @@ -224,7 +224,7 @@ async def main(loop, gather=None):
password=password,
state_reload_interval=count,
idle_connection_timeout=count,
pool_maxsize=2 ** 31,
pool_maxsize=2**31,
)
print(f"{loop} {gather} {await warmup(aiorc)} aioredis-cluster")
print(await run(aiorc, gather=gather))
Expand All @@ -238,7 +238,7 @@ async def main(loop, gather=None):
reinitialize_steps=count,
read_from_replicas=False,
decode_responses=False,
max_connections=2 ** 31,
max_connections=2**31,
) as rca:
print(f"{loop} {gather} {await warmup(rca)} redispy")
print(await run(rca, gather=gather))
Expand Down
2 changes: 1 addition & 1 deletion dev_requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
click==8.0.4
black==21.11b1
black==22.3.0
flake8==4.0.1
flynt~=0.69.0
isort==5.10.1
Expand Down
2 changes: 1 addition & 1 deletion redis/asyncio/cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -746,7 +746,7 @@ def __init__(
host: str,
port: int,
server_type: Optional[str] = None,
max_connections: int = 2 ** 31,
max_connections: int = 2**31,
connection_class: Type[Connection] = Connection,
response_callbacks: Dict[str, Any] = RedisCluster.RESPONSE_CALLBACKS,
**connection_kwargs: Any,
Expand Down
2 changes: 1 addition & 1 deletion redis/asyncio/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -1390,7 +1390,7 @@ def __init__(
max_connections: Optional[int] = None,
**connection_kwargs,
):
max_connections = max_connections or 2 ** 31
max_connections = max_connections or 2**31
if not isinstance(max_connections, int) or max_connections < 0:
raise ValueError('"max_connections" must be a positive integer')

Expand Down
6 changes: 3 additions & 3 deletions redis/backoff.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def __init__(self, cap, base):
self._base = base

def compute(self, failures):
return min(self._cap, self._base * 2 ** failures)
return min(self._cap, self._base * 2**failures)


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

def compute(self, failures):
return random.uniform(0, min(self._cap, self._base * 2 ** failures))
return random.uniform(0, min(self._cap, self._base * 2**failures))


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

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


Expand Down
131 changes: 24 additions & 107 deletions redis/commands/core.py
Original file line number Diff line number Diff line change
Expand Up @@ -502,10 +502,7 @@ def client_info(self, **kwargs) -> ResponseT:
return self.execute_command("CLIENT INFO", **kwargs)

def client_list(
self,
_type: Union[str, None] = None,
client_id: List[EncodableT] = [],
**kwargs,
self, _type: Union[str, None] = None, client_id: List[EncodableT] = [], **kwargs
) -> ResponseT:
"""
Returns a list of currently connected clients.
Expand Down Expand Up @@ -548,9 +545,7 @@ def client_getredir(self, **kwargs) -> ResponseT:
return self.execute_command("CLIENT GETREDIR", **kwargs)

def client_reply(
self,
reply: Union[Literal["ON"], Literal["OFF"], Literal["SKIP"]],
**kwargs,
self, reply: Union[Literal["ON"], Literal["OFF"], Literal["SKIP"]], **kwargs
) -> ResponseT:
"""
Enable and disable redis server replies.
Expand Down Expand Up @@ -696,10 +691,7 @@ def client_setname(self, name: str, **kwargs) -> ResponseT:
return self.execute_command("CLIENT SETNAME", name, **kwargs)

def client_unblock(
self,
client_id: int,
error: bool = False,
**kwargs,
self, client_id: int, error: bool = False, **kwargs
) -> ResponseT:
"""
Unblocks a connection by its client id.
Expand Down Expand Up @@ -1475,12 +1467,7 @@ def bitfield(
"""
return BitFieldOperation(self, key, default_overflow=default_overflow)

def bitop(
self,
operation: str,
dest: KeyT,
*keys: KeyT,
) -> ResponseT:
def bitop(self, operation: str, dest: KeyT, *keys: KeyT) -> ResponseT:
"""
Perform a bitwise operation using ``operation`` between ``keys`` and
store the result in ``dest``.
Expand Down Expand Up @@ -1826,11 +1813,7 @@ def keys(self, pattern: PatternT = "*", **kwargs) -> ResponseT:
return self.execute_command("KEYS", pattern, **kwargs)

def lmove(
self,
first_list: str,
second_list: str,
src: str = "LEFT",
dest: str = "RIGHT",
self, first_list: str, second_list: str, src: str = "LEFT", dest: str = "RIGHT"
) -> ResponseT:
"""
Atomically returns and removes the first/last element of a list,
Expand Down Expand Up @@ -1996,12 +1979,7 @@ def pexpiretime(self, key: str) -> int:
"""
return self.execute_command("PEXPIRETIME", key)

def psetex(
self,
name: KeyT,
time_ms: ExpiryT,
value: EncodableT,
):
def psetex(self, name: KeyT, time_ms: ExpiryT, value: EncodableT):
"""
Set the value of key ``name`` to ``value`` that expires in ``time_ms``
milliseconds. ``time_ms`` can be represented by an integer or a Python
Expand All @@ -2022,10 +2000,7 @@ def pttl(self, name: KeyT) -> ResponseT:
return self.execute_command("PTTL", name)

def hrandfield(
self,
key: str,
count: int = None,
withvalues: bool = False,
self, key: str, count: int = None, withvalues: bool = False
) -> ResponseT:
"""
Return a random field from the hash value stored at key.
Expand Down Expand Up @@ -2240,12 +2215,7 @@ def setnx(self, name: KeyT, value: EncodableT) -> ResponseT:
"""
return self.execute_command("SETNX", name, value)

def setrange(
self,
name: KeyT,
offset: int,
value: EncodableT,
) -> ResponseT:
def setrange(self, name: KeyT, offset: int, value: EncodableT) -> ResponseT:
"""
Overwrite bytes in the value of ``name`` starting at ``offset`` with
``value``. If ``offset`` plus the length of ``value`` exceeds the
Expand Down Expand Up @@ -3259,10 +3229,7 @@ def smembers(self, name: str) -> Union[Awaitable[list], list]:
return self.execute_command("SMEMBERS", name)

def smismember(
self,
name: str,
values: List,
*args: List,
self, name: str, values: List, *args: List
) -> Union[Awaitable[List[bool]], List[bool]]:
"""
Return whether each value in ``values`` is a member of the set ``name``
Expand Down Expand Up @@ -3291,9 +3258,7 @@ def spop(self, name: str, count: Optional[int] = None) -> Union[str, List, None]
return self.execute_command("SPOP", name, *args)

def srandmember(
self,
name: str,
number: Optional[int] = None,
self, name: str, number: Optional[int] = None
) -> Union[str, List, None]:
"""
If ``number`` is None, returns a random member of set ``name``.
Expand Down Expand Up @@ -3346,12 +3311,7 @@ class StreamCommands(CommandsProtocol):
see: https://redis.io/topics/streams-intro
"""

def xack(
self,
name: KeyT,
groupname: GroupT,
*ids: StreamIdT,
) -> ResponseT:
def xack(self, name: KeyT, groupname: GroupT, *ids: StreamIdT) -> ResponseT:
"""
Acknowledges the successful processing of one or more messages.
name: name of the stream.
Expand Down Expand Up @@ -3576,10 +3536,7 @@ def xgroup_create(
return self.execute_command(*pieces)

def xgroup_delconsumer(
self,
name: KeyT,
groupname: GroupT,
consumername: ConsumerT,
self, name: KeyT, groupname: GroupT, consumername: ConsumerT
) -> ResponseT:
"""
Remove a specific consumer from a consumer group.
Expand All @@ -3604,10 +3561,7 @@ def xgroup_destroy(self, name: KeyT, groupname: GroupT) -> ResponseT:
return self.execute_command("XGROUP DESTROY", name, groupname)

def xgroup_createconsumer(
self,
name: KeyT,
groupname: GroupT,
consumername: ConsumerT,
self, name: KeyT, groupname: GroupT, consumername: ConsumerT
) -> ResponseT:
"""
Consumers in a consumer group are auto-created every time a new
Expand Down Expand Up @@ -4052,12 +4006,7 @@ def zdiffstore(self, dest: KeyT, keys: KeysT) -> ResponseT:
pieces = [len(keys), *keys]
return self.execute_command("ZDIFFSTORE", dest, *pieces)

def zincrby(
self,
name: KeyT,
amount: float,
value: EncodableT,
) -> ResponseT:
def zincrby(self, name: KeyT, amount: float, value: EncodableT) -> ResponseT:
"""
Increment the score of ``value`` in sorted set ``name`` by ``amount``

Expand All @@ -4066,10 +4015,7 @@ def zincrby(
return self.execute_command("ZINCRBY", name, amount, value)

def zinter(
self,
keys: KeysT,
aggregate: Union[str, None] = None,
withscores: bool = False,
self, keys: KeysT, aggregate: Union[str, None] = None, withscores: bool = False
) -> ResponseT:
"""
Return the intersect of multiple sorted sets specified by ``keys``.
Expand Down Expand Up @@ -4127,11 +4073,7 @@ def zlexcount(self, name, min, max):
"""
return self.execute_command("ZLEXCOUNT", name, min, max)

def zpopmax(
self,
name: KeyT,
count: Union[int, None] = None,
) -> ResponseT:
def zpopmax(self, name: KeyT, count: Union[int, None] = None) -> ResponseT:
"""
Remove and return up to ``count`` members with the highest scores
from the sorted set ``name``.
Expand All @@ -4142,11 +4084,7 @@ def zpopmax(
options = {"withscores": True}
return self.execute_command("ZPOPMAX", name, *args, **options)

def zpopmin(
self,
name: KeyT,
count: Union[int, None] = None,
) -> ResponseT:
def zpopmin(self, name: KeyT, count: Union[int, None] = None) -> ResponseT:
"""
Remove and return up to ``count`` members with the lowest scores
from the sorted set ``name``.
Expand All @@ -4158,10 +4096,7 @@ def zpopmin(
return self.execute_command("ZPOPMIN", name, *args, **options)

def zrandmember(
self,
key: KeyT,
count: int = None,
withscores: bool = False,
self, key: KeyT, count: int = None, withscores: bool = False
) -> ResponseT:
"""
Return a random element from the sorted set value stored at key.
Expand Down Expand Up @@ -4675,11 +4610,7 @@ def zunionstore(
"""
return self._zaggregate("ZUNIONSTORE", dest, keys, aggregate)

def zmscore(
self,
key: KeyT,
members: List[str],
) -> ResponseT:
def zmscore(self, key: KeyT, members: List[str]) -> ResponseT:
"""
Returns the scores associated with the specified members
in the sorted set stored at key.
Expand Down Expand Up @@ -5264,11 +5195,7 @@ def geoadd(
return self.execute_command("GEOADD", *pieces)

def geodist(
self,
name: KeyT,
place1: FieldT,
place2: FieldT,
unit: Union[str, None] = None,
self, name: KeyT, place1: FieldT, place2: FieldT, unit: Union[str, None] = None
) -> ResponseT:
"""
Return the distance between ``place1`` and ``place2`` members of the
Expand Down Expand Up @@ -5407,20 +5334,15 @@ def georadiusbymember(
)

def _georadiusgeneric(
self,
command: str,
*args: EncodableT,
**kwargs: Union[EncodableT, None],
self, command: str, *args: EncodableT, **kwargs: Union[EncodableT, None]
) -> ResponseT:
pieces = list(args)
if kwargs["unit"] and kwargs["unit"] not in ("m", "km", "mi", "ft"):
raise DataError("GEORADIUS invalid unit")
elif kwargs["unit"]:
pieces.append(kwargs["unit"])
else:
pieces.append(
"m",
)
pieces.append("m")

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

def _geosearchgeneric(
self,
command: str,
*args: EncodableT,
**kwargs: Union[EncodableT, None],
self, command: str, *args: EncodableT, **kwargs: Union[EncodableT, None]
) -> ResponseT:
pieces = list(args)

Expand Down Expand Up @@ -5814,9 +5733,7 @@ class FunctionCommands:
"""

def function_load(
self,
code: str,
replace: Optional[bool] = False,
self, code: str, replace: Optional[bool] = False
) -> Union[Awaitable[str], str]:
"""
Load a library to Redis.
Expand Down
6 changes: 1 addition & 5 deletions redis/commands/json/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,7 @@ class JSON(JSONCommands):
"""

def __init__(
self,
client,
version=None,
decoder=JSONDecoder(),
encoder=JSONEncoder(),
self, client, version=None, decoder=JSONDecoder(), encoder=JSONEncoder()
):
"""
Create a client for talking to json.
Expand Down
Loading