@@ -3,21 +3,36 @@ import email.message
33import http .client
44import re
55from _ssl import _PasswordType
6- from _typeshed import Incomplete , MaybeNone , StrOrBytesPath
6+ from _typeshed import ConvertibleToFloat , ConvertibleToInt , Incomplete , MaybeNone , StrOrBytesPath
77from collections .abc import Generator
88from ssl import _SSLMethod
9- from typing import ClassVar , Final , Literal , TypeVar
9+ from typing import Any , ClassVar , Final , Literal , TypeVar , overload
1010from typing_extensions import Self
1111
1212from .error import *
1313
1414_T = TypeVar ("_T" , default = str )
15+ _R = TypeVar ("_R" )
16+ _D = TypeVar ("_D" )
1517
1618__author__ : Final [str ]
1719__copyright__ : Final [str ]
1820__contributors__ : Final [list [str ]]
1921__license__ : Final [str ]
2022__version__ : Final [str ]
23+ __all__ = [
24+ "debuglevel" ,
25+ "FailedToDecompressContent" ,
26+ "Http" ,
27+ "HttpLib2Error" ,
28+ "ProxyInfo" ,
29+ "RedirectLimit" ,
30+ "RedirectMissingLocation" ,
31+ "Response" ,
32+ "RETRIES" ,
33+ "UnimplementedDigestAuthOptionError" ,
34+ "UnimplementedHmacDigestAuthOptionError" ,
35+ ]
2136
2237def has_timeout (timeout : float | None ) -> bool : ...
2338
@@ -176,6 +191,7 @@ class Http:
176191 force_exception_to_status_code : bool
177192 timeout : float | None
178193 forward_authorization_headers : bool
194+ limit_kwargs : dict [str , float ]
179195 def __init__ (
180196 self ,
181197 cache : str | FileCache | None = None ,
@@ -185,6 +201,10 @@ class Http:
185201 disable_ssl_certificate_validation : bool = False ,
186202 tls_maximum_version = None ,
187203 tls_minimum_version = None ,
204+ decode_limit_hard : ConvertibleToInt | None = None ,
205+ decode_limit_safe : ConvertibleToInt | None = None ,
206+ decode_limit_ratio : ConvertibleToFloat | None = None ,
207+ decode_limit_chunk : ConvertibleToInt | None = None ,
188208 ) -> None : ...
189209 def close (self ) -> None : ...
190210 def add_credentials (self , name , password , domain : str = "" ) -> None : ...
@@ -202,16 +222,11 @@ class Response(dict[str, str | _T]):
202222 @property
203223 def dict (self ) -> Self : ...
204224
205- __all__ = [
206- "debuglevel" ,
207- "FailedToDecompressContent" ,
208- "Http" ,
209- "HttpLib2Error" ,
210- "ProxyInfo" ,
211- "RedirectLimit" ,
212- "RedirectMissingLocation" ,
213- "Response" ,
214- "RETRIES" ,
215- "UnimplementedDigestAuthOptionError" ,
216- "UnimplementedHmacDigestAuthOptionError" ,
217- ]
225+ @overload
226+ def try_value_or_env (
227+ to : type [_R ], value : Any , env_key : str , default : None = None # `value` type depends on what `to()` can convert
228+ ) -> _R | None : ...
229+ @overload
230+ def try_value_or_env (
231+ to : type [_R ], value : Any , env_key : str , default : _D = ... # `value` type depends on what `to()` can convert
232+ ) -> _R | _D : ...
0 commit comments