Mypy now supports sys.platform and sys.version_info checks (#410)

This commit is contained in:
Guido van Rossum
2016-07-27 13:25:29 -07:00
committed by GitHub
parent 112a1a17dd
commit 39325bf159
27 changed files with 289 additions and 276 deletions

View File

@@ -50,28 +50,27 @@ class Logger:
stack_info: bool = ..., extra: Dict[str, Any] = ...,
**kwargs: Any) -> None: ...
else:
def debug(self, # type: ignore
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
def debug(msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def info(self, # type: ignore
def info(self,
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def warning(self, # type: ignore
def warning(self,
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def warn(self, # type: ignore
def warn(self,
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def error(self, # type: ignore
def error(self,
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def critical(self, # type: ignore
def critical(self,
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def log(self, # type: ignore
def log(self,
lvl: int, msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def exception(self, # type: ignore
def exception(self,
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def addFilter(self, filt: _FilterType) -> None: ...
@@ -82,8 +81,7 @@ class Logger:
if sys.version_info >= (3,):
def findCaller(self, stack_info: bool = ...) -> Tuple[str, int, str, Optional[str]]: ...
else:
def findCaller(self # type: ignore
) -> Tuple[str, int, str]: ...
def findCaller(self) -> Tuple[str, int, str]: ...
def handle(self, record: 'LogRecord') -> None: ...
if sys.version_info >= (3,):
def makeRecord(self, name: str, lvl: int, fn: str, lno: int, msg: Text,
@@ -93,7 +91,7 @@ class Logger:
extra: Optional[Mapping[str, Any]] = ...,
sinfo: Optional[str] = ...) -> None: ...
else:
def makeRecord(self, # type: ignore
def makeRecord(self,
name: str, lvl: int, fn: str, lno: int, msg: Text,
args: Mapping[str, Any],
exc_info: Optional[_SysExcInfoType],
@@ -136,7 +134,7 @@ class Formatter:
datefmt: Optional[str] =...,
style: str = ...) -> None: ...
else:
def __init__(self, # type: ignore
def __init__(self,
fmt: Optional[str] = ...,
datefmt: Optional[str] =...) -> None: ...
def format(self, record: LogRecord) -> str: ...
@@ -181,7 +179,7 @@ class LogRecord:
func: Optional[str] = ...,
sinfo: Optional[str] = ...) -> None: ...
else:
def __init__(self, # type: ignore
def __init__(self,
name: str, level: int, pathname: str, lineno: int,
msg: Text, args: _ArgsType,
exc_info: Optional[_SysExcInfoType],
@@ -215,25 +213,25 @@ class LoggerAdapter:
stack_info: bool = ..., extra: Dict[str, Any] = ...,
**kwargs: Any) -> None: ...
else:
def debug(self, # type: ignore
def debug(self,
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def info(self, # type: ignore
def info(self,
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def warning(self, # type: ignore
def warning(self,
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def error(self, # type: ignore
def error(self,
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def exception(self, # type: ignore
def exception(self,
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def critical(self, # type: ignore
def critical(self,
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def log(self, # type: ignore
def log(self,
lvl: int, msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def isEnabledFor(self, lvl: int) -> None: ...
@@ -282,29 +280,21 @@ if sys.version_info > (3,):
stack_info: bool = ..., extra: Dict[str, Any] = ...,
**kwargs: Any) -> None: ...
else:
def debug(# type: ignore
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
def debug(msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def info(# type: ignore
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
def info(msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def warning(# type: ignore
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
def warning(msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def warn(# type: ignore
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
def warn(msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def error(# type: ignore
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
def error(msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def critical(# type: ignore
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
def critical(msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def exception(# type: ignore
msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
def exception(msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def log(# type: ignore
lvl: int, msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
def log(lvl: int, msg: Text, *args: Any, exc_info: _ExcInfoType = ...,
extra: Dict[str, Any] = ..., **kwargs: Any) -> None: ...
def disable(lvl: int) -> None: ...

View File

@@ -19,10 +19,8 @@ if sys.version_info >= (3, 4):
def listen(port: int = ...,
verify: Optional[Callable[[bytes], Optional[bytes]]] = ...) -> None: ...
else:
def fileConfig( # type: ignore
fname: Union[str, IO[str]],
def fileConfig(fname: Union[str, IO[str]],
defaults: Optional[Dict[str, str]] = ...,
disable_existing_loggers: bool = ...) -> None: ...
def listen( # type: ignore
port: int = ...) -> None: ...
def listen(port: int = ...) -> None: ...
def stopListening() -> None: ...

View File

@@ -40,61 +40,41 @@ if sys.version_info >= (3,):
def rotate(self, source: str, dest: str) -> None: ...
# TODO uncomment when mypy handle conditionals
#if sys.version_info >= (3,):
# class RotatingFileHandler(BaseRotatingHandler):
# def __init__(self, filename: str, mode: str = ..., maxBytes: int = ...,
# backupCount: int = ..., encoding: Optional[str] = ...,
# delay: bool = ...) -> None: ...
# def doRollover(self) -> None: ...
#else:
# class RotatingFileHandler(Handler):
# def __init__(self, filename: str, mode: str = ..., maxBytes: int = ...,
# backupCount: int = ..., encoding: Optional[str] = ...,
# delay: bool = ...) -> None: ...
# def doRollover(self) -> None: ...
class RotatingFileHandler(BaseRotatingHandler):
def __init__(self, filename: str, mode: str = ..., maxBytes: int = ...,
backupCount: int = ..., encoding: Optional[str] = ...,
delay: bool = ...) -> None: ...
def doRollover(self) -> None: ...
# TODO uncomment when mypy handle conditionals
#if sys.version_info >= (3,):
# class TimedRotatingFileHandler(BaseRotatingHandler):
# if sys.version_info >= (3, 4):
# def __init__(self, filename: str, when: str = ...,
# interval: int = ...,
# backupCount: int = ..., encoding: Optional[str] = ...,
# delay: bool = ..., utc: bool = ...,
# atTime: Optional[datetime.datetime] = ...) -> None: ...
# else:
# def __init__(self, # type: ignore
# filename: str, when: str = ..., interval: int = ...,
# backupCount: int = ..., encoding: Optional[str] = ...,
# delay: bool = ..., utc: bool = ...) -> None: ...
# def doRollover(self) -> None: ...
#else:
# class TimedRotatingFileHandler:
# def __init__(self, # type: ignore
# filename: str, when: str = ..., interval: int = ...,
# backupCount: int = ..., encoding: Optional[str] = ...,
# delay: bool = ..., utc: bool = ...) -> None: ...
# def doRollover(self) -> None: ...
class TimedRotatingFileHandler(BaseRotatingHandler):
if sys.version_info >= (3, 4):
def __init__(self, filename: str, when: str = ...,
interval: int = ...,
if sys.version_info >= (3,):
class RotatingFileHandler(BaseRotatingHandler):
def __init__(self, filename: str, mode: str = ..., maxBytes: int = ...,
backupCount: int = ..., encoding: Optional[str] = ...,
delay: bool = ..., utc: bool = ...,
atTime: Optional[datetime.datetime] = ...) -> None: ...
else:
def __init__(self, # type: ignore
delay: bool = ...) -> None: ...
def doRollover(self) -> None: ...
else:
class RotatingFileHandler(Handler):
def __init__(self, filename: str, mode: str = ..., maxBytes: int = ...,
backupCount: int = ..., encoding: Optional[str] = ...,
delay: bool = ...) -> None: ...
def doRollover(self) -> None: ...
if sys.version_info >= (3,):
class TimedRotatingFileHandler(BaseRotatingHandler):
if sys.version_info >= (3, 4):
def __init__(self, filename: str, when: str = ...,
interval: int = ...,
backupCount: int = ..., encoding: Optional[str] = ...,
delay: bool = ..., utc: bool = ...,
atTime: Optional[datetime.datetime] = ...) -> None: ...
else:
def __init__(self,
filename: str, when: str = ..., interval: int = ...,
backupCount: int = ..., encoding: Optional[str] = ...,
delay: bool = ..., utc: bool = ...) -> None: ...
def doRollover(self) -> None: ...
else:
class TimedRotatingFileHandler:
def __init__(self,
filename: str, when: str = ..., interval: int = ...,
backupCount: int = ..., encoding: Optional[str] = ...,
delay: bool = ..., utc: bool = ...) -> None: ...
def doRollover(self) -> None: ...
def doRollover(self) -> None: ...
class SocketHandler(Handler):
@@ -104,7 +84,7 @@ class SocketHandler(Handler):
if sys.version_info >= (3, 4):
def __init__(self, host: str, port: Optional[int]) -> None: ...
else:
def __init__(self, host: str, port: int) -> None: ... # type: ignore
def __init__(self, host: str, port: int) -> None: ...
def makeSocket(self) -> SocketType: ...
def makePickle(self, record: LogRecord) -> bytes: ...
def send(self, packet: bytes) -> None: ...
@@ -168,7 +148,7 @@ class SMTPHandler(Handler):
secure: Union[Tuple[str], Tuple[str, str], None] =...,
timeout: float = ...) -> None: ...
else:
def __init__(self, # type: ignore
def __init__(self,
mailhost: Union[str, Tuple[str, int]], fromaddr: str,
toaddrs: List[str], subject: str,
credentials: Optional[Tuple[str, str]] = ...,
@@ -193,11 +173,11 @@ class HTTPHandler(Handler):
credentials: Optional[Tuple[str, str]] = ...,
context: Optional[ssl.SSLContext] = ...) -> None: ...
elif sys.version_info >= (3,):
def __init__(self, # type: ignore
def __init__(self,
host: str, url: str, method: str = ..., secure: bool = ...,
credentials: Optional[Tuple[str, str]] = ...) -> None: ...
else:
def __init__(self, # type: ignore
def __init__(self,
host: str, url: str, method: str = ...) -> None: ...
def mapLogRecord(self, record: LogRecord) -> Dict[str, Any]: ...
@@ -213,7 +193,7 @@ if sys.version_info > (3,):
def __init__(self, queue: Queue, *handlers: Handler,
respect_handler_level: bool = ...) -> None: ...
else:
def __init__(self, # type: ignore
def __init__(self,
queue: Queue, *handlers: Handler) -> None: ...
def dequeue(self, block: bool) -> LogRecord: ...
def prepare(self, record: LogRecord) -> Any: ...