From 98844c3ba9bf24552afc0dc52bbcc6b2d4311bfa Mon Sep 17 00:00:00 2001 From: Semyon Moroz Date: Mon, 7 Jul 2025 12:26:48 +0000 Subject: [PATCH] [python-http-client] Remove from pyrightconfig (#14321) --- 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 8874b6dde..c8897dca0 100644 --- a/pyrightconfig.stricter.json +++ b/pyrightconfig.stricter.json @@ -83,7 +83,6 @@ "stubs/PyMySQL", "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 f47cebc70..aceb5f6cb 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 4852c02d6..d89669869 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: ...