Skip to content

Commit

Permalink
Add stubs for python-http-client (#12626)
Browse files Browse the repository at this point in the history
  • Loading branch information
ajimenez2712 authored Sep 9, 2024
1 parent 089953e commit 65170f4
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 0 deletions.
1 change: 1 addition & 0 deletions pyrightconfig.stricter.json
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,7 @@
"stubs/PyMySQL",
"stubs/python-crontab",
"stubs/python-dateutil",
"stubs/python-http-client",
"stubs/python-jose",
"stubs/pywin32",
"stubs/pyxdg",
Expand Down
1 change: 1 addition & 0 deletions stubs/python-http-client/@tests/stubtest_allowlist.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
python_http_client.version_file
2 changes: 2 additions & 0 deletions stubs/python-http-client/METADATA.toml
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
version = "3.3.7"
upstream_repository = "https://github.com/sendgrid/python-http-client"
20 changes: 20 additions & 0 deletions stubs/python-http-client/python_http_client/__init__.pyi
Original file line number Diff line number Diff line change
@@ -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]
31 changes: 31 additions & 0 deletions stubs/python-http-client/python_http_client/client.pyi
Original file line number Diff line number Diff line change
@@ -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: ...
28 changes: 28 additions & 0 deletions stubs/python-http-client/python_http_client/exceptions.pyi
Original file line number Diff line number Diff line change
@@ -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: ...

0 comments on commit 65170f4

Please sign in to comment.