From 313a835bea3bc5d43f0721c1197d403495773b87 Mon Sep 17 00:00:00 2001 From: Teddy Sudol Date: Thu, 28 May 2020 04:48:27 -0700 Subject: [PATCH] Add missing definitions for urllib/response.pyi (#4118) Co-authored-by: Jelle Zijlstra --- stdlib/3/urllib/response.pyi | 11 ++++++++++- tests/stubtest_whitelists/py3_common.txt | 2 -- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/stdlib/3/urllib/response.pyi b/stdlib/3/urllib/response.pyi index dca0efacc..970fd7437 100644 --- a/stdlib/3/urllib/response.pyi +++ b/stdlib/3/urllib/response.pyi @@ -1,12 +1,14 @@ # private module, we only expose what's needed -from typing import BinaryIO, Iterable, List, Mapping, Optional, Type, TypeVar +from typing import Any, BinaryIO, Callable, IO, Iterable, List, Mapping, Optional, Tuple, Type, TypeVar from email.message import Message from types import TracebackType _AIUT = TypeVar("_AIUT", bound=addbase) class addbase(BinaryIO): + fp: IO[bytes] + def __init__(self, fp: IO[bytes]) -> None: ... def __enter__(self: _AIUT) -> _AIUT: ... def __exit__(self, type: Optional[Type[BaseException]], value: Optional[BaseException], traceback: Optional[TracebackType]) -> None: ... def __iter__(self: _AIUT) -> _AIUT: ... @@ -31,12 +33,19 @@ class addbase(BinaryIO): def write(self, s: bytes) -> int: ... def writelines(self, lines: Iterable[bytes]) -> None: ... +class addclosehook(addbase): + closehook: Callable[..., object] + hookargs: Tuple[Any, ...] + def __init__(self, fp: IO[bytes], closehook: Callable[..., object], *hookargs: Any) -> None: ... + class addinfo(addbase): headers: Message + def __init__(self, fp: IO[bytes], headers: Message) -> None: ... def info(self) -> Message: ... class addinfourl(addinfo): url: str code: int + def __init__(self, fp: IO[bytes], headers: Message, url: str, code: Optional[int] = ...) -> None: ... def geturl(self) -> str: ... def getcode(self) -> int: ... diff --git a/tests/stubtest_whitelists/py3_common.txt b/tests/stubtest_whitelists/py3_common.txt index 6be6d36fc..3890ae038 100644 --- a/tests/stubtest_whitelists/py3_common.txt +++ b/tests/stubtest_whitelists/py3_common.txt @@ -493,8 +493,6 @@ urllib.error.URLError.__init__ urllib.parse._DefragResultBase.__new__ urllib.request.BaseHandler.http_error_nnn urllib.request.HTTPPasswordMgrWithPriorAuth.__init__ -urllib.response.addinfo.__init__ -urllib.response.addinfourl.__init__ urllib.robotparser.RobotFileParser.can_fetch warnings.catch_warnings.__init__ weakref.CallableProxyType.__getattr__