From 3c5133390989301f0111fcc27e11703d2612deca Mon Sep 17 00:00:00 2001 From: Dmytro Vynnyk Date: Fri, 24 Oct 2025 16:32:51 -0700 Subject: [PATCH 1/4] Update connector.py --- aiohttp/connector.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/aiohttp/connector.py b/aiohttp/connector.py index 0b6081f8e08..da25e0dafd5 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -132,9 +132,9 @@ def __init__( def __repr__(self) -> str: return f"Connection<{self._key}>" - def __del__(self, _warnings: Any = warnings) -> None: + def __del__(self, warnings_warn: Any = warnings.warn) -> None: if self._protocol is not None: - _warnings.warn( + warnings_warn( f"Unclosed connection {self!r}", ResourceWarning, source=self ) if self._loop.is_closed(): From d8afcf9b4da8b3115dad02d9488f2636bd4f1f8a Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 24 Oct 2025 23:39:18 +0000 Subject: [PATCH 2/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- aiohttp/connector.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/aiohttp/connector.py b/aiohttp/connector.py index da25e0dafd5..92b0382b8ac 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -134,9 +134,7 @@ def __repr__(self) -> str: def __del__(self, warnings_warn: Any = warnings.warn) -> None: if self._protocol is not None: - warnings_warn( - f"Unclosed connection {self!r}", ResourceWarning, source=self - ) + warnings_warn(f"Unclosed connection {self!r}", ResourceWarning, source=self) if self._loop.is_closed(): return From e247e8c06f379376f6d43163d06b87faccea45cf Mon Sep 17 00:00:00 2001 From: Dimitry Date: Fri, 24 Oct 2025 16:43:21 -0700 Subject: [PATCH 3/4] . --- aiohttp/client.py | 4 ++-- aiohttp/client_reqrep.py | 4 ++-- aiohttp/connector.py | 4 +++- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/aiohttp/client.py b/aiohttp/client.py index dcbdd23dfd4..dd55e6e615d 100644 --- a/aiohttp/client.py +++ b/aiohttp/client.py @@ -383,9 +383,9 @@ def __init_subclass__(cls: type["ClientSession"]) -> None: f"Inheritance class {cls.__name__} from ClientSession " "is forbidden" ) - def __del__(self, _warnings: Any = warnings) -> None: + def __del__(self, warnings_warn: Any = warnings.warn) -> None: if not self.closed: - _warnings.warn( + warnings_warn( f"Unclosed client session {self!r}", ResourceWarning, source=self, diff --git a/aiohttp/client_reqrep.py b/aiohttp/client_reqrep.py index 0d6f435b6e5..a6b4845ec6b 100644 --- a/aiohttp/client_reqrep.py +++ b/aiohttp/client_reqrep.py @@ -352,7 +352,7 @@ def content_disposition(self) -> ContentDisposition | None: filename = multipart.content_disposition_filename(params) return ContentDisposition(disposition_type, params, filename) - def __del__(self, _warnings: Any = warnings) -> None: + def __del__(self, warnings_warn: Any = warnings.warn) -> None: if self._closed: return @@ -361,7 +361,7 @@ def __del__(self, _warnings: Any = warnings) -> None: self._cleanup_writer() if self._loop.get_debug(): - _warnings.warn( + warnings_warn( f"Unclosed response {self!r}", ResourceWarning, source=self ) context = {"client_response": self, "message": "Unclosed response"} diff --git a/aiohttp/connector.py b/aiohttp/connector.py index 92b0382b8ac..da25e0dafd5 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -134,7 +134,9 @@ def __repr__(self) -> str: def __del__(self, warnings_warn: Any = warnings.warn) -> None: if self._protocol is not None: - warnings_warn(f"Unclosed connection {self!r}", ResourceWarning, source=self) + warnings_warn( + f"Unclosed connection {self!r}", ResourceWarning, source=self + ) if self._loop.is_closed(): return From 0ba123d0d96ecd959b3488984123cf8a97f3a3dd Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 24 Oct 2025 23:44:13 +0000 Subject: [PATCH 4/4] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- aiohttp/connector.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/aiohttp/connector.py b/aiohttp/connector.py index da25e0dafd5..92b0382b8ac 100644 --- a/aiohttp/connector.py +++ b/aiohttp/connector.py @@ -134,9 +134,7 @@ def __repr__(self) -> str: def __del__(self, warnings_warn: Any = warnings.warn) -> None: if self._protocol is not None: - warnings_warn( - f"Unclosed connection {self!r}", ResourceWarning, source=self - ) + warnings_warn(f"Unclosed connection {self!r}", ResourceWarning, source=self) if self._loop.is_closed(): return