Skip to content

Commit

Permalink
Bump black to fix CI (#6675)
Browse files Browse the repository at this point in the history
* Bump black to fix CI

* Update .pre-commit-config.yaml

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
  • Loading branch information
Dreamsorcerer and pre-commit-ci[bot] committed Apr 4, 2022
1 parent b1051d5 commit 8e92c4c
Show file tree
Hide file tree
Showing 23 changed files with 104 additions and 104 deletions.
2 changes: 1 addition & 1 deletion .pre-commit-config.yaml
Expand Up @@ -34,7 +34,7 @@ repos:
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: '21.12b0'
rev: '22.3.0'
hooks:
- id: black
language_version: python3 # Should be a command that runs python
Expand Down
4 changes: 2 additions & 2 deletions aiohttp/client.py
Expand Up @@ -217,7 +217,7 @@ def __init__(
trust_env: bool = False,
requote_redirect_url: bool = True,
trace_configs: Optional[List[TraceConfig]] = None,
read_bufsize: int = 2 ** 16,
read_bufsize: int = 2**16,
) -> None:
if base_url is None or isinstance(base_url, URL):
self._base_url: Optional[URL] = base_url
Expand Down Expand Up @@ -865,7 +865,7 @@ async def _ws_connect(
transport = conn.transport
assert transport is not None
reader: FlowControlDataQueue[WSMessage] = FlowControlDataQueue(
conn_proto, 2 ** 16, loop=self._loop
conn_proto, 2**16, loop=self._loop
)
conn_proto.set_parser(WebSocketReader(reader, max_msg_size), reader)
writer = WebSocketWriter(
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/client_proto.py
Expand Up @@ -151,7 +151,7 @@ def set_response_params(
read_until_eof: bool = False,
auto_decompress: bool = True,
read_timeout: Optional[float] = None,
read_bufsize: int = 2 ** 16,
read_bufsize: int = 2**16,
timeout_ceil_threshold: float = 5,
) -> None:
self._skip_payload = skip_payload
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/cookiejar.py
Expand Up @@ -55,7 +55,7 @@ class CookieJar(AbstractCookieJar):

MAX_TIME = datetime.datetime.max.replace(tzinfo=datetime.timezone.utc)

MAX_32BIT_TIME = datetime.datetime.utcfromtimestamp(2 ** 31 - 1)
MAX_32BIT_TIME = datetime.datetime.utcfromtimestamp(2**31 - 1)

def __init__(
self,
Expand Down
4 changes: 2 additions & 2 deletions aiohttp/helpers.py
Expand Up @@ -1012,9 +1012,9 @@ def populate_with_cookies(
# https://tools.ietf.org/html/rfc7232#section-2.3
_ETAGC = r"[!#-}\x80-\xff]+"
_ETAGC_RE = re.compile(_ETAGC)
_QUOTED_ETAG = fr'(W/)?"({_ETAGC})"'
_QUOTED_ETAG = rf'(W/)?"({_ETAGC})"'
QUOTED_ETAG_RE = re.compile(_QUOTED_ETAG)
LIST_QUOTED_ETAG_RE = re.compile(fr"({_QUOTED_ETAG})(?:\s*,\s*|$)|(.)")
LIST_QUOTED_ETAG_RE = re.compile(rf"({_QUOTED_ETAG})(?:\s*,\s*|$)|(.)")

ETAG_ANY = "*"

Expand Down
4 changes: 2 additions & 2 deletions aiohttp/http_websocket.py
Expand Up @@ -74,8 +74,8 @@ class WSMsgType(IntEnum):
PACK_LEN2 = Struct("!BBH").pack
PACK_LEN3 = Struct("!BBQ").pack
PACK_CLOSE_CODE = Struct("!H").pack
MSG_SIZE: Final[int] = 2 ** 14
DEFAULT_LIMIT: Final[int] = 2 ** 16
MSG_SIZE: Final[int] = 2**14
DEFAULT_LIMIT: Final[int] = 2**16


_WSMessageBase = collections.namedtuple("_WSMessageBase", ["type", "data", "extra"])
Expand Down
8 changes: 4 additions & 4 deletions aiohttp/multipart.py
Expand Up @@ -551,10 +551,10 @@ def __init__(self, value: BodyPartReader, *args: Any, **kwargs: Any) -> None:

async def write(self, writer: Any) -> None:
field = self._value
chunk = await field.read_chunk(size=2 ** 16)
chunk = await field.read_chunk(size=2**16)
while chunk:
await writer.write(field.decode(chunk))
chunk = await field.read_chunk(size=2 ** 16)
chunk = await field.read_chunk(size=2**16)


class MultipartReader:
Expand Down Expand Up @@ -808,8 +808,8 @@ def __len__(self) -> int:
def __bool__(self) -> bool:
return True

_valid_tchar_regex = re.compile(br"\A[!#$%&'*+\-.^_`|~\w]+\Z")
_invalid_qdtext_char_regex = re.compile(br"[\x00-\x08\x0A-\x1F\x7F]")
_valid_tchar_regex = re.compile(rb"\A[!#$%&'*+\-.^_`|~\w]+\Z")
_invalid_qdtext_char_regex = re.compile(rb"[\x00-\x08\x0A-\x1F\x7F]")

@property
def _boundary_value(self) -> str:
Expand Down
10 changes: 5 additions & 5 deletions aiohttp/payload.py
Expand Up @@ -52,7 +52,7 @@
"AsyncIterablePayload",
)

TOO_LARGE_BYTES_BODY: Final[int] = 2 ** 20 # 1 MB
TOO_LARGE_BYTES_BODY: Final[int] = 2**20 # 1 MB

if TYPE_CHECKING: # pragma: no cover
from typing import List
Expand Down Expand Up @@ -299,10 +299,10 @@ def __init__(
async def write(self, writer: AbstractStreamWriter) -> None:
loop = asyncio.get_event_loop()
try:
chunk = await loop.run_in_executor(None, self._value.read, 2 ** 16)
chunk = await loop.run_in_executor(None, self._value.read, 2**16)
while chunk:
await writer.write(chunk)
chunk = await loop.run_in_executor(None, self._value.read, 2 ** 16)
chunk = await loop.run_in_executor(None, self._value.read, 2**16)
finally:
await loop.run_in_executor(None, self._value.close)

Expand Down Expand Up @@ -348,15 +348,15 @@ def size(self) -> Optional[int]:
async def write(self, writer: AbstractStreamWriter) -> None:
loop = asyncio.get_event_loop()
try:
chunk = await loop.run_in_executor(None, self._value.read, 2 ** 16)
chunk = await loop.run_in_executor(None, self._value.read, 2**16)
while chunk:
data = (
chunk.encode(encoding=self._encoding)
if self._encoding
else chunk.encode()
)
await writer.write(data)
chunk = await loop.run_in_executor(None, self._value.read, 2 ** 16)
chunk = await loop.run_in_executor(None, self._value.read, 2**16)
finally:
await loop.run_in_executor(None, self._value.close)

Expand Down
2 changes: 1 addition & 1 deletion aiohttp/streams.py
Expand Up @@ -131,7 +131,7 @@ def __repr__(self) -> str:
info.append("%d bytes" % self._size)
if self._eof:
info.append("eof")
if self._low_water != 2 ** 16: # default limit
if self._low_water != 2**16: # default limit
info.append("low=%d high=%d" % (self._low_water, self._high_water))
if self._waiter:
info.append("w=%r" % self._waiter)
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/test_utils.py
Expand Up @@ -567,7 +567,7 @@ def make_mocked_request(
transport: Any = sentinel,
payload: Any = sentinel,
sslcontext: Optional[SSLContext] = None,
client_max_size: int = 1024 ** 2,
client_max_size: int = 1024**2,
loop: Any = ...,
) -> Request:
"""Creates mocked web.Request testing purposes.
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_app.py
Expand Up @@ -97,7 +97,7 @@ def __init__(
logger: logging.Logger = web_logger,
middlewares: Iterable[Middleware] = (),
handler_args: Optional[Mapping[str, Any]] = None,
client_max_size: int = 1024 ** 2,
client_max_size: int = 1024**2,
debug: Any = ..., # mypy doesn't support ellipsis
) -> None:

Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_protocol.py
Expand Up @@ -194,7 +194,7 @@ def __init__(
max_headers: int = 32768,
max_field_size: int = 8190,
lingering_time: float = 10.0,
read_bufsize: int = 2 ** 16,
read_bufsize: int = 2**16,
auto_decompress: bool = True,
timeout_ceil_threshold: float = 5,
):
Expand Down
8 changes: 4 additions & 4 deletions aiohttp/web_request.py
Expand Up @@ -83,7 +83,7 @@ class FileField:
_TCHAR: Final[str] = string.digits + string.ascii_letters + r"!#$%&'*+.^_`|~-"
# '-' at the end to prevent interpretation as range in a char class

_TOKEN: Final[str] = fr"[{_TCHAR}]+"
_TOKEN: Final[str] = rf"[{_TCHAR}]+"

_QDTEXT: Final[str] = r"[{}]".format(
r"".join(chr(c) for c in (0x09, 0x20, 0x21) + tuple(range(0x23, 0x7F)))
Expand Down Expand Up @@ -154,7 +154,7 @@ def __init__(
task: "asyncio.Task[None]",
loop: asyncio.AbstractEventLoop,
*,
client_max_size: int = 1024 ** 2,
client_max_size: int = 1024**2,
state: Optional[Dict[str, Any]] = None,
scheme: Optional[str] = None,
host: Optional[str] = None,
Expand Down Expand Up @@ -725,7 +725,7 @@ async def post(self) -> "MultiDictProxy[Union[str, bytes, FileField]]":
if field.filename:
# store file in temp file
tmp = tempfile.TemporaryFile()
chunk = await field.read_chunk(size=2 ** 16)
chunk = await field.read_chunk(size=2**16)
while chunk:
chunk = field.decode(chunk)
tmp.write(chunk)
Expand All @@ -735,7 +735,7 @@ async def post(self) -> "MultiDictProxy[Union[str, bytes, FileField]]":
raise HTTPRequestEntityTooLarge(
max_size=max_size, actual_size=size
)
chunk = await field.read_chunk(size=2 ** 16)
chunk = await field.read_chunk(size=2**16)
tmp.seek(0)

if field_ct is None:
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_ws.py
Expand Up @@ -286,7 +286,7 @@ def _post_start(

loop = self._loop
assert loop is not None
self._reader = FlowControlDataQueue(request._protocol, 2 ** 16, loop=loop)
self._reader = FlowControlDataQueue(request._protocol, 2**16, loop=loop)
request.protocol.set_parser(
WebSocketReader(self._reader, self._max_msg_size, compress=self._compress)
)
Expand Down
2 changes: 1 addition & 1 deletion tests/conftest.py
Expand Up @@ -95,7 +95,7 @@ def tls_certificate_fingerprint_sha256(tls_certificate_pem_bytes: Any) -> str:

@pytest.fixture
def pipe_name() -> str:
name = fr"\\.\pipe\{uuid4().hex}"
name = rf"\\.\pipe\{uuid4().hex}"
return name


Expand Down
2 changes: 1 addition & 1 deletion tests/test_client_functional.py
Expand Up @@ -1294,7 +1294,7 @@ async def handler(request):


async def test_POST_bytes_too_large(aiohttp_client: Any) -> None:
body = b"0" * (2 ** 20 + 1)
body = b"0" * (2**20 + 1)

async def handler(request):
data = await request.content.read()
Expand Down

0 comments on commit 8e92c4c

Please sign in to comment.