From c6ad6f47daea83c592555571f592005669bb2dff Mon Sep 17 00:00:00 2001 From: donbarbos Date: Sun, 19 Jul 2026 19:31:54 +0400 Subject: [PATCH] [httplib2] Update to 0.32.0 Closes: #15951 --- stubs/httplib2/METADATA.toml | 2 +- stubs/httplib2/httplib2/__init__.pyi | 45 ++++++++++++++++-------- stubs/httplib2/httplib2/decode.pyi | 52 ++++++++++++++++++++++++++++ 3 files changed, 83 insertions(+), 16 deletions(-) create mode 100644 stubs/httplib2/httplib2/decode.pyi diff --git a/stubs/httplib2/METADATA.toml b/stubs/httplib2/METADATA.toml index bca46d69b832..69b14a50a93a 100644 --- a/stubs/httplib2/METADATA.toml +++ b/stubs/httplib2/METADATA.toml @@ -1,2 +1,2 @@ -version = "0.31.2" +version = "0.32.0" upstream-repository = "https://github.com/httplib2/httplib2" diff --git a/stubs/httplib2/httplib2/__init__.pyi b/stubs/httplib2/httplib2/__init__.pyi index 0961d41d6f6c..7be7c15e3ea0 100644 --- a/stubs/httplib2/httplib2/__init__.pyi +++ b/stubs/httplib2/httplib2/__init__.pyi @@ -3,21 +3,36 @@ import email.message import http.client import re from _ssl import _PasswordType -from _typeshed import Incomplete, MaybeNone, StrOrBytesPath +from _typeshed import ConvertibleToFloat, ConvertibleToInt, Incomplete, MaybeNone, StrOrBytesPath from collections.abc import Generator from ssl import _SSLMethod -from typing import ClassVar, Final, Literal, TypeVar +from typing import Any, ClassVar, Final, Literal, TypeVar, overload from typing_extensions import Self from .error import * _T = TypeVar("_T", default=str) +_R = TypeVar("_R") +_D = TypeVar("_D") __author__: Final[str] __copyright__: Final[str] __contributors__: Final[list[str]] __license__: Final[str] __version__: Final[str] +__all__ = [ + "debuglevel", + "FailedToDecompressContent", + "Http", + "HttpLib2Error", + "ProxyInfo", + "RedirectLimit", + "RedirectMissingLocation", + "Response", + "RETRIES", + "UnimplementedDigestAuthOptionError", + "UnimplementedHmacDigestAuthOptionError", +] def has_timeout(timeout: float | None) -> bool: ... @@ -176,6 +191,7 @@ class Http: force_exception_to_status_code: bool timeout: float | None forward_authorization_headers: bool + limit_kwargs: dict[str, float] def __init__( self, cache: str | FileCache | None = None, @@ -185,6 +201,10 @@ class Http: disable_ssl_certificate_validation: bool = False, tls_maximum_version=None, tls_minimum_version=None, + decode_limit_hard: ConvertibleToInt | None = None, + decode_limit_safe: ConvertibleToInt | None = None, + decode_limit_ratio: ConvertibleToFloat | None = None, + decode_limit_chunk: ConvertibleToInt | None = None, ) -> None: ... def close(self) -> None: ... def add_credentials(self, name, password, domain: str = "") -> None: ... @@ -202,16 +222,11 @@ class Response(dict[str, str | _T]): @property def dict(self) -> Self: ... -__all__ = [ - "debuglevel", - "FailedToDecompressContent", - "Http", - "HttpLib2Error", - "ProxyInfo", - "RedirectLimit", - "RedirectMissingLocation", - "Response", - "RETRIES", - "UnimplementedDigestAuthOptionError", - "UnimplementedHmacDigestAuthOptionError", -] +@overload +def try_value_or_env( + to: type[_R], value: Any, env_key: str, default: None = None # `value` type depends on what `to()` can convert +) -> _R | None: ... +@overload +def try_value_or_env( + to: type[_R], value: Any, env_key: str, default: _D = ... # `value` type depends on what `to()` can convert +) -> _R | _D: ... diff --git a/stubs/httplib2/httplib2/decode.pyi b/stubs/httplib2/httplib2/decode.pyi new file mode 100644 index 000000000000..9c9e14ca1601 --- /dev/null +++ b/stubs/httplib2/httplib2/decode.pyi @@ -0,0 +1,52 @@ +from typing import Final, Protocol + +class DecodeRatioError(Exception): ... +class DecodeLimitError(Exception): ... + +class DecoderProtocol(Protocol): + @property + def needs_input(self) -> bool: ... + def decode(self, b: bytes) -> bytes: ... + def flush(self) -> bytes: ... + def consume_bytes(self, data: bytes, chunk_size: int = 65536) -> bytes: ... + +class ZlibDecoder(DecoderProtocol): + __slots__ = ("_decoder",) + WBITS_DEFLATE: Final = -15 + WBITS_ZLIB: Final = 15 + WBITS_GZIP: Final = 31 + WBITS_AUTO_GZIP_ZLIB: Final = 47 + + def __init__(self, wbits: int = 47): ... + @property + def needs_input(self) -> bool: ... + def decode(self, b: bytes) -> bytes: ... + def flush(self) -> bytes: ... + +def DeflateDecoder() -> ZlibDecoder: ... + +class LimitDecoder(DecoderProtocol): + __slots__ = ( + "_decoder", + "_ratio", + "_chunk_size", + "_safe_limit", + "_hard_limit", + "_consumed_length", + "_output_length", + "_input_buffer", + "_flushed", + ) + + def __init__( + self, + decoder: DecoderProtocol, + ratio: float = 100, + chunk_size: int = 65536, + safe_limit: int = 10485760, + hard_limit: int = ..., + ) -> None: ... + @property + def needs_input(self) -> bool: ... + def decode(self, b: bytes) -> bytes: ... + def flush(self) -> bytes: ...