Skip to content
Open
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
4 changes: 2 additions & 2 deletions aiohttp/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 2 additions & 2 deletions aiohttp/client_reqrep.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,7 +352,7 @@
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:

Check notice

Code scanning / CodeQL

Overly complex `__del__` method Note

Overly complex '__del__' method.
if self._closed:
return

Expand All @@ -361,7 +361,7 @@
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"}
Expand Down
6 changes: 2 additions & 4 deletions aiohttp/connector.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,11 +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(
f"Unclosed connection {self!r}", ResourceWarning, source=self
)
warnings_warn(f"Unclosed connection {self!r}", ResourceWarning, source=self)
if self._loop.is_closed():
return

Expand Down
Loading