Skip to content
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

[pre-commit.ci] pre-commit autoupdate #5985

Merged
merged 7 commits into from
Sep 30, 2021
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
20 changes: 10 additions & 10 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,24 +7,24 @@ repos:
entry: ./tools/check_changes.py
pass_filenames: false
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v3.3.0'
rev: 'v4.0.1'
hooks:
- id: check-merge-conflict
- repo: https://github.com/asottile/yesqa
rev: v1.2.2
rev: v1.2.3
hooks:
- id: yesqa
- repo: https://github.com/pre-commit/mirrors-isort
rev: 'v5.6.4'
- repo: https://github.com/PyCQA/isort
rev: '5.9.3'
hooks:
- id: isort
- repo: https://github.com/psf/black
rev: '20.8b1'
rev: '21.9b0'
hooks:
- id: black
language_version: python3 # Should be a command that runs python3.6+
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: 'v3.3.0'
rev: 'v4.0.1'
hooks:
- id: end-of-file-fixer
exclude: >-
Expand Down Expand Up @@ -60,18 +60,18 @@ repos:
- id: detect-private-key
exclude: ^examples/
- repo: https://github.com/asottile/pyupgrade
rev: 'v2.7.4'
rev: 'v2.28.0'
hooks:
- id: pyupgrade
args: ['--py36-plus']
- repo: https://gitlab.com/pycqa/flake8
rev: '3.8.4'
- repo: https://github.com/PyCQA/flake8
rev: '3.9.2'
hooks:
- id: flake8
exclude: "^docs/"

- repo: git://github.com/Lucas-C/pre-commit-hooks-markup
rev: v1.0.0
rev: v1.0.1
hooks:
- id: rst-linter
files: >-
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ def __init__(
real_headers = CIMultiDict()
self._default_headers = real_headers # type: CIMultiDict[str]
if skip_auto_headers is not None:
self._skip_auto_headers = frozenset([istr(i) for i in skip_auto_headers])
self._skip_auto_headers = frozenset(istr(i) for i in skip_auto_headers)
else:
self._skip_auto_headers = frozenset()

Expand Down
2 changes: 1 addition & 1 deletion aiohttp/client_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def __repr__(self) -> str:
args += f", message={self.message!r}"
if self.headers is not None:
args += f", headers={self.headers!r}"
return "{}({})".format(type(self).__name__, args)
return f"{type(self).__name__}({args})"


class ContentTypeError(ClientResponseError):
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,7 @@ def closed(self) -> bool:


class _TransportPlaceholder:
""" placeholder for BaseConnector.connect function """
"""placeholder for BaseConnector.connect function"""

def __init__(self, loop: asyncio.AbstractEventLoop) -> None:
fut = loop.create_future()
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/cookiejar.py
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ def _parse_date(cls, date_str: str) -> Optional[datetime.datetime]:
time_match = cls.DATE_HMS_TIME_RE.match(token)
if time_match:
found_time = True
hour, minute, second = [int(s) for s in time_match.groups()]
hour, minute, second = (int(s) for s in time_match.groups())
continue

if not found_day:
Expand Down
6 changes: 3 additions & 3 deletions aiohttp/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -499,7 +499,7 @@ def _is_ip_address(
elif isinstance(host, (bytes, bytearray, memoryview)):
return bool(regexb.match(host))
else:
raise TypeError("{} [{}] is not a str or bytes".format(host, type(host)))
raise TypeError(f"{host} [{type(host)}] is not a str or bytes")


is_ipv4_address = functools.partial(_is_ip_address, _ipv4_regex, _ipv4_regexb)
Expand Down Expand Up @@ -593,7 +593,7 @@ def call_later(


class TimeoutHandle:
""" Timeout handle """
"""Timeout handle"""

def __init__(
self, loop: asyncio.AbstractEventLoop, timeout: Optional[float]
Expand Down Expand Up @@ -656,7 +656,7 @@ def __exit__(


class TimerContext(BaseTimerContext):
""" Low resolution timeout context manager """
"""Low resolution timeout context manager"""

def __init__(self, loop: asyncio.AbstractEventLoop) -> None:
self._loop = loop
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/locks.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,6 @@ async def wait(self) -> Any:
return val

def cancel(self) -> None:
""" Cancel all waiters """
"""Cancel all waiters"""
for waiter in self._waiters:
waiter.cancel()
2 changes: 1 addition & 1 deletion aiohttp/multipart.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ def unescape(text: str, *, chars: str = "".join(map(re.escape, CHAR))) -> str:
elif parts:
# maybe just ; in filename, in any case this is just
# one case fix, for proper fix we need to redesign parser
_value = "{};{}".format(value, parts[0])
_value = f"{value};{parts[0]}"
if is_quoted(_value):
parts.pop(0)
value = unescape(_value[1:-1].lstrip("\\/"))
Expand Down
7 changes: 2 additions & 5 deletions aiohttp/payload.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
Dict,
Iterable,
Optional,
Text,
TextIO,
Tuple,
Type,
Expand Down Expand Up @@ -221,9 +220,7 @@ async def write(self, writer: AbstractStreamWriter) -> None:
class BytesPayload(Payload):
def __init__(self, value: ByteString, *args: Any, **kwargs: Any) -> None:
if not isinstance(value, (bytes, bytearray, memoryview)):
raise TypeError(
"value argument must be byte-ish, not {!r}".format(type(value))
)
raise TypeError(f"value argument must be byte-ish, not {type(value)!r}")

if "content_type" not in kwargs:
kwargs["content_type"] = "application/octet-stream"
Expand Down Expand Up @@ -251,7 +248,7 @@ async def write(self, writer: AbstractStreamWriter) -> None:
class StringPayload(BytesPayload):
def __init__(
self,
value: Text,
value: str,
*args: Any,
encoding: Optional[str] = None,
content_type: Optional[str] = None,
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,7 @@ def _read_nowait_chunk(self, n: int) -> bytes:
return data

def _read_nowait(self, n: int) -> bytes:
""" Read not more than n bytes, or whole buffer if n == -1 """
"""Read not more than n bytes, or whole buffer if n == -1"""
chunks = []

while self._buffer:
Expand Down
34 changes: 17 additions & 17 deletions aiohttp/tracing.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def __init__(
def trace_config_ctx(
self, trace_request_ctx: Optional[SimpleNamespace] = None
) -> SimpleNamespace:
""" Return a new trace_config_ctx instance """
"""Return a new trace_config_ctx instance"""
return self._trace_config_ctx_factory(trace_request_ctx=trace_request_ctx)

def freeze(self) -> None:
Expand Down Expand Up @@ -219,7 +219,7 @@ def on_request_headers_sent(

@dataclasses.dataclass(frozen=True)
class TraceRequestStartParams:
""" Parameters sent by the `on_request_start` signal"""
"""Parameters sent by the `on_request_start` signal"""

method: str
url: URL
Expand All @@ -228,7 +228,7 @@ class TraceRequestStartParams:

@dataclasses.dataclass(frozen=True)
class TraceRequestChunkSentParams:
""" Parameters sent by the `on_request_chunk_sent` signal"""
"""Parameters sent by the `on_request_chunk_sent` signal"""

method: str
url: URL
Expand All @@ -237,7 +237,7 @@ class TraceRequestChunkSentParams:

@dataclasses.dataclass(frozen=True)
class TraceResponseChunkReceivedParams:
""" Parameters sent by the `on_response_chunk_received` signal"""
"""Parameters sent by the `on_response_chunk_received` signal"""

method: str
url: URL
Expand All @@ -246,7 +246,7 @@ class TraceResponseChunkReceivedParams:

@dataclasses.dataclass(frozen=True)
class TraceRequestEndParams:
""" Parameters sent by the `on_request_end` signal"""
"""Parameters sent by the `on_request_end` signal"""

method: str
url: URL
Expand All @@ -256,7 +256,7 @@ class TraceRequestEndParams:

@dataclasses.dataclass(frozen=True)
class TraceRequestExceptionParams:
""" Parameters sent by the `on_request_exception` signal"""
"""Parameters sent by the `on_request_exception` signal"""

method: str
url: URL
Expand All @@ -266,7 +266,7 @@ class TraceRequestExceptionParams:

@dataclasses.dataclass(frozen=True)
class TraceRequestRedirectParams:
""" Parameters sent by the `on_request_redirect` signal"""
"""Parameters sent by the `on_request_redirect` signal"""

method: str
url: URL
Expand All @@ -276,60 +276,60 @@ class TraceRequestRedirectParams:

@dataclasses.dataclass(frozen=True)
class TraceConnectionQueuedStartParams:
""" Parameters sent by the `on_connection_queued_start` signal"""
"""Parameters sent by the `on_connection_queued_start` signal"""


@dataclasses.dataclass(frozen=True)
class TraceConnectionQueuedEndParams:
""" Parameters sent by the `on_connection_queued_end` signal"""
"""Parameters sent by the `on_connection_queued_end` signal"""


@dataclasses.dataclass(frozen=True)
class TraceConnectionCreateStartParams:
""" Parameters sent by the `on_connection_create_start` signal"""
"""Parameters sent by the `on_connection_create_start` signal"""


@dataclasses.dataclass(frozen=True)
class TraceConnectionCreateEndParams:
""" Parameters sent by the `on_connection_create_end` signal"""
"""Parameters sent by the `on_connection_create_end` signal"""


@dataclasses.dataclass(frozen=True)
class TraceConnectionReuseconnParams:
""" Parameters sent by the `on_connection_reuseconn` signal"""
"""Parameters sent by the `on_connection_reuseconn` signal"""


@dataclasses.dataclass(frozen=True)
class TraceDnsResolveHostStartParams:
""" Parameters sent by the `on_dns_resolvehost_start` signal"""
"""Parameters sent by the `on_dns_resolvehost_start` signal"""

host: str


@dataclasses.dataclass(frozen=True)
class TraceDnsResolveHostEndParams:
""" Parameters sent by the `on_dns_resolvehost_end` signal"""
"""Parameters sent by the `on_dns_resolvehost_end` signal"""

host: str


@dataclasses.dataclass(frozen=True)
class TraceDnsCacheHitParams:
""" Parameters sent by the `on_dns_cache_hit` signal"""
"""Parameters sent by the `on_dns_cache_hit` signal"""

host: str


@dataclasses.dataclass(frozen=True)
class TraceDnsCacheMissParams:
""" Parameters sent by the `on_dns_cache_miss` signal"""
"""Parameters sent by the `on_dns_cache_miss` signal"""

host: str


@dataclasses.dataclass(frozen=True)
class TraceRequestHeadersSentParams:
""" Parameters sent by the `on_request_headers_sent` signal"""
"""Parameters sent by the `on_request_headers_sent` signal"""

method: str
url: URL
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_app.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ def __call__(self) -> "Application":
return self

def __repr__(self) -> str:
return "<Application 0x{:x}>".format(id(self))
return f"<Application 0x{id(self):x}>"
Dreamsorcerer marked this conversation as resolved.
Show resolved Hide resolved

def __bool__(self) -> bool:
return True
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -431,7 +431,7 @@ def __init__(
super().__init__(
headers=headers, reason=reason, text=text, content_type=content_type
)
self.headers["Link"] = '<{}>; rel="blocked-by"'.format(str(link))
self.headers["Link"] = f'<{str(link)}>; rel="blocked-by"'
self._link = URL(link)

@property
Expand Down
2 changes: 1 addition & 1 deletion aiohttp/web_routedef.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ def __init__(self) -> None:
self._items = [] # type: List[AbstractRouteDef]

def __repr__(self) -> str:
return "<RouteTableDef count={}>".format(len(self._items))
return f"<RouteTableDef count={len(self._items)}>"

@overload
def __getitem__(self, index: int) -> AbstractRouteDef:
Expand Down
2 changes: 1 addition & 1 deletion examples/legacy/tcp_protocol_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ def stop(self):
self.transport.write(b"stop:\r\n")

def send_text(self, text):
self.transport.write(f"text:{text.strip()}\r\n".encode("utf-8"))
self.transport.write(f"text:{text.strip()}\r\n".encode())


class EchoServer(asyncio.Protocol):
Expand Down
2 changes: 1 addition & 1 deletion tests/test_client_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -996,7 +996,7 @@ async def handler(request):
async def redirect(request):
count = int(request.match_info["count"])
if count:
raise web.HTTPFound(location="/redirect/{}".format(count - 1))
raise web.HTTPFound(location=f"/redirect/{count - 1}")
else:
raise web.HTTPFound(location="/")

Expand Down
2 changes: 1 addition & 1 deletion tests/test_helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ def test_basic_auth_decode_invalid_credentials() -> None:
),
)
def test_basic_auth_decode_blank_username(credentials, expected_auth) -> None:
header = "Basic {}".format(base64.b64encode(credentials.encode()).decode())
header = f"Basic {base64.b64encode(credentials.encode()).decode()}"
assert helpers.BasicAuth.decode(header) == expected_auth


Expand Down
2 changes: 1 addition & 1 deletion tests/test_http_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -978,7 +978,7 @@ async def test_http_payload_parser_deflate(self, stream: Any) -> None:
assert out.is_eof()

async def test_http_payload_parser_deflate_no_hdrs(self, stream: Any) -> None:
"""Tests incorrectly formed data (no zlib headers) """
"""Tests incorrectly formed data (no zlib headers)"""

# c=compressobj(wbits=-15); b''.join([c.compress(b'data'), c.flush()])
COMPRESSED = b"KI,I\x04\x00"
Expand Down
2 changes: 1 addition & 1 deletion tests/test_resolver.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ async def fake(*args: Any, **kwargs: Any) -> List[Any]:
if not hosts:
raise socket.gaierror

return list([(None, None, None, None, [h, 0]) for h in hosts])
return [(None, None, None, None, [h, 0]) for h in hosts]

return fake

Expand Down
2 changes: 1 addition & 1 deletion tests/test_web_functional.py
Original file line number Diff line number Diff line change
Expand Up @@ -445,7 +445,7 @@ async def handler(request):

def test_repr_for_application() -> None:
app = web.Application()
assert "<Application 0x{:x}>".format(id(app)) == repr(app)
assert f"<Application 0x{id(app):x}>" == repr(app)


async def test_expect_default_handler_unknown(aiohttp_client: Any) -> None:
Expand Down
Loading