Fix return types in urllib.request (#2389)

* Tighten return types of URL handlers

* urlopen() etc. return a modified HTTPResponse

* Add missing methods to HTTPResponse
This commit is contained in:
Sebastian Rittau
2018-09-19 01:45:09 +02:00
committed by Rebecca Chen
parent d70a6cbcc0
commit 9827132d5b
2 changed files with 19 additions and 10 deletions

View File

@@ -104,6 +104,9 @@ if sys.version_info >= (3, 5):
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[types.TracebackType]) -> bool: ...
def info(self) -> email.message.Message: ...
def geturl(self) -> str: ...
def getcode(self) -> int: ...
else:
class HTTPResponse(io.RawIOBase, BinaryIO): # type: ignore
msg = ... # type: HTTPMessage
@@ -126,6 +129,9 @@ else:
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[types.TracebackType]) -> bool: ...
def info(self) -> email.message.Message: ...
def geturl(self) -> str: ...
def getcode(self) -> int: ...
class HTTPConnection:
if sys.version_info >= (3, 7):