From 742616fabf0e58f0b1172070c890462756b1b583 Mon Sep 17 00:00:00 2001 From: Psychosoc1al Date: Wed, 17 Jun 2026 18:54:47 +0300 Subject: [PATCH] Update `pycurl` annotations compatibility --- tornado/curl_httpclient.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tornado/curl_httpclient.py b/tornado/curl_httpclient.py index 98da8543c..06c75fe30 100644 --- a/tornado/curl_httpclient.py +++ b/tornado/curl_httpclient.py @@ -49,8 +49,7 @@ def initialize( # type: ignore self, max_clients: int = 10, defaults: dict[str, Any] | None = None ) -> None: super().initialize(defaults=defaults) - # Typeshed is incomplete for CurlMulti, so just use Any for now. - self._multi: Any = pycurl.CurlMulti() + self._multi = pycurl.CurlMulti() self._multi.setopt(pycurl.M_TIMERFUNCTION, self._set_timeout) self._multi.setopt(pycurl.M_SOCKETFUNCTION, self._handle_socket) self._curls = [self._curl_create() for i in range(max_clients)] @@ -81,7 +80,7 @@ def close(self) -> None: # Set below properties to None to reduce the reference count of current # instance, because those properties hold some methods of current # instance that will case circular reference. - self._multi = None + self._multi = None # type: ignore def fetch_impl( self, request: HTTPRequest, callback: Callable[[HTTPResponse], None] @@ -90,7 +89,9 @@ def fetch_impl( self._process_queue() self._set_timeout(0) - def _handle_socket(self, event: int, fd: int, multi: Any, data: bytes) -> None: + def _handle_socket( + self, event: int, fd: int, multi: pycurl.CurlMulti, data: Any | None + ) -> None: """Called by libcurl when it wants to change the file descriptors it cares about. """