Skip to content
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
2 changes: 1 addition & 1 deletion aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -1054,7 +1054,7 @@ def update_headers(self, headers: LooseHeaders | None) -> None:
if isinstance(headers, (dict, MultiDictProxy, MultiDict)):
headers = headers.items()

for key, value in headers: # type: ignore[misc]
for key, value in headers: # type: ignore[str-unpack]
# A special case for Host header
if key in hdrs.HOST_ALL:
self.headers[key] = value
Expand Down
22 changes: 12 additions & 10 deletions aiohttp/web_log.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,17 @@
import os
import re
import time as time_mod
from collections import namedtuple
from collections.abc import Iterable
from typing import Callable, ClassVar
from typing import Callable, ClassVar, NamedTuple

from .abc import AbstractAccessLogger
from .web_request import BaseRequest
from .web_response import StreamResponse

KeyMethod = namedtuple("KeyMethod", "key method")

class KeyMethod(NamedTuple):
key: str | tuple[str, str]
method: Callable[[BaseRequest, StreamResponse, float], str]


class AccessLogger(AbstractAccessLogger):
Expand Down Expand Up @@ -198,7 +200,7 @@ def _format_D(request: BaseRequest, response: StreamResponse, time: float) -> st

def _format_line(
self, request: BaseRequest, response: StreamResponse, time: float
) -> Iterable[tuple[str, Callable[[BaseRequest, StreamResponse, float], str]]]:
) -> Iterable[tuple[str | tuple[str, str], str]]:
return [(key, method(request, response, time)) for key, method in self._methods]

@property
Expand All @@ -212,17 +214,17 @@ def log(self, request: BaseRequest, response: StreamResponse, time: float) -> No
fmt_info = self._format_line(request, response, time)

values = list()
extra = dict()
extra: dict[str, str | dict[str, str]] = dict()
for key, value in fmt_info:
values.append(value)

if key.__class__ is str:
if isinstance(key, str):
extra[key] = value
else:
k1, k2 = key # type: ignore[misc]
dct = extra.get(k1, {}) # type: ignore[var-annotated,has-type]
dct[k2] = value # type: ignore[index,has-type]
extra[k1] = dct # type: ignore[has-type,assignment]
k1, k2 = key
dct: dict[str, str] = extra.get(k1, {}) # type: ignore[assignment]
dct[k2] = value
extra[k1] = dct

self.logger.info(self._log_format % tuple(values), extra=extra)
except Exception:
Expand Down
2 changes: 1 addition & 1 deletion requirements/constraints.txt
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ multidict==6.7.1
# -r requirements/multidict.in
# -r requirements/runtime-deps.in
# yarl
mypy==1.19.1 ; implementation_name == "cpython"
mypy==1.20.2 ; implementation_name == "cpython"
# via
# -r requirements/lint.in
# -r requirements/test-common.in
Expand Down
2 changes: 1 addition & 1 deletion requirements/dev.txt
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ multidict==6.7.1
# via
# -r requirements/runtime-deps.in
# yarl
mypy==1.19.1 ; implementation_name == "cpython"
mypy==1.20.2 ; implementation_name == "cpython"
# via
# -r requirements/lint.in
# -r requirements/test-common.in
Expand Down
2 changes: 1 addition & 1 deletion requirements/lint.txt
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ markdown-it-py==4.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
mypy==1.19.1 ; implementation_name == "cpython"
mypy==1.20.2 ; implementation_name == "cpython"
# via -r requirements/lint.in
mypy-extensions==1.1.0
# via mypy
Expand Down
2 changes: 1 addition & 1 deletion requirements/test-common.txt
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ markdown-it-py==4.0.0
# via rich
mdurl==0.1.2
# via markdown-it-py
mypy==1.19.1 ; implementation_name == "cpython"
mypy==1.20.2 ; implementation_name == "cpython"
# via -r requirements/test-common.in
mypy-extensions==1.1.0
# via mypy
Expand Down
2 changes: 1 addition & 1 deletion requirements/test-ft.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ multidict==6.7.1
# via
# -r requirements/runtime-deps.in
# yarl
mypy==1.19.1 ; implementation_name == "cpython"
mypy==1.20.2 ; implementation_name == "cpython"
# via -r requirements/test-common.in
mypy-extensions==1.1.0
# via mypy
Expand Down
2 changes: 1 addition & 1 deletion requirements/test.txt
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ multidict==6.7.1
# via
# -r requirements/runtime-deps.in
# yarl
mypy==1.19.1 ; implementation_name == "cpython"
mypy==1.20.2 ; implementation_name == "cpython"
# via -r requirements/test-common.in
mypy-extensions==1.1.0
# via mypy
Expand Down
Loading