Skip to content

Commit 7f17de7

Browse files
authored
Update adapters.pyi
1 parent 06f5f92 commit 7f17de7

1 file changed

Lines changed: 31 additions & 6 deletions

File tree

stubs/requests/requests/adapters.pyi

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from _typeshed import Incomplete
22
from collections.abc import Mapping
33
from ssl import SSLContext
4-
from typing import Literal, TypedDict, type_check_only
4+
from typing import Any, Literal, TypedDict, type_check_only
55
from typing_extensions import NotRequired, deprecated
66

77
import urllib3
@@ -80,8 +80,26 @@ class HTTPAdapter(BaseAdapter):
8080
self, pool_connections: int = 10, pool_maxsize: int = 10, max_retries: Retry | int | None = 0, pool_block: bool = False
8181
) -> None: ...
8282
poolmanager: Incomplete
83-
def init_poolmanager(self, connections, maxsize, block=False, **pool_kwargs): ...
84-
def proxy_manager_for(self, proxy, **proxy_kwargs): ...
83+
def init_poolmanager(
84+
self,
85+
connections: int,
86+
maxsize: int,
87+
block: bool = False,
88+
**pool_kwargs: Any, # Any: Arbitrary keyword arguments passed directly to urllib3's PoolManager constructor.
89+
# Allowed types depend on urllib3 version, but typically include:
90+
# ssl_version (int), cert_reqs (str), ca_certs (str), ca_cert_dir (str),
91+
# ssl_context (ssl.SSLContext), socket_options (list), etc.
92+
# We use Any because the exact set is dynamic and not fully specified in stubs.
93+
) -> None: ...
94+
def proxy_manager_for(
95+
self,
96+
proxy: str,
97+
**proxy_kwargs: Any # Any: Same as pool_kwargs above, passed to ProxyManager or SOCKSProxyManager.
98+
# May include: ssl_context, cert_reqs, ca_certs, ca_cert_dir, etc.
99+
) -> Any: # Any: Returns either urllib3.ProxyManager (for HTTP/HTTPS proxies) or SOCKSProxyManager (for SOCKS).
100+
# The exact return type depends on the proxy scheme and is not needed by callers; using Any avoids
101+
# circular imports or complex union types. In practice, the object adheres to a common interface.
102+
...
85103
def cert_verify(self, conn, url, verify, cert): ...
86104
def build_response(self, req: PreparedRequest, resp: urllib3.BaseHTTPResponse) -> Response: ...
87105
def build_connection_pool_key_attributes(
@@ -97,9 +115,16 @@ class HTTPAdapter(BaseAdapter):
97115
@deprecated("Use get_connection_with_tls_context() instead.")
98116
def get_connection(self, url: _Uri, proxies: Mapping[str, str] | None = None) -> ConnectionPool: ...
99117
def close(self) -> None: ...
100-
def request_url(self, request, proxies): ...
101-
def add_headers(self, request, **kwargs): ...
102-
def proxy_headers(self, proxy): ...
118+
def request_url(self, request: PreparedRequest, proxies: Mapping[str, str] | None) -> str: ...
119+
def add_headers(
120+
self,
121+
request: PreparedRequest,
122+
**kwargs: Any # Any: Hook method for subclasses to add custom headers.
123+
# The kwargs mirror the send() parameters: stream (bool), timeout (float|tuple),
124+
# verify (bool|str), cert (str|tuple), proxies (dict). Base implementation ignores them.
125+
# Using Any allows subclasses to access these arguments without repeating the full signature.
126+
) -> None: ...
127+
def proxy_headers(self, proxy: str) -> dict[str, str]: ...
103128
def send(
104129
self,
105130
request: PreparedRequest,

0 commit comments

Comments
 (0)