Skip to content
Open
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
72 changes: 46 additions & 26 deletions stubs/httplib2/httplib2/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import http.client
import re
from _ssl import _PasswordType
from _typeshed import ConvertibleToFloat, ConvertibleToInt, FloatInt, Incomplete, MaybeNone, StrOrBytesPath
from collections.abc import Generator
from ssl import _SSLMethod
from typing import Any, ClassVar, Final, Literal, TypeVar, overload
from collections.abc import Callable, Generator, Sequence
from ssl import TLSVersion, _SSLMethod
from typing import Any, ClassVar, Final, Literal, TypeAlias, TypeVar, overload
from typing_extensions import Self

from .error import *
Expand All @@ -15,6 +15,8 @@ _T = TypeVar("_T", default=str)
_R = TypeVar("_R")
_D = TypeVar("_D")

_ProxyInfoFactory: TypeAlias = Callable[[Literal["http", "https"]], ProxyInfo | None]

__author__: Final[str]
__copyright__: Final[str]
__contributors__: Final[list[str]]
Expand Down Expand Up @@ -127,28 +129,47 @@ class KeyCerts(Credentials):
class AllHosts: ...

class ProxyInfo:
bypass_hosts: Incomplete
bypass_hosts: Sequence[str] | type[AllHosts]
proxy_type: int
proxy_host: str | None
proxy_port: int | None
proxy_rdns: bool
proxy_user: str | None
proxy_pass: str | None
proxy_headers: Incomplete | None # stored but never sent by httplib2
def __init__(
self, proxy_type, proxy_host, proxy_port, proxy_rdns: bool = True, proxy_user=None, proxy_pass=None, proxy_headers=None
self,
proxy_type: int,
proxy_host: str | None,
proxy_port: int | None,
proxy_rdns: bool = True,
proxy_user: str | bytes | None = None,
proxy_pass: str | bytes | None = None,
proxy_headers=None,
) -> None: ...
def astuple(self): ...
def isgood(self): ...
def applies_to(self, hostname): ...
def bypass_host(self, hostname): ...
def astuple(self) -> tuple[int, str | None, int | None, bool, str | None, str | None, Incomplete | None]: ...
def isgood(self) -> bool | None: ... # None if PySocks is not installed
def applies_to(self, hostname: str) -> bool: ...
def bypass_host(self, hostname: str) -> bool: ...

def proxy_info_from_environment(method: Literal["http", "https"] = "http") -> ProxyInfo | None: ...
def proxy_info_from_url(url: str, method: Literal["http", "https"] = "http", noproxy: str | None = None) -> ProxyInfo: ...

class HTTPConnectionWithTimeout(http.client.HTTPConnection):
proxy_info: Incomplete
def __init__(self, host, port=None, timeout=None, proxy_info=None) -> None: ...
sock: Incomplete
proxy_info: ProxyInfo | None
def __init__(
self,
host: str,
port: int | None = None,
timeout: FloatInt | None = None,
proxy_info: ProxyInfo | _ProxyInfoFactory | None = None,
) -> None: ...
def connect(self) -> None: ...

class HTTPSConnectionWithTimeout(http.client.HTTPSConnection):
disable_ssl_certificate_validation: bool
ca_certs: StrOrBytesPath | None
proxy_info: Incomplete
proxy_info: ProxyInfo | None
key_file: StrOrBytesPath | None
cert_file: StrOrBytesPath | None
key_password: _PasswordType | None
Expand All @@ -159,25 +180,24 @@ class HTTPSConnectionWithTimeout(http.client.HTTPSConnection):
key_file: StrOrBytesPath | None = None,
cert_file: StrOrBytesPath | None = None,
timeout: FloatInt | None = None,
proxy_info=None,
proxy_info: ProxyInfo | _ProxyInfoFactory | None = None,
ca_certs: StrOrBytesPath | None = None,
disable_ssl_certificate_validation: bool = False,
tls_maximum_version=None,
tls_minimum_version=None,
tls_maximum_version: TLSVersion | str | None = None,
tls_minimum_version: TLSVersion | str | None = None,
key_password: _PasswordType | None = None,
) -> None: ...
sock: Incomplete
def connect(self) -> None: ...

SCHEME_TO_CONNECTION: Final[dict[Literal["http", "https"], type[http.client.HTTPConnection]]]

class Http:
proxy_info: Incomplete
ca_certs: Incomplete
proxy_info: ProxyInfo | _ProxyInfoFactory | None
ca_certs: StrOrBytesPath | None
disable_ssl_certificate_validation: bool
tls_maximum_version: Incomplete
tls_minimum_version: Incomplete
connections: Incomplete
tls_maximum_version: TLSVersion | str | None
tls_minimum_version: TLSVersion | str | None
connections: dict[str, http.client.HTTPConnection]
cache: FileCache
credentials: Credentials
certificates: KeyCerts
Expand All @@ -196,11 +216,11 @@ class Http:
self,
cache: str | FileCache | None = None,
timeout: FloatInt | None = None,
proxy_info=...,
ca_certs=None,
proxy_info: ProxyInfo | _ProxyInfoFactory | None = ...,
ca_certs: StrOrBytesPath | None = None,
disable_ssl_certificate_validation: bool = False,
tls_maximum_version=None,
tls_minimum_version=None,
tls_maximum_version: TLSVersion | str | None = None,
tls_minimum_version: TLSVersion | str | None = None,
decode_limit_hard: ConvertibleToInt | None = None,
decode_limit_safe: ConvertibleToInt | None = None,
decode_limit_ratio: ConvertibleToFloat | None = None,
Expand Down
Loading