Make http.client.HTTPResponse a BinaryIO (#2218)

Fixes #2189.

The errors from mypy are a false positive (see python/mypy#5027).
This commit is contained in:
Jelle Zijlstra
2018-06-12 09:20:24 -07:00
committed by Guido van Rossum
parent 6bbf3d89eb
commit de86f15fa0

View File

@@ -2,6 +2,7 @@ from typing import (
Any, Dict, IO, Iterable, List, Iterator, Mapping, Optional, Tuple, Type, TypeVar,
Union,
overload,
BinaryIO,
)
import email.message
import io
@@ -79,7 +80,8 @@ responses = ... # type: Dict[int, str]
class HTTPMessage(email.message.Message): ...
if sys.version_info >= (3, 5):
class HTTPResponse(io.BufferedIOBase):
# Ignore errors to work around python/mypy#5027
class HTTPResponse(io.BufferedIOBase, BinaryIO): # type: ignore
msg = ... # type: HTTPMessage
headers = ... # type: HTTPMessage
version = ... # type: int
@@ -103,7 +105,7 @@ if sys.version_info >= (3, 5):
exc_val: Optional[BaseException],
exc_tb: Optional[types.TracebackType]) -> bool: ...
else:
class HTTPResponse:
class HTTPResponse(BinaryIO):
msg = ... # type: HTTPMessage
headers = ... # type: HTTPMessage
version = ... # type: int
@@ -122,8 +124,8 @@ else:
def fileno(self) -> int: ...
def __iter__(self) -> Iterator[bytes]: ...
def __enter__(self) -> 'HTTPResponse': ...
def __exit__(self, exc_type: Optional[type],
exc_val: Optional[Exception],
def __exit__(self, exc_type: Optional[Type[BaseException]],
exc_val: Optional[BaseException],
exc_tb: Optional[types.TracebackType]) -> bool: ...
class HTTPConnection: