From 0085539df30b59d53e94980faddbf695800584a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Anton=20Gr=C3=BCbel?= Date: Thu, 8 Jul 2021 13:43:42 +0200 Subject: [PATCH] Add missing type hints in http.client (#5734) * Add missing type hints in http.client * Add http.client.HTTPConnection.response_class to exclude list --- stdlib/http/client.pyi | 8 +++++++- tests/stubtest_allowlists/py3_common.txt | 1 + 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/stdlib/http/client.pyi b/stdlib/http/client.pyi index 1914daf1d..59e64d873 100644 --- a/stdlib/http/client.pyi +++ b/stdlib/http/client.pyi @@ -90,7 +90,8 @@ NETWORK_AUTHENTICATION_REQUIRED: int responses: Dict[int, str] -class HTTPMessage(email.message.Message): ... +class HTTPMessage(email.message.Message): + def getallmatchingheaders(self, name: str) -> list[str]: ... # undocumented def parse_headers(fp: io.BufferedIOBase, _class: Callable[[], email.message.Message] = ...) -> HTTPMessage: ... @@ -103,6 +104,7 @@ class HTTPResponse(io.BufferedIOBase, BinaryIO): status: int reason: str def __init__(self, sock: socket, debuglevel: int = ..., method: Optional[str] = ..., url: Optional[str] = ...) -> None: ... + def peek(self, n: int = ...) -> bytes: ... def read(self, amt: Optional[int] = ...) -> bytes: ... def read1(self, n: int = ...) -> bytes: ... def readinto(self, b: WriteableBuffer) -> int: ... @@ -142,6 +144,10 @@ class _HTTPConnectionProtocol(Protocol): ) -> HTTPConnection: ... class HTTPConnection: + auto_open: int = ... # undocumented + debuglevel: int = ... + default_port: int = ... # undocumented + response_class: Type[HTTPResponse] = ... # undocumented timeout: Optional[float] host: str port: int diff --git a/tests/stubtest_allowlists/py3_common.txt b/tests/stubtest_allowlists/py3_common.txt index 7e66b97e6..d513aad2f 100644 --- a/tests/stubtest_allowlists/py3_common.txt +++ b/tests/stubtest_allowlists/py3_common.txt @@ -88,6 +88,7 @@ enum.EnumMeta.__call__ enum.EnumMeta.__new__ http.HTTPStatus.description # set in __new__ http.HTTPStatus.phrase # set in __new__ +http.client.HTTPConnection.response_class # the actual type at runtime is abc.ABCMeta imaplib.IMAP4_SSL.ssl # Dependent on SSL existence importlib.abc.FileLoader.get_filename # Wrapped with _check_name decorator which changes runtime signature importlib.abc.FileLoader.load_module # Wrapped with _check_name decorator which changes runtime signature