From f7062b5fac5a15b4cad651281003537f910365a6 Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Mon, 4 May 2026 13:57:50 +0000 Subject: [PATCH 1/3] Bump mypy from 1.19.1 to 1.20.2 Bumps [mypy](https://github.com/python/mypy) from 1.19.1 to 1.20.2. - [Changelog](https://github.com/python/mypy/blob/master/CHANGELOG.md) - [Commits](https://github.com/python/mypy/compare/v1.19.1...v1.20.2) --- updated-dependencies: - dependency-name: mypy dependency-version: 1.20.2 dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] --- requirements/constraints.txt | 2 +- requirements/dev.txt | 2 +- requirements/lint.txt | 2 +- requirements/test-common.txt | 2 +- requirements/test-ft.txt | 2 +- requirements/test.txt | 2 +- 6 files changed, 6 insertions(+), 6 deletions(-) diff --git a/requirements/constraints.txt b/requirements/constraints.txt index 3d47fe07dde..7d2a46373b3 100644 --- a/requirements/constraints.txt +++ b/requirements/constraints.txt @@ -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 diff --git a/requirements/dev.txt b/requirements/dev.txt index e021873638c..228f62fdfa4 100644 --- a/requirements/dev.txt +++ b/requirements/dev.txt @@ -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 diff --git a/requirements/lint.txt b/requirements/lint.txt index 77209a1d445..c9cf6e965dc 100644 --- a/requirements/lint.txt +++ b/requirements/lint.txt @@ -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 diff --git a/requirements/test-common.txt b/requirements/test-common.txt index 35bb72c8c73..92559c4578e 100644 --- a/requirements/test-common.txt +++ b/requirements/test-common.txt @@ -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 diff --git a/requirements/test-ft.txt b/requirements/test-ft.txt index f38961394dc..5deead87e38 100644 --- a/requirements/test-ft.txt +++ b/requirements/test-ft.txt @@ -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 diff --git a/requirements/test.txt b/requirements/test.txt index 9a1a0470ef0..b50e7ce1dbc 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -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 From 6fba6d8602e6e77177bba815835b1e3667a977f6 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Mon, 4 May 2026 15:30:43 +0100 Subject: [PATCH 2/3] Refactor KeyMethod and update type hints Refactor KeyMethod from namedtuple to NamedTuple and update type hints for better clarity. --- aiohttp/web_log.py | 22 ++++++++++++---------- 1 file changed, 12 insertions(+), 10 deletions(-) diff --git a/aiohttp/web_log.py b/aiohttp/web_log.py index 27b50adf6d6..9283cc08b12 100644 --- a/aiohttp/web_log.py +++ b/aiohttp/web_log.py @@ -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): @@ -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 @@ -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: From eb5b5f9eae66d91bdc894519f4219ff783fe2e88 Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Mon, 4 May 2026 15:50:19 +0100 Subject: [PATCH 3/3] Update type ignore for headers unpacking --- aiohttp/client_reqrep.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index aa0d48159c0..92b3529bf13 100644 --- a/aiohttp/client_reqrep.py +++ b/aiohttp/client_reqrep.py @@ -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