Skip to content

Commit 779505c

Browse files
[pre-commit.ci] pre-commit autoupdate (#8100)
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com> Co-authored-by: J. Nick Koston <[email protected]>
1 parent 2bd69cf commit 779505c

17 files changed

+98
-139
lines changed

.pre-commit-config.yaml

+2-2
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ repos:
6060
hooks:
6161
- id: isort
6262
- repo: https://github.com/psf/black
63-
rev: '23.12.1'
63+
rev: '24.3.0'
6464
hooks:
6565
- id: black
6666
language_version: python3 # Should be a command that runs python
@@ -97,7 +97,7 @@ repos:
9797
- id: detect-private-key
9898
exclude: ^examples/
9999
- repo: https://github.com/asottile/pyupgrade
100-
rev: 'v3.15.0'
100+
rev: 'v3.15.2'
101101
hooks:
102102
- id: pyupgrade
103103
args: ['--py37-plus']

aiohttp/client.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,9 @@ def __init__(
261261
self._connector: Optional[BaseConnector] = connector
262262
self._loop = loop
263263
if loop.get_debug():
264-
self._source_traceback: Optional[
265-
traceback.StackSummary
266-
] = traceback.extract_stack(sys._getframe(1))
264+
self._source_traceback: Optional[traceback.StackSummary] = (
265+
traceback.extract_stack(sys._getframe(1))
266+
)
267267
else:
268268
self._source_traceback = None
269269

aiohttp/client_reqrep.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -756,9 +756,9 @@ def __init__(
756756
# work after the response has finished reading the body.
757757
if session is None:
758758
# TODO: Fix session=None in tests (see ClientRequest.__init__).
759-
self._resolve_charset: Callable[
760-
["ClientResponse", bytes], str
761-
] = lambda *_: "utf-8"
759+
self._resolve_charset: Callable[["ClientResponse", bytes], str] = (
760+
lambda *_: "utf-8"
761+
)
762762
else:
763763
self._resolve_charset = session._resolve_charset
764764
if loop.get_debug():

aiohttp/client_ws.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -100,9 +100,11 @@ def _reset_heartbeat(self) -> None:
100100
self._send_heartbeat,
101101
self._heartbeat,
102102
self._loop,
103-
timeout_ceil_threshold=self._conn._connector._timeout_ceil_threshold
104-
if self._conn is not None
105-
else 5,
103+
timeout_ceil_threshold=(
104+
self._conn._connector._timeout_ceil_threshold
105+
if self._conn is not None
106+
else 5
107+
),
106108
)
107109

108110
def _send_heartbeat(self) -> None:
@@ -118,9 +120,11 @@ def _send_heartbeat(self) -> None:
118120
self._pong_not_received,
119121
self._pong_heartbeat,
120122
self._loop,
121-
timeout_ceil_threshold=self._conn._connector._timeout_ceil_threshold
122-
if self._conn is not None
123-
else 5,
123+
timeout_ceil_threshold=(
124+
self._conn._connector._timeout_ceil_threshold
125+
if self._conn is not None
126+
else 5
127+
),
124128
)
125129

126130
def _pong_not_received(self) -> None:

aiohttp/compression_utils.py

+5-3
Original file line numberDiff line numberDiff line change
@@ -50,9 +50,11 @@ def __init__(
5050
max_sync_chunk_size: Optional[int] = MAX_SYNC_CHUNK_SIZE,
5151
):
5252
super().__init__(
53-
mode=encoding_to_mode(encoding, suppress_deflate_header)
54-
if wbits is None
55-
else wbits,
53+
mode=(
54+
encoding_to_mode(encoding, suppress_deflate_header)
55+
if wbits is None
56+
else wbits
57+
),
5658
executor=executor,
5759
max_sync_chunk_size=max_sync_chunk_size,
5860
)

aiohttp/connector.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -220,9 +220,9 @@ def __init__(
220220
self._limit = limit
221221
self._limit_per_host = limit_per_host
222222
self._acquired: Set[ResponseHandler] = set()
223-
self._acquired_per_host: DefaultDict[
224-
ConnectionKey, Set[ResponseHandler]
225-
] = defaultdict(set)
223+
self._acquired_per_host: DefaultDict[ConnectionKey, Set[ResponseHandler]] = (
224+
defaultdict(set)
225+
)
226226
self._keepalive_timeout = cast(float, keepalive_timeout)
227227
self._force_close = force_close
228228

aiohttp/helpers.py

+6-12
Original file line numberDiff line numberDiff line change
@@ -805,8 +805,7 @@ def set_exception(
805805
self,
806806
exc: BaseException,
807807
exc_cause: BaseException = ...,
808-
) -> None:
809-
... # pragma: no cover
808+
) -> None: ... # pragma: no cover
810809

811810

812811
def set_exception(
@@ -896,12 +895,10 @@ def __init_subclass__(cls) -> None:
896895
)
897896

898897
@overload # type: ignore[override]
899-
def __getitem__(self, key: AppKey[_T]) -> _T:
900-
...
898+
def __getitem__(self, key: AppKey[_T]) -> _T: ...
901899

902900
@overload
903-
def __getitem__(self, key: str) -> Any:
904-
...
901+
def __getitem__(self, key: str) -> Any: ...
905902

906903
def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:
907904
for mapping in self._maps:
@@ -912,16 +909,13 @@ def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:
912909
raise KeyError(key)
913910

914911
@overload # type: ignore[override]
915-
def get(self, key: AppKey[_T], default: _S) -> Union[_T, _S]:
916-
...
912+
def get(self, key: AppKey[_T], default: _S) -> Union[_T, _S]: ...
917913

918914
@overload
919-
def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]:
920-
...
915+
def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]: ...
921916

922917
@overload
923-
def get(self, key: str, default: Any = ...) -> Any:
924-
...
918+
def get(self, key: str, default: Any = ...) -> Any: ...
925919

926920
def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:
927921
try:

aiohttp/http_exceptions.py

-1
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
"""Low-level http related exceptions."""
22

3-
43
from textwrap import indent
54
from typing import Optional, Union
65

aiohttp/tracing.py

+10-11
Original file line numberDiff line numberDiff line change
@@ -19,8 +19,7 @@ def __call__(
1919
__client_session: ClientSession,
2020
__trace_config_ctx: SimpleNamespace,
2121
__params: _ParamT_contra,
22-
) -> Awaitable[None]:
23-
...
22+
) -> Awaitable[None]: ...
2423

2524

2625
__all__ = (
@@ -50,9 +49,9 @@ class TraceConfig:
5049
def __init__(
5150
self, trace_config_ctx_factory: Type[SimpleNamespace] = SimpleNamespace
5251
) -> None:
53-
self._on_request_start: Signal[
54-
_SignalCallback[TraceRequestStartParams]
55-
] = Signal(self)
52+
self._on_request_start: Signal[_SignalCallback[TraceRequestStartParams]] = (
53+
Signal(self)
54+
)
5655
self._on_request_chunk_sent: Signal[
5756
_SignalCallback[TraceRequestChunkSentParams]
5857
] = Signal(self)
@@ -89,12 +88,12 @@ def __init__(
8988
self._on_dns_resolvehost_end: Signal[
9089
_SignalCallback[TraceDnsResolveHostEndParams]
9190
] = Signal(self)
92-
self._on_dns_cache_hit: Signal[
93-
_SignalCallback[TraceDnsCacheHitParams]
94-
] = Signal(self)
95-
self._on_dns_cache_miss: Signal[
96-
_SignalCallback[TraceDnsCacheMissParams]
97-
] = Signal(self)
91+
self._on_dns_cache_hit: Signal[_SignalCallback[TraceDnsCacheHitParams]] = (
92+
Signal(self)
93+
)
94+
self._on_dns_cache_miss: Signal[_SignalCallback[TraceDnsCacheMissParams]] = (
95+
Signal(self)
96+
)
9897
self._on_request_headers_sent: Signal[
9998
_SignalCallback[TraceRequestHeadersSentParams]
10099
] = Signal(self)

aiohttp/web_app.py

+7-14
Original file line numberDiff line numberDiff line change
@@ -143,12 +143,10 @@ def __eq__(self, other: object) -> bool:
143143
return self is other
144144

145145
@overload # type: ignore[override]
146-
def __getitem__(self, key: AppKey[_T]) -> _T:
147-
...
146+
def __getitem__(self, key: AppKey[_T]) -> _T: ...
148147

149148
@overload
150-
def __getitem__(self, key: str) -> Any:
151-
...
149+
def __getitem__(self, key: str) -> Any: ...
152150

153151
def __getitem__(self, key: Union[str, AppKey[_T]]) -> Any:
154152
return self._state[key]
@@ -160,12 +158,10 @@ def _check_frozen(self) -> None:
160158
)
161159

162160
@overload # type: ignore[override]
163-
def __setitem__(self, key: AppKey[_T], value: _T) -> None:
164-
...
161+
def __setitem__(self, key: AppKey[_T], value: _T) -> None: ...
165162

166163
@overload
167-
def __setitem__(self, key: str, value: Any) -> None:
168-
...
164+
def __setitem__(self, key: str, value: Any) -> None: ...
169165

170166
def __setitem__(self, key: Union[str, AppKey[_T]], value: Any) -> None:
171167
self._check_frozen()
@@ -190,16 +186,13 @@ def __iter__(self) -> Iterator[Union[str, AppKey[Any]]]:
190186
return iter(self._state)
191187

192188
@overload # type: ignore[override]
193-
def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]:
194-
...
189+
def get(self, key: AppKey[_T], default: None = ...) -> Optional[_T]: ...
195190

196191
@overload
197-
def get(self, key: AppKey[_T], default: _U) -> Union[_T, _U]:
198-
...
192+
def get(self, key: AppKey[_T], default: _U) -> Union[_T, _U]: ...
199193

200194
@overload
201-
def get(self, key: str, default: Any = ...) -> Any:
202-
...
195+
def get(self, key: str, default: Any = ...) -> Any: ...
203196

204197
def get(self, key: Union[str, AppKey[_T]], default: Any = None) -> Any:
205198
return self._state.get(key, default)

aiohttp/web_protocol.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -239,9 +239,9 @@ def __init__(
239239
self.access_log = access_log
240240
if access_log:
241241
if issubclass(access_log_class, AbstractAsyncAccessLogger):
242-
self.access_logger: Optional[
243-
AbstractAsyncAccessLogger
244-
] = access_log_class()
242+
self.access_logger: Optional[AbstractAsyncAccessLogger] = (
243+
access_log_class()
244+
)
245245
else:
246246
access_logger = access_log_class(access_log, access_log_format)
247247
self.access_logger = AccessLoggerWrapper(

aiohttp/web_request.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -98,10 +98,10 @@ class FileField:
9898
qdtext=_QDTEXT, quoted_pair=_QUOTED_PAIR
9999
)
100100

101-
_FORWARDED_PAIR: Final[
102-
str
103-
] = r"({token})=({token}|{quoted_string})(:\d{{1,4}})?".format(
104-
token=_TOKEN, quoted_string=_QUOTED_STRING
101+
_FORWARDED_PAIR: Final[str] = (
102+
r"({token})=({token}|{quoted_string})(:\d{{1,4}})?".format(
103+
token=_TOKEN, quoted_string=_QUOTED_STRING
104+
)
105105
)
106106

107107
_QUOTED_PAIR_REPLACE_RE: Final[Pattern[str]] = re.compile(r"\\([\t !-~])")

aiohttp/web_routedef.py

+2-4
Original file line numberDiff line numberDiff line change
@@ -161,12 +161,10 @@ def __repr__(self) -> str:
161161
return f"<RouteTableDef count={len(self._items)}>"
162162

163163
@overload
164-
def __getitem__(self, index: int) -> AbstractRouteDef:
165-
...
164+
def __getitem__(self, index: int) -> AbstractRouteDef: ...
166165

167166
@overload
168-
def __getitem__(self, index: slice) -> List[AbstractRouteDef]:
169-
...
167+
def __getitem__(self, index: slice) -> List[AbstractRouteDef]: ...
170168

171169
def __getitem__(self, index): # type: ignore[no-untyped-def]
172170
return self._items[index]

aiohttp/web_server.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
"""Low level HTTP server."""
2+
23
import asyncio
34
import warnings
45
from typing import Any, Awaitable, Callable, Dict, List, Optional # noqa

aiohttp/web_ws.py

+10-6
Original file line numberDiff line numberDiff line change
@@ -135,9 +135,11 @@ def _reset_heartbeat(self) -> None:
135135
self._send_heartbeat,
136136
self._heartbeat,
137137
self._loop,
138-
timeout_ceil_threshold=self._req._protocol._timeout_ceil_threshold
139-
if self._req is not None
140-
else 5,
138+
timeout_ceil_threshold=(
139+
self._req._protocol._timeout_ceil_threshold
140+
if self._req is not None
141+
else 5
142+
),
141143
)
142144

143145
def _send_heartbeat(self) -> None:
@@ -154,9 +156,11 @@ def _send_heartbeat(self) -> None:
154156
self._pong_not_received,
155157
self._pong_heartbeat,
156158
self._loop,
157-
timeout_ceil_threshold=self._req._protocol._timeout_ceil_threshold
158-
if self._req is not None
159-
else 5,
159+
timeout_ceil_threshold=(
160+
self._req._protocol._timeout_ceil_threshold
161+
if self._req is not None
162+
else 5
163+
),
160164
)
161165

162166
def _pong_not_received(self) -> None:

tests/test_circular_imports.py

+10-7
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88
* https://github.com/pytest-dev/pytest/blob/d18c75b/testing/test_meta.py
99
* https://twitter.com/codewithanthony/status/1229445110510735361
1010
"""
11+
1112
import os
1213
import pkgutil
1314
import socket
@@ -30,14 +31,16 @@ def _mark_aiohttp_worker_for_skipping(
3031
importables: List[str],
3132
) -> List[Union[str, "ParameterSet"]]:
3233
return [
33-
pytest.param(
34-
importable,
35-
marks=pytest.mark.skipif(
36-
not hasattr(socket, "AF_UNIX"), reason="It's a UNIX-only module"
37-
),
34+
(
35+
pytest.param(
36+
importable,
37+
marks=pytest.mark.skipif(
38+
not hasattr(socket, "AF_UNIX"), reason="It's a UNIX-only module"
39+
),
40+
)
41+
if importable == "aiohttp.worker"
42+
else importable
3843
)
39-
if importable == "aiohttp.worker"
40-
else importable
4144
for importable in importables
4245
]
4346

0 commit comments

Comments
 (0)