From 68613d2aa88d0f8ac4e5b013160d3ec05a7d1c0a Mon Sep 17 00:00:00 2001 From: donBarbos Date: Sun, 22 Jun 2025 09:30:22 +0400 Subject: [PATCH] [python-http-client] Remove from pyrightconfig --- pyrightconfig.stricter.json | 1 - .../python_http_client/client.pyi | 9 +++++---- .../python_http_client/exceptions.pyi | 16 ++++++++++------ 3 files changed, 15 insertions(+), 11 deletions(-) diff --git a/pyrightconfig.stricter.json b/pyrightconfig.stricter.json index 0f9e8a25856b..357b1b796700 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -86,7 +86,6 @@ "stubs/python-crontab", "stubs/python-datemath", "stubs/python-dateutil", - "stubs/python-http-client", "stubs/python-jose", "stubs/pytz/pytz/lazy.pyi", "stubs/pywin32", diff --git a/stubs/python-http-client/python_http_client/client.pyi b/stubs/python-http-client/python_http_client/client.pyi index f47cebc70bc8..aceb5f6cbaa8 100644 --- a/stubs/python-http-client/python_http_client/client.pyi +++ b/stubs/python-http-client/python_http_client/client.pyi @@ -1,16 +1,17 @@ from email.message import Message -from typing import Final +from http.client import HTTPResponse +from typing import Any, Final class Response: - def __init__(self, response) -> None: ... + def __init__(self, response: HTTPResponse) -> None: ... @property def status_code(self) -> int: ... @property - def body(self): ... + def body(self) -> bytes: ... @property def headers(self) -> Message: ... @property - def to_dict(self): ... + def to_dict(self) -> dict[str, Any] | None: ... # dict of response from API if body is not empty class Client: methods: Final[set[str]] diff --git a/stubs/python-http-client/python_http_client/exceptions.pyi b/stubs/python-http-client/python_http_client/exceptions.pyi index 4852c02d679d..d896698698c1 100644 --- a/stubs/python-http-client/python_http_client/exceptions.pyi +++ b/stubs/python-http-client/python_http_client/exceptions.pyi @@ -1,15 +1,19 @@ from email.message import Message -from typing import Final +from typing import Any, Final, overload +from urllib.error import HTTPError as _HTTPError class HTTPError(Exception): status_code: int reason: str - body: str + body: bytes headers: Message - def __init__(self, *args) -> None: ... - def __reduce__(self): ... + @overload + def __init__(self, status_code: int, reason: str, body: bytes, headers: Message, /) -> None: ... + @overload + def __init__(self, http_error: _HTTPError, /) -> None: ... + def __reduce__(self) -> tuple[type[HTTPError], tuple[int, str, bytes, Message]]: ... @property - def to_dict(self): ... + def to_dict(self) -> dict[str, Any]: ... # dict of response error from the API class BadRequestsError(HTTPError): ... class UnauthorizedError(HTTPError): ... @@ -25,4 +29,4 @@ class GatewayTimeoutError(HTTPError): ... err_dict: Final[dict[int, type[HTTPError]]] -def handle_error(error) -> HTTPError: ... +def handle_error(error: _HTTPError) -> HTTPError: ...