@@ -4,9 +4,9 @@ import http.client
44import re
55from _ssl import _PasswordType
66from _typeshed import ConvertibleToFloat , ConvertibleToInt , FloatInt , Incomplete , MaybeNone , StrOrBytesPath
7- from collections .abc import Generator
8- from ssl import _SSLMethod
9- from typing import Any , ClassVar , Final , Literal , TypeVar , overload
7+ from collections .abc import Callable , Generator , Sequence
8+ from ssl import TLSVersion , _SSLMethod
9+ from typing import Any , ClassVar , Final , Literal , TypeAlias , TypeVar , overload
1010from typing_extensions import Self
1111
1212from .error import *
@@ -15,6 +15,8 @@ _T = TypeVar("_T", default=str)
1515_R = TypeVar ("_R" )
1616_D = TypeVar ("_D" )
1717
18+ _ProxyInfoFactory : TypeAlias = Callable [[Literal ["http" , "https" ]], ProxyInfo | None ]
19+
1820__author__ : Final [str ]
1921__copyright__ : Final [str ]
2022__contributors__ : Final [list [str ]]
@@ -127,28 +129,47 @@ class KeyCerts(Credentials):
127129class AllHosts : ...
128130
129131class ProxyInfo :
130- bypass_hosts : Incomplete
132+ bypass_hosts : Sequence [str ] | type [AllHosts ]
133+ proxy_type : int
134+ proxy_host : str | None
135+ proxy_port : int | None
136+ proxy_rdns : bool
137+ proxy_user : str | None
138+ proxy_pass : str | None
139+ proxy_headers : Incomplete | None # stored but never sent by httplib2
131140 def __init__ (
132- self , proxy_type , proxy_host , proxy_port , proxy_rdns : bool = True , proxy_user = None , proxy_pass = None , proxy_headers = None
141+ self ,
142+ proxy_type : int ,
143+ proxy_host : str | None ,
144+ proxy_port : int | None ,
145+ proxy_rdns : bool = True ,
146+ proxy_user : str | bytes | None = None ,
147+ proxy_pass : str | bytes | None = None ,
148+ proxy_headers = None ,
133149 ) -> None : ...
134- def astuple (self ): ...
135- def isgood (self ): ...
136- def applies_to (self , hostname ) : ...
137- def bypass_host (self , hostname ) : ...
150+ def astuple (self ) -> tuple [ int , str | None , int | None , bool , str | None , str | None , Incomplete | None ] : ...
151+ def isgood (self ) -> bool | None : ... # None if PySocks is not installed
152+ def applies_to (self , hostname : str ) -> bool : ...
153+ def bypass_host (self , hostname : str ) -> bool : ...
138154
139155def proxy_info_from_environment (method : Literal ["http" , "https" ] = "http" ) -> ProxyInfo | None : ...
140156def proxy_info_from_url (url : str , method : Literal ["http" , "https" ] = "http" , noproxy : str | None = None ) -> ProxyInfo : ...
141157
142158class HTTPConnectionWithTimeout (http .client .HTTPConnection ):
143- proxy_info : Incomplete
144- def __init__ (self , host , port = None , timeout = None , proxy_info = None ) -> None : ...
145- sock : Incomplete
159+ proxy_info : ProxyInfo | None
160+ def __init__ (
161+ self ,
162+ host : str ,
163+ port : int | None = None ,
164+ timeout : FloatInt | None = None ,
165+ proxy_info : ProxyInfo | _ProxyInfoFactory | None = None ,
166+ ) -> None : ...
146167 def connect (self ) -> None : ...
147168
148169class HTTPSConnectionWithTimeout (http .client .HTTPSConnection ):
149170 disable_ssl_certificate_validation : bool
150171 ca_certs : StrOrBytesPath | None
151- proxy_info : Incomplete
172+ proxy_info : ProxyInfo | None
152173 key_file : StrOrBytesPath | None
153174 cert_file : StrOrBytesPath | None
154175 key_password : _PasswordType | None
@@ -159,25 +180,24 @@ class HTTPSConnectionWithTimeout(http.client.HTTPSConnection):
159180 key_file : StrOrBytesPath | None = None ,
160181 cert_file : StrOrBytesPath | None = None ,
161182 timeout : FloatInt | None = None ,
162- proxy_info = None ,
183+ proxy_info : ProxyInfo | _ProxyInfoFactory | None = None ,
163184 ca_certs : StrOrBytesPath | None = None ,
164185 disable_ssl_certificate_validation : bool = False ,
165- tls_maximum_version = None ,
166- tls_minimum_version = None ,
186+ tls_maximum_version : TLSVersion | str | None = None ,
187+ tls_minimum_version : TLSVersion | str | None = None ,
167188 key_password : _PasswordType | None = None ,
168189 ) -> None : ...
169- sock : Incomplete
170190 def connect (self ) -> None : ...
171191
172192SCHEME_TO_CONNECTION : Final [dict [Literal ["http" , "https" ], type [http .client .HTTPConnection ]]]
173193
174194class Http :
175- proxy_info : Incomplete
176- ca_certs : Incomplete
195+ proxy_info : ProxyInfo | _ProxyInfoFactory | None
196+ ca_certs : StrOrBytesPath | None
177197 disable_ssl_certificate_validation : bool
178- tls_maximum_version : Incomplete
179- tls_minimum_version : Incomplete
180- connections : Incomplete
198+ tls_maximum_version : TLSVersion | str | None
199+ tls_minimum_version : TLSVersion | str | None
200+ connections : dict [ str , http . client . HTTPConnection ]
181201 cache : FileCache
182202 credentials : Credentials
183203 certificates : KeyCerts
@@ -196,11 +216,11 @@ class Http:
196216 self ,
197217 cache : str | FileCache | None = None ,
198218 timeout : FloatInt | None = None ,
199- proxy_info = ...,
200- ca_certs = None ,
219+ proxy_info : ProxyInfo | _ProxyInfoFactory | None = ...,
220+ ca_certs : StrOrBytesPath | None = None ,
201221 disable_ssl_certificate_validation : bool = False ,
202- tls_maximum_version = None ,
203- tls_minimum_version = None ,
222+ tls_maximum_version : TLSVersion | str | None = None ,
223+ tls_minimum_version : TLSVersion | str | None = None ,
204224 decode_limit_hard : ConvertibleToInt | None = None ,
205225 decode_limit_safe : ConvertibleToInt | None = None ,
206226 decode_limit_ratio : ConvertibleToFloat | None = None ,
0 commit comments