Skip to content

[httplib2] Improve stubs #14249

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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
170 changes: 101 additions & 69 deletions stubs/httplib2/httplib2/__init__.pyi
Original file line number Diff line number Diff line change
@@ -1,57 +1,84 @@
import email.message
import http.client
import re
from _ssl import _PasswordType
from _typeshed import Incomplete, MaybeNone, StrOrBytesPath
from collections.abc import Generator
from typing import Any, ClassVar
from ssl import _SSLMethod
from typing import ClassVar, Final, Literal, TypeVar
from typing_extensions import Self

from .error import *

__author__: str
__copyright__: str
__contributors__: list[str]
__license__: str
__version__: str
_T = TypeVar("_T", default=str)

debuglevel: int
RETRIES: int
__author__: Final[str]
__copyright__: Final[str]
__contributors__: Final[list[str]]
__license__: Final[str]
__version__: Final[str]

def has_timeout(timeout: float | None) -> bool: ...

debuglevel: Final[int]
RETRIES: Final[int]
DEFAULT_MAX_REDIRECTS: Final[int]
HOP_BY_HOP: Final[list[str]]
SAFE_METHODS: Final[tuple[str, ...]]
REDIRECT_CODES: Final[frozenset[int]]
CA_CERTS: Final[str]
DEFAULT_TLS_VERSION: Final[_SSLMethod]
URI: Final[re.Pattern[str]]

def parse_uri(uri: str) -> tuple[str | MaybeNone, str | MaybeNone, str | MaybeNone, str | MaybeNone, str | MaybeNone]: ...
def urlnorm(uri: str) -> tuple[str | MaybeNone, str | MaybeNone, str | MaybeNone, str | MaybeNone]: ...

re_url_scheme: Final[re.Pattern[str]]
re_unsafe: Final[re.Pattern[str]]

def safename(filename: str | bytes) -> str: ...

NORMALIZE_SPACE: Final[re.Pattern[str]]
USE_WWW_AUTH_STRICT_PARSING: Final[int]

class Authentication:
path: Any
host: Any
credentials: Any
http: Any
def __init__(self, credentials, host, request_uri, headers, response, content, http) -> None: ...
def depth(self, request_uri): ...
def inscope(self, host, request_uri): ...
path: Incomplete
host: Incomplete
credentials: Incomplete
http: Incomplete
def __init__(self, credentials, host, request_uri: str, headers, response, content, http) -> None: ...
def depth(self, request_uri: str) -> int: ...
def inscope(self, host: str, request_uri: str) -> bool: ...
def request(self, method, request_uri, headers, content) -> None: ...
def response(self, response, content): ...
def __eq__(self, auth): ...
def __ne__(self, auth): ...
def __lt__(self, auth): ...
def __gt__(self, auth): ...
def __le__(self, auth): ...
def __ge__(self, auth): ...
def response(self, response, content) -> bool: ...
def __eq__(self, auth: object) -> bool: ...
def __ne__(self, auth: object) -> bool: ...
def __lt__(self, auth: object) -> bool: ...
def __gt__(self, auth: object) -> bool: ...
def __le__(self, auth: object) -> bool: ...
def __ge__(self, auth: object) -> bool: ...
def __bool__(self) -> bool: ...

class BasicAuthentication(Authentication):
def __init__(self, credentials, host, request_uri, headers, response, content, http) -> None: ...
def request(self, method, request_uri, headers, content) -> None: ...

class DigestAuthentication(Authentication):
challenge: Any
A1: Any
challenge: Incomplete
A1: Incomplete
def __init__(self, credentials, host, request_uri, headers, response, content, http) -> None: ...
def request(self, method, request_uri, headers, content, cnonce=None): ...
def response(self, response, content): ...
def response(self, response, content) -> bool: ...

class HmacDigestAuthentication(Authentication):
challenge: Any
hashmod: Any
pwhashmod: Any
key: Any
challenge: Incomplete
hashmod: Incomplete
pwhashmod: Incomplete
key: Incomplete
__author__: ClassVar[str]
def __init__(self, credentials, host, request_uri, headers, response, content, http) -> None: ...
def request(self, method, request_uri, headers, content) -> None: ...
def response(self, response, content): ...
def response(self, response, content) -> bool: ...

class WsseAuthentication(Authentication):
def __init__(self, credentials, host, request_uri, headers, response, content, http) -> None: ...
Expand All @@ -63,15 +90,15 @@ class GoogleLoginAuthentication(Authentication):
def request(self, method, request_uri, headers, content) -> None: ...

class FileCache:
cache: Any
safe: Any
cache: Incomplete
safe: Incomplete
def __init__(self, cache, safe=...) -> None: ...
def get(self, key): ...
def set(self, key, value) -> None: ...
def delete(self, key) -> None: ...

class Credentials:
credentials: Any
credentials: Incomplete
def __init__(self) -> None: ...
def add(self, name, password, domain: str = "") -> None: ...
def clear(self) -> None: ...
Expand All @@ -84,7 +111,7 @@ class KeyCerts(Credentials):
class AllHosts: ...

class ProxyInfo:
bypass_hosts: Any
bypass_hosts: Incomplete
def __init__(
self, proxy_type, proxy_host, proxy_port, proxy_rdns: bool = True, proxy_user=None, proxy_pass=None, proxy_headers=None
) -> None: ...
Expand All @@ -93,60 +120,65 @@ class ProxyInfo:
def applies_to(self, hostname): ...
def bypass_host(self, hostname): ...

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: Any
proxy_info: Incomplete
def __init__(self, host, port=None, timeout=None, proxy_info=None) -> None: ...
sock: Any
sock: Incomplete
def connect(self) -> None: ...

class HTTPSConnectionWithTimeout(http.client.HTTPSConnection):
disable_ssl_certificate_validation: Any
ca_certs: Any
proxy_info: Any
key_file: Any
cert_file: Any
key_password: Any
disable_ssl_certificate_validation: bool
ca_certs: StrOrBytesPath | None
proxy_info: Incomplete
key_file: StrOrBytesPath | None
cert_file: StrOrBytesPath | None
key_password: _PasswordType | None
def __init__(
self,
host,
port=None,
key_file=None,
cert_file=None,
timeout=None,
host: str,
port: int | None = None,
key_file: StrOrBytesPath | None = None,
cert_file: StrOrBytesPath | None = None,
timeout: float | None = None,
proxy_info=None,
ca_certs=None,
ca_certs: StrOrBytesPath | None = None,
disable_ssl_certificate_validation: bool = False,
tls_maximum_version=None,
tls_minimum_version=None,
key_password=None,
key_password: _PasswordType | None = None,
) -> None: ...
sock: Any
sock: Incomplete
def connect(self) -> None: ...

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

class Http:
proxy_info: Any
ca_certs: Any
disable_ssl_certificate_validation: Any
tls_maximum_version: Any
tls_minimum_version: Any
connections: Any
cache: Any
credentials: Any
certificates: Any
authorizations: Any
proxy_info: Incomplete
ca_certs: Incomplete
disable_ssl_certificate_validation: bool
tls_maximum_version: Incomplete
tls_minimum_version: Incomplete
connections: Incomplete
cache: FileCache
credentials: Credentials
certificates: KeyCerts
authorizations: list[Authentication]
follow_redirects: bool
redirect_codes: Any
optimistic_concurrency_methods: Any
safe_methods: Any
redirect_codes: frozenset[int]
optimistic_concurrency_methods: list[str]
safe_methods: list[str]
follow_all_redirects: bool
ignore_etag: bool
force_exception_to_status_code: bool
timeout: Any
timeout: float | None
forward_authorization_headers: bool
def __init__(
self,
cache=None,
timeout=None,
cache: str | FileCache | None = None,
timeout: float | None = None,
proxy_info=...,
ca_certs=None,
disable_ssl_certificate_validation: bool = False,
Expand All @@ -159,13 +191,13 @@ class Http:
def clear_credentials(self) -> None: ...
def request(self, uri, method: str = "GET", body=None, headers=None, redirections=5, connection_type=None): ...

class Response(dict[str, Any]):
class Response(dict[str, str | _T]):
fromcache: bool
version: int
status: int
reason: str
previous: Any
def __init__(self, info) -> None: ...
previous: Response[_T] | None
def __init__(self, info: http.client.HTTPResponse | email.message.Message | dict[str, _T]) -> None: ...
@property
def dict(self) -> Self: ...

Expand Down
33 changes: 18 additions & 15 deletions stubs/httplib2/httplib2/auth.pyi
Original file line number Diff line number Diff line change
@@ -1,16 +1,19 @@
from typing import Any
import re
from _typeshed import Incomplete
from collections.abc import Callable
from typing import Final

UNQUOTE_PAIRS: Any
unquote: Any
tchar: Any
token: Any
token68: Any
quoted_string: Any
auth_param_name: Any
auth_param: Any
params: Any
scheme: Any
challenge: Any
authentication_info: Any
www_authenticate: Any
downcaseTokens: Any
UNQUOTE_PAIRS: Final[re.Pattern[str]]
unquote: Callable[..., str]
tchar: Final[str]
token: Incomplete # types from pyparsing library
token68: Incomplete
quoted_string: Incomplete
auth_param_name: Incomplete
auth_param: Incomplete
params: Incomplete
scheme: Incomplete
challenge: Incomplete
authentication_info: Incomplete
www_authenticate: Incomplete
downcaseTokens: Incomplete
11 changes: 6 additions & 5 deletions stubs/httplib2/httplib2/certs.pyi
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
from typing import Any
from collections.abc import Callable
from typing import Final

certifi_available: bool
certifi_where: Any
certifi_where: Callable[[], str] | None
custom_ca_locater_available: bool
custom_ca_locater_where: Any
BUILTIN_CA_CERTS: Any
custom_ca_locater_where: Callable[..., str] | None
BUILTIN_CA_CERTS: Final[str]

def where(): ...
def where() -> str: ...
12 changes: 8 additions & 4 deletions stubs/httplib2/httplib2/error.pyi
Original file line number Diff line number Diff line change
@@ -1,11 +1,15 @@
from typing import Any
from _typeshed import Incomplete

from httplib2 import Response

class HttpLib2Error(Exception): ...

class HttpLib2ErrorWithResponse(HttpLib2Error):
response: Any
content: Any
def __init__(self, desc, response, content) -> None: ...
response: Response | dict[str, Incomplete] | None
content: str | bytes | None
def __init__(
self, desc: str | None, response: Response | dict[str, Incomplete] | None, content: str | bytes | None
) -> None: ...

class RedirectMissingLocation(HttpLib2ErrorWithResponse): ...
class RedirectLimit(HttpLib2ErrorWithResponse): ...
Expand Down
20 changes: 11 additions & 9 deletions stubs/httplib2/httplib2/iri2uri.pyi
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
from typing import Any
from typing import Final, TypeVar

__author__: str
__copyright__: str
__contributors__: list[str]
__version__: str
__license__: str
_T = TypeVar("_T")

escape_range: Any
__author__: Final[str]
__copyright__: Final[str]
__contributors__: Final[list[str]]
__version__: Final[str]
__license__: Final[str]

def encode(c): ...
def iri2uri(uri): ...
escape_range: list[tuple[int, int]]

def encode(c: str) -> str: ...
def iri2uri(uri: _T) -> _T: ...
Loading