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

@@ -241,15 +241,13 @@ class LoggerAdapter:
def hasHandlers(self) -> bool: ...
# TODO uncomment when mypy handle conditionals
#if sys.version_info >= (3,):
# def getLogger(name: Optional[str] = ...) -> Logger: ...
#else:
# @overload
# def getLogger() -> Logger: ...
# @overload
# def getLogger(name: str) -> Logger: ...
def getLogger(name: Optional[str] = ...) -> Logger: ...
if sys.version_info >= (3,):
def getLogger(name: Optional[str] = ...) -> Logger: ...
else:
@overload
def getLogger() -> Logger: ...
@overload
def getLogger(name: str) -> Logger: ...
def getLoggerClass() -> type: ...
if sys.version_info >= (3,):
def getLogRecordFactory() -> Callable[..., LogRecord]: ...
@@ -303,23 +301,18 @@ def getLevelName(lvl: int) -> str: ...
def makeLogRecord(attrdict: Mapping[str, Any]) -> LogRecord: ...
# TODO uncomment when mypy handle conditionals
#if sys.version_info >= (3,):
# def basicConfig(*, filename: str = ..., filemode: str = ...,
# format: str = ..., datefmt: str = ..., style: str = ...,
# level: int = ..., stream: IO[str] = ...,
# handlers: Iterable[Handler]) -> None: ...
#else:
# @overload
# def basicConfig() -> None: ...
# @overload
# def basicConfig(*, filename: str = ..., filemode: str = ...,
# format: str = ..., datefmt: str = ...,
# level: int = ..., stream: IO[str] = ...) -> None: ...
def basicConfig(*, filename: str = ..., filemode: str = ...,
format: str = ..., datefmt: str = ..., style: str = ...,
level: int = ..., stream: IO[str] = ...,
handlers: Iterable[Handler]) -> None: ...
if sys.version_info >= (3,):
def basicConfig(*, filename: str = ..., filemode: str = ...,
format: str = ..., datefmt: str = ..., style: str = ...,
level: int = ..., stream: IO[str] = ...,
handlers: Iterable[Handler]) -> None: ...
else:
@overload
def basicConfig() -> None: ...
@overload
def basicConfig(*, filename: str = ..., filemode: str = ...,
format: str = ..., datefmt: str = ...,
level: int = ..., stream: IO[str] = ...) -> None: ...
def shutdown() -> None: ...
def setLoggerClass(klass: type) -> None: ...

View File

@@ -2,13 +2,12 @@
from typing import Any, Callable, Dict, Optional, IO, Union
import sys
# TODO uncomment when mypy handle conditionals
#if sys.version_info >= (3,):
# from configparser import RawConfigParser
#else:
# from ConfigParser import RawConfigParser
# TODO add RawConfigParser to configparser stubs
RawConfigParser = Any
if sys.version_info >= (3,):
#from configparser import RawConfigParser
# TODO add RawConfigParser to configparser stubs
RawConfigParser = Any
else:
from ConfigParser import RawConfigParser
def dictConfig(config: Dict[str, Any]) -> None: ...

View File

@@ -3,12 +3,10 @@
from typing import Any, Callable, Optional, Tuple, Union, overload
from logging import Handler, FileHandler, LogRecord
import datetime
# TODO uncomment when mypy handle conditionals
#if sys.version_info >= (3,):
# from queue import Queue
#else:
# from Queue import Queue
Queue = Any
if sys.version_info >= (3,):
from queue import Queue
else:
from Queue import Queue
from socket import SocketType
# TODO update socket stubs to add SocketKind
SocketKind = int

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']):