From ee24958e1e58b455cc1bb164117dcfa2c4d074da Mon Sep 17 00:00:00 2001 From: Andria Brown Date: Thu, 11 Jul 2024 18:09:07 -0600 Subject: [PATCH] requests: Add connection property (type HTTPAdapter) to the Response class (#12279) The `Response` instance is built by `HTTPAdapter`. When built, a property called `connection` is added to the `Response` that points back to the `HTTPAdapter` that created it. For example, this is used in the `requests` library's `HTTPDigestAuth` class to remake requests with credentials after authorization is requested by a server. --- stubs/requests/requests/models.pyi | 2 ++ 1 file changed, 2 insertions(+) diff --git a/stubs/requests/requests/models.pyi b/stubs/requests/requests/models.pyi index e63d44f73..af06bc29a 100644 --- a/stubs/requests/requests/models.pyi +++ b/stubs/requests/requests/models.pyi @@ -8,6 +8,7 @@ from typing_extensions import Self from urllib3 import exceptions as urllib3_exceptions, fields, filepost, util from . import auth, cookies, exceptions, hooks, status_codes, utils +from .adapters import HTTPAdapter from .cookies import RequestsCookieJar from .structures import CaseInsensitiveDict as CaseInsensitiveDict @@ -123,6 +124,7 @@ class Response: cookies: RequestsCookieJar elapsed: datetime.timedelta request: PreparedRequest + connection: HTTPAdapter def __init__(self) -> None: ... def __bool__(self) -> bool: ... def __nonzero__(self) -> bool: ...