Add stubs for python-http-client (#12626)

This commit is contained in:
Alberto Jiménez López
2024-09-08 21:08:38 -06:00
committed by GitHub
parent 089953ed84
commit 65170f4a2e
6 changed files with 83 additions and 0 deletions

View File

@@ -0,0 +1 @@
python_http_client.version_file

View File

@@ -0,0 +1,2 @@
version = "3.3.7"
upstream_repository = "https://github.com/sendgrid/python-http-client"

View File

@@ -0,0 +1,20 @@
from typing import Final
from .client import Client as Client
from .exceptions import (
BadRequestsError as BadRequestsError,
ForbiddenError as ForbiddenError,
GatewayTimeoutError as GatewayTimeoutError,
HTTPError as HTTPError,
InternalServerError as InternalServerError,
MethodNotAllowedError as MethodNotAllowedError,
NotFoundError as NotFoundError,
PayloadTooLargeError as PayloadTooLargeError,
ServiceUnavailableError as ServiceUnavailableError,
TooManyRequestsError as TooManyRequestsError,
UnauthorizedError as UnauthorizedError,
UnsupportedMediaTypeError as UnsupportedMediaTypeError,
)
dir_path: Final[str]
__version__: Final[str]

View File

@@ -0,0 +1,31 @@
from email.message import Message
from typing import Final
class Response:
def __init__(self, response) -> None: ...
@property
def status_code(self) -> int: ...
@property
def body(self): ...
@property
def headers(self) -> Message: ...
@property
def to_dict(self): ...
class Client:
methods: Final[set[str]]
host: str
request_headers: dict[str, str]
append_slash: bool
timeout: int
def __init__(
self,
host: str,
request_headers: dict[str, str] | None = None,
version: int | None = None,
url_path: list[str] | None = None,
append_slash: bool = False,
timeout: int | None = None,
) -> None: ...
def _(self, name: str) -> Client: ...
def __getattr__(self, name: str) -> Client | Response: ...

View File

@@ -0,0 +1,28 @@
from email.message import Message
from typing import Final
class HTTPError(Exception):
status_code: int
reason: str
body: str
headers: Message
def __init__(self, *args) -> None: ...
def __reduce__(self): ...
@property
def to_dict(self): ...
class BadRequestsError(HTTPError): ...
class UnauthorizedError(HTTPError): ...
class ForbiddenError(HTTPError): ...
class NotFoundError(HTTPError): ...
class MethodNotAllowedError(HTTPError): ...
class PayloadTooLargeError(HTTPError): ...
class UnsupportedMediaTypeError(HTTPError): ...
class TooManyRequestsError(HTTPError): ...
class InternalServerError(HTTPError): ...
class ServiceUnavailableError(HTTPError): ...
class GatewayTimeoutError(HTTPError): ...
err_dict: Final[dict[int, type[HTTPError]]]
def handle_error(error) -> HTTPError: ...