Skip to content

Commit d2d55a1

Browse files
authored
[httplib2] Update to 0.32.0 (#16038)
1 parent f5aa7d5 commit d2d55a1

3 files changed

Lines changed: 83 additions & 16 deletions

File tree

stubs/httplib2/METADATA.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
1-
version = "0.31.2"
1+
version = "0.32.0"
22
upstream-repository = "https://github.com/httplib2/httplib2"

stubs/httplib2/httplib2/__init__.pyi

Lines changed: 30 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,36 @@ import email.message
33
import http.client
44
import re
55
from _ssl import _PasswordType
6-
from _typeshed import Incomplete, MaybeNone, StrOrBytesPath
6+
from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, MaybeNone, StrOrBytesPath
77
from collections.abc import Generator
88
from ssl import _SSLMethod
9-
from typing import ClassVar, Final, Literal, TypeVar
9+
from typing import Any, ClassVar, Final, Literal, TypeVar, overload
1010
from typing_extensions import Self
1111

1212
from .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

2237
def 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: ...

stubs/httplib2/httplib2/decode.pyi

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
from typing import Final, Protocol
2+
3+
class DecodeRatioError(Exception): ...
4+
class DecodeLimitError(Exception): ...
5+
6+
class DecoderProtocol(Protocol):
7+
@property
8+
def needs_input(self) -> bool: ...
9+
def decode(self, b: bytes) -> bytes: ...
10+
def flush(self) -> bytes: ...
11+
def consume_bytes(self, data: bytes, chunk_size: int = 65536) -> bytes: ...
12+
13+
class ZlibDecoder(DecoderProtocol):
14+
__slots__ = ("_decoder",)
15+
WBITS_DEFLATE: Final = -15
16+
WBITS_ZLIB: Final = 15
17+
WBITS_GZIP: Final = 31
18+
WBITS_AUTO_GZIP_ZLIB: Final = 47
19+
20+
def __init__(self, wbits: int = 47): ...
21+
@property
22+
def needs_input(self) -> bool: ...
23+
def decode(self, b: bytes) -> bytes: ...
24+
def flush(self) -> bytes: ...
25+
26+
def DeflateDecoder() -> ZlibDecoder: ...
27+
28+
class LimitDecoder(DecoderProtocol):
29+
__slots__ = (
30+
"_decoder",
31+
"_ratio",
32+
"_chunk_size",
33+
"_safe_limit",
34+
"_hard_limit",
35+
"_consumed_length",
36+
"_output_length",
37+
"_input_buffer",
38+
"_flushed",
39+
)
40+
41+
def __init__(
42+
self,
43+
decoder: DecoderProtocol,
44+
ratio: float = 100,
45+
chunk_size: int = 65536,
46+
safe_limit: int = 10485760,
47+
hard_limit: int = ...,
48+
) -> None: ...
49+
@property
50+
def needs_input(self) -> bool: ...
51+
def decode(self, b: bytes) -> bytes: ...
52+
def flush(self) -> bytes: ...

0 commit comments

Comments
 (0)