apply conditionals (#417)

This commit is contained in:
Valérian Rousset
2016-07-29 14:59:26 +02:00
committed by Matthias Kramm
parent cfde32b93f
commit 6c6f5f19da
5 changed files with 76 additions and 109 deletions

View File

@@ -79,70 +79,49 @@ responses = ... # type: Dict[int, str]
class HTTPMessage(email.message.Message): ...
# TODO uncomment when mypy handle conditionals
#if sys.version_info >= (3, 5):
# class HTTPResponse(io.BufferedIOBase):
# msg = ... # type: HTTPMessage
# version = ... # type: int
# debuglevel = ... # type: int
# closed = ... # type: bool
# status = ... # type: int
# reason = ... # type: str
# def read(self, amt: Optional[int] = ...) -> bytes: ...
# def readinto(self, b: bytearray) -> int: ...
# @overload
# def getheader(self, name: str) -> Optional[str]: ...
# @overload
# def getheader(self, name: str, default: _T) -> Union[str, _T]: ...
# def getheaders(self) -> List[Tuple[str, str]]: ...
# def fileno(self) -> int: ...
# def __iter__(self) -> Iterator[bytes]: ...
# def __enter__(self) -> 'HTTPResponse': ...
# def __exit__(self, exc_type: Optional[type],
# exc_val: Optional[Exception],
# exc_tb: Optional[types.TracebackType]) -> bool: ...
#else:
# class HTTPResponse:
# msg = ... # type: HTTPMessage
# version = ... # type: int
# debuglevel = ... # type: int
# closed = ... # type: bool
# status = ... # type: int
# reason = ... # type: str
# def read(self, amt: Optional[int] = ...) -> bytes: ...
# if sys.version_info >= (3, 3):
# def readinto(self, b: bytearray) -> int: ...
# @overload
# def getheader(self, name: str) -> Optional[str]: ...
# @overload
# def getheader(self, name: str, default: _T) -> Union[str, _T]: ...
# def getheaders(self) -> List[Tuple[str, str]]: ...
# def fileno(self) -> int: ...
# def __iter__(self) -> Iterator[bytes]: ...
# def __enter__(self) -> 'HTTPResponse': ...
# def __exit__(self, exc_type: Optional[type],
# exc_val: Optional[Exception],
# exc_tb: Optional[types.TracebackType]) -> bool: ...
class HTTPResponse(io.BufferedIOBase):
msg = ... # type: HTTPMessage
version = ... # type: int
debuglevel = ... # type: int
closed = ... # type: bool
status = ... # type: int
reason = ... # type: str
def read(self, amt: Optional[int] = ...) -> bytes: ...
def readinto(self, b: bytearray) -> int: ...
@overload
def getheader(self, name: str) -> Optional[str]: ...
@overload
def getheader(self, name: str, default: _T) -> Union[str, _T]: ...
def getheaders(self) -> List[Tuple[str, str]]: ...
def fileno(self) -> int: ...
def __iter__(self) -> Iterator[bytes]: ...
def __enter__(self) -> 'HTTPResponse': ...
def __exit__(self, exc_type: Optional[type],
exc_val: Optional[Exception],
exc_tb: Optional[types.TracebackType]) -> bool: ...
if sys.version_info >= (3, 5):
class HTTPResponse(io.BufferedIOBase):
msg = ... # type: HTTPMessage
version = ... # type: int
debuglevel = ... # type: int
closed = ... # type: bool
status = ... # type: int
reason = ... # type: str
def read(self, amt: Optional[int] = ...) -> bytes: ...
def readinto(self, b: bytearray) -> int: ...
@overload
def getheader(self, name: str) -> Optional[str]: ...
@overload
def getheader(self, name: str, default: _T) -> Union[str, _T]: ...
def getheaders(self) -> List[Tuple[str, str]]: ...
def fileno(self) -> int: ...
def __iter__(self) -> Iterator[bytes]: ...
def __enter__(self) -> 'HTTPResponse': ...
def __exit__(self, exc_type: Optional[type],
exc_val: Optional[Exception],
exc_tb: Optional[types.TracebackType]) -> bool: ...
else:
class HTTPResponse:
msg = ... # type: HTTPMessage
version = ... # type: int
debuglevel = ... # type: int
closed = ... # type: bool
status = ... # type: int
reason = ... # type: str
def read(self, amt: Optional[int] = ...) -> bytes: ...
if sys.version_info >= (3, 3):
def readinto(self, b: bytearray) -> int: ...
@overload
def getheader(self, name: str) -> Optional[str]: ...
@overload
def getheader(self, name: str, default: _T) -> Union[str, _T]: ...
def getheaders(self) -> List[Tuple[str, str]]: ...
def fileno(self) -> int: ...
def __iter__(self) -> Iterator[bytes]: ...
def __enter__(self) -> 'HTTPResponse': ...
def __exit__(self, exc_type: Optional[type],
exc_val: Optional[Exception],
exc_tb: Optional[types.TracebackType]) -> bool: ...
class HTTPConnection:
if sys.version_info >= (3, 4):

View File

@@ -7,12 +7,10 @@ from urllib.request import Request
_T = TypeVar('_T')
# TODO uncomment when mypy handles conditionals
#if sys.version_info >= (3, 3):
# class LoadError(OSError): ...
#else:
# class LoadError(IOError): ...
class LoadError(OSError): ...
if sys.version_info >= (3, 3):
class LoadError(OSError): ...
else:
class LoadError(IOError): ...
class CookieJar(Iterable['Cookie']):