diff --git a/stubs/requests/requests/adapters.pyi b/stubs/requests/requests/adapters.pyi index 4e540e94fa13..2f8e4d75cd97 100644 --- a/stubs/requests/requests/adapters.pyi +++ b/stubs/requests/requests/adapters.pyi @@ -1,7 +1,10 @@ from _typeshed import Incomplete from collections.abc import Mapping -from typing_extensions import deprecated +from ssl import SSLContext +from typing import Literal, TypedDict +from typing_extensions import NotRequired, deprecated +import urllib3 from urllib3.connectionpool import ConnectionPool from urllib3.contrib.socks import SOCKSProxyManager as SOCKSProxyManager from urllib3.exceptions import ( @@ -34,6 +37,20 @@ from .utils import ( urldefragauth as urldefragauth, ) +# Arguments to urllib3 connection_from_host() functions (except pool_kwargs). +class _HostParams(TypedDict): + host: str + scheme: str + port: int + +class _PoolKwargs(TypedDict): + ssl_context: NotRequired[SSLContext] + ca_certs: NotRequired[str] + ca_cert_dir: NotRequired[str] + cert_reqs: Literal["CERT_REQUIRED", "CERT_NONE"] + cert_file: NotRequired[str] + key_file: NotRequired[str] + DEFAULT_POOLBLOCK: bool DEFAULT_POOLSIZE: int DEFAULT_RETRIES: int @@ -64,7 +81,10 @@ class HTTPAdapter(BaseAdapter): def init_poolmanager(self, connections, maxsize, block=False, **pool_kwargs): ... def proxy_manager_for(self, proxy, **proxy_kwargs): ... def cert_verify(self, conn, url, verify, cert): ... - def build_response(self, req, resp): ... + def build_response(self, req: PreparedRequest, resp: urllib3.BaseHTTPResponse) -> Response: ... + def build_connection_pool_key_attributes( + self, request: PreparedRequest, verify: bool | str, cert: str | tuple[str, str] | None = None + ) -> tuple[_HostParams, _PoolKwargs]: ... def get_connection_with_tls_context( self, request: PreparedRequest, diff --git a/stubs/requests/requests/models.pyi b/stubs/requests/requests/models.pyi index d710de8e792d..7e1a2e2de540 100644 --- a/stubs/requests/requests/models.pyi +++ b/stubs/requests/requests/models.pyi @@ -1,5 +1,5 @@ import datetime -from _typeshed import Unused +from _typeshed import Incomplete, Unused from collections.abc import Callable, Iterator from json import JSONDecoder from typing import Any @@ -41,10 +41,10 @@ super_len = utils.super_len to_native_string = utils.to_native_string codes = status_codes.codes -REDIRECT_STATI: Any -DEFAULT_REDIRECT_LIMIT: Any -CONTENT_CHUNK_SIZE: Any -ITER_CHUNK_SIZE: Any +REDIRECT_STATI: Incomplete +DEFAULT_REDIRECT_LIMIT: Incomplete +CONTENT_CHUNK_SIZE: Incomplete +ITER_CHUNK_SIZE: Incomplete class RequestEncodingMixin: @property @@ -55,16 +55,16 @@ class RequestHooksMixin: def deregister_hook(self, event, hook): ... class Request(RequestHooksMixin): - hooks: Any - method: Any - url: Any - headers: Any - files: Any - data: Any - json: Any - params: Any - auth: Any - cookies: Any + hooks: Incomplete + method: Incomplete + url: Incomplete + headers: Incomplete + files: Incomplete + data: Incomplete + json: Incomplete + params: Incomplete + auth: Incomplete + cookies: Incomplete def __init__( self, method=None, @@ -85,7 +85,7 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): url: str | None headers: CaseInsensitiveDict[str] body: bytes | str | None - hooks: Any + hooks: Incomplete def __init__(self) -> None: ... def prepare( self, @@ -111,11 +111,11 @@ class PreparedRequest(RequestEncodingMixin, RequestHooksMixin): def prepare_hooks(self, hooks) -> None: ... class Response: - __attrs__: Any + __attrs__: Incomplete _content: bytes | None # undocumented status_code: int headers: CaseInsensitiveDict[str] - raw: Any + raw: Incomplete url: str encoding: str | None history: list[Response] @@ -139,10 +139,10 @@ class Response: def is_permanent_redirect(self) -> bool: ... @property def apparent_encoding(self) -> str: ... - def iter_content(self, chunk_size: int | None = 1, decode_unicode: bool = False) -> Iterator[Any]: ... + def iter_content(self, chunk_size: int | None = 1, decode_unicode: bool = False) -> Iterator[Incomplete]: ... def iter_lines( self, chunk_size: int | None = 512, decode_unicode: bool = False, delimiter: str | bytes | None = None - ) -> Iterator[Any]: ... + ) -> Iterator[Incomplete]: ... @property def content(self) -> bytes: ... @property @@ -159,6 +159,6 @@ class Response: **kwds: Any, ) -> Any: ... @property - def links(self) -> dict[Any, Any]: ... + def links(self) -> dict[Incomplete, Incomplete]: ... def raise_for_status(self) -> None: ... def close(self) -> None: ...