Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion stubs/httplib2/METADATA.toml
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
version = "0.31.2"
version = "0.32.0"
upstream-repository = "https://github.com/httplib2/httplib2"
45 changes: 30 additions & 15 deletions stubs/httplib2/httplib2/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -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: ...

Expand Down Expand Up @@ -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,
Expand All @@ -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: ...
Expand All @@ -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: ...
52 changes: 52 additions & 0 deletions stubs/httplib2/httplib2/decode.pyi
Original file line number Diff line number Diff line change
@@ -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: ...