diff --git a/stdlib/2and3/argparse.pyi b/stdlib/2and3/argparse.pyi index 56ac9b573..4a0918098 100644 --- a/stdlib/2and3/argparse.pyi +++ b/stdlib/2and3/argparse.pyi @@ -34,7 +34,7 @@ class ArgumentParser: add_help: bool = ..., allow_abbrev: bool = ...) -> None: ... else: - def __init__(self, # type: ignore + def __init__(self, prog: Optional[str] = ..., usage: Optional[str] = ..., description: Optional[str] = ..., @@ -122,10 +122,10 @@ class FileType: encoding: Optional[str] = ..., errors: Optional[str] = ...) -> None: ... elif sys.version_info >= (3,): - def __init__(self, # type: ignore + def __init__(self, mode: str = ..., bufsize: int = ...) -> None: ... else: - def __init__(self, # type: ignore + def __init__(self, mode: str = ..., bufsize: Optional[int] = ...) -> None: ... def __call__(self, string: str) -> IO[Any]: ... diff --git a/stdlib/2and3/hmac.pyi b/stdlib/2and3/hmac.pyi index af0cdf4ea..59aaf3673 100644 --- a/stdlib/2and3/hmac.pyi +++ b/stdlib/2and3/hmac.pyi @@ -13,8 +13,7 @@ if sys.version_info >= (3, 4): def new(key: _B, msg: Optional[_B] = ..., digestmod: Optional[Union[str, Callable[[], _Hash], ModuleType]] = ...) -> HMAC: ... else: - def new( # type: ignore - key: _B, msg: Optional[_B] = ..., + def new(key: _B, msg: Optional[_B] = ..., digestmod: Optional[Union[Callable[[], _Hash], ModuleType]] = ...) -> HMAC: ... class HMAC: diff --git a/stdlib/2and3/logging/__init__.pyi b/stdlib/2and3/logging/__init__.pyi index 8afe6c3af..7f4e5ccba 100644 --- a/stdlib/2and3/logging/__init__.pyi +++ b/stdlib/2and3/logging/__init__.pyi @@ -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: ... diff --git a/stdlib/2and3/logging/config.pyi b/stdlib/2and3/logging/config.pyi index 7ee9c27e3..3a76c2872 100644 --- a/stdlib/2and3/logging/config.pyi +++ b/stdlib/2and3/logging/config.pyi @@ -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: ... diff --git a/stdlib/2and3/logging/handlers.pyi b/stdlib/2and3/logging/handlers.pyi index c2e5cda29..85ee34259 100644 --- a/stdlib/2and3/logging/handlers.pyi +++ b/stdlib/2and3/logging/handlers.pyi @@ -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: ... diff --git a/stdlib/2and3/math.pyi b/stdlib/2and3/math.pyi index e36f16087..db5f6a908 100644 --- a/stdlib/2and3/math.pyi +++ b/stdlib/2and3/math.pyi @@ -32,7 +32,7 @@ def factorial(x: int) -> int: ... if sys.version_info >= (3,): def floor(x: float) -> int: ... else: - def floor(x: float) -> float: ... # type: ignore + def floor(x: float) -> float: ... def fmod(x: float, y: float) -> float: ... def frexp(x: float) -> Tuple[float, int]: ... def fsum(iterable: Iterable) -> float: ... diff --git a/stdlib/2and3/zipfile.pyi b/stdlib/2and3/zipfile.pyi index f3be04dd8..c8236acf6 100644 --- a/stdlib/2and3/zipfile.pyi +++ b/stdlib/2and3/zipfile.pyi @@ -46,7 +46,7 @@ class ZipFile: def writestr(self, zinfo_or_arcname: _SZI, data: Union[bytes, str], compress_type: Optional[int] = ...) -> None: ... else: - def writestr(self, # type: ignore + def writestr(self, zinfo_or_arcname: _SZI, bytes: bytes, compress_type: Optional[int] = ...) -> None: ... @@ -58,7 +58,7 @@ class PyZipFile(ZipFile): def writepy(self, pathname: str, basename: str = ..., filterfunc: Optional[Callable[[str], bool]] = ...) -> None: ... else: - def writepy(self, # type: ignore + def writepy(self, pathname: str, basename: str = ...) -> None: ... class ZipInfo: diff --git a/stdlib/3.4/asyncio/__init__.pyi b/stdlib/3.4/asyncio/__init__.pyi index b4c47435c..b10a25ef6 100644 --- a/stdlib/3.4/asyncio/__init__.pyi +++ b/stdlib/3.4/asyncio/__init__.pyi @@ -81,7 +81,7 @@ from asyncio.locks import ( # See https://github.com/python/mypy/issues/1843 SelectorEventLoop = ... # type: Type[AbstractEventLoop] if sys.platform == 'win32': - ProactorEventLoop = ... # type: Type[AbstractEventLoop] # TODO: Windows only + ProactorEventLoop = ... # type: Type[AbstractEventLoop] DefaultEventLoopPolicy = ... # type: Type[AbstractEventLoopPolicy] # TODO: AbstractChildWatcher (UNIX only) diff --git a/stdlib/3/builtins.pyi b/stdlib/3/builtins.pyi index 473c7eed2..8293f3f3c 100644 --- a/stdlib/3/builtins.pyi +++ b/stdlib/3/builtins.pyi @@ -404,8 +404,7 @@ class bytearray(MutableSequence[int], ByteString): def __setitem__(self, s: slice, x: Sequence[int]) -> None: ... def __delitem__(self, i: Union[int, slice]) -> None: ... def __add__(self, s: bytes) -> bytearray: ... - # TODO: Mypy complains about __add__ and __iadd__ having different signatures. - def __iadd__(self, s: Iterable[int]) -> bytearray: ... # type: ignore + def __iadd__(self, s: Iterable[int]) -> bytearray: ... def __mul__(self, n: int) -> bytearray: ... def __rmul__(self, n: int) -> bytearray: ... def __imul__(self, n: int) -> bytearray: ... diff --git a/stdlib/3/email/__init__.pyi b/stdlib/3/email/__init__.pyi index 4d50f098c..d42a90107 100644 --- a/stdlib/3/email/__init__.pyi +++ b/stdlib/3/email/__init__.pyi @@ -2,7 +2,9 @@ from typing import Callable, Optional, IO import sys -from email.message import Message, Policy +from email.message import Message +if sys.version_info >= (3, 3): + from email.policy import Policy if sys.version_info >= (3, 3): def message_from_string(s: str, _class: Callable[[], Message] = ..., *, @@ -15,16 +17,16 @@ if sys.version_info >= (3, 3): _class: Callable[[], Message] = ..., *, policy: Policy = ...) -> Message: ... elif sys.version_info >= (3, 2): - def message_from_string(s: str, # type: ignore + def message_from_string(s: str, _class: Callable[[], Message] = ..., *, strict: Optional[bool] = ...) -> Message: ... - def message_from_bytes(s: bytes, # type: ignore + def message_from_bytes(s: bytes, _class: Callable[[], Message] = ..., *, strict: Optional[bool] = ...) -> Message: ... - def message_from_file(fp: IO[str], # type: ignore + def message_from_file(fp: IO[str], _class: Callable[[], Message] = ..., *, strict: Optional[bool] = ...) -> Message: ... - def message_from_binary_file(fp: IO[bytes], # type: ignore + def message_from_binary_file(fp: IO[bytes], _class: Callable[[], Message] = ..., *, strict: Optional[bool] = ...) -> Message: ... diff --git a/stdlib/3/email/feedparser.pyi b/stdlib/3/email/feedparser.pyi index 4950fa836..a86032d34 100644 --- a/stdlib/3/email/feedparser.pyi +++ b/stdlib/3/email/feedparser.pyi @@ -3,14 +3,15 @@ from typing import Callable import sys from email.message import Message -from email.policy import Policy +if sys.version_info >= (3, 3): + from email.policy import Policy class FeedParser: if sys.version_info >= (3, 3): def __init__(self, _factory: Callable[[], Message] = ..., *, policy: Policy = ...) -> None: ... else: - def __init__(self, # type: ignore + def __init__(self, _factory: Callable[[], Message] = ...) -> None: ... def feed(self, data: str) -> None: ... def close(self) -> Message: ... @@ -21,7 +22,7 @@ if sys.version_info >= (3, 2): def __init__(self, _factory: Callable[[], Message] = ..., *, policy: Policy = ...) -> None: ... else: - def __init__(self, # type: ignore + def __init__(self, _factory: Callable[[], Message] = ...) -> None: ... def feed(self, data: str) -> None: ... def close(self) -> Message: ... diff --git a/stdlib/3/email/generator.pyi b/stdlib/3/email/generator.pyi index eb8552c65..4be36d10a 100644 --- a/stdlib/3/email/generator.pyi +++ b/stdlib/3/email/generator.pyi @@ -2,8 +2,9 @@ from typing import TextIO, Optional import sys -from email.policy import Policy from email.message import Message +if sys.version_info >= (3, 3): + from email.policy import Policy class Generator: def clone(self, fp: TextIO) -> 'Generator': ... @@ -13,14 +14,14 @@ class Generator: maxheaderlen: int = ..., *, policy: Policy = ...) -> None: ... else: - def __init__(self, outfp: TextIO, # type: ignore + def __init__(self, outfp: TextIO, mangle_from_: bool = ..., maxheaderlen: int = ...) -> None: ... if sys.version_info >= (3, 2): def flatten(self, msg: Message, unixfrom: bool = ..., linesep: Optional[str] =...) -> None: ... else: - def flatten(self, msg: Message, # type: ignore + def flatten(self, msg: Message, unixfrom: bool = ...) -> None: ... if sys.version_info >= (3, 2): @@ -32,7 +33,7 @@ if sys.version_info >= (3, 2): maxheaderlen: int = ..., *, policy: Policy = ...) -> None: ... else: - def __init__(self, outfp: TextIO, # type: ignore + def __init__(self, outfp: TextIO, mangle_from_: bool = ..., maxheaderlen: int = ...) -> None: ... def flatten(self, msg: Message, unixfrom: bool = ..., diff --git a/stdlib/3/email/headerregistry.pyi b/stdlib/3/email/headerregistry.pyi index 078c65d8d..40b57d49d 100644 --- a/stdlib/3/email/headerregistry.pyi +++ b/stdlib/3/email/headerregistry.pyi @@ -1,10 +1,11 @@ # Stubs for email.headerregistry (Python 3.4) -from typing import Tuple, Optional, Any, Union, Mapping -import sys -from email.errors import MessageDefect -from email.policy import Policy import datetime as dt +import sys +from typing import Tuple, Optional, Any, Union, Mapping +from email.errors import MessageDefect +if sys.version_info >= (3, 3): + from email.policy import Policy if sys.version_info >= (3, 3): diff --git a/stdlib/3/email/message.pyi b/stdlib/3/email/message.pyi index 4bf3ca386..3162c0351 100644 --- a/stdlib/3/email/message.pyi +++ b/stdlib/3/email/message.pyi @@ -6,8 +6,12 @@ from typing import ( import sys from email.charset import Charset from email.errors import MessageDefect -from email.policy import Policy -from email.contentmanager import ContentManager +if sys.version_info >= (3, 3): + from email.policy import Policy +if sys.version_info >= (3, 4): + from email.contentmanager import ContentManager +else: + ContentManager = object # Hack so we can reference it in argument types. _T = TypeVar('_T') @@ -75,50 +79,21 @@ class Message: requote: bool = ..., charset: str = ..., language: str = ..., replace: bool = ...) -> None: ... else: - def as_string(self, unixfrom: bool = ..., # type: ignore + def as_string(self, unixfrom: bool = ..., maxheaderlen: int = ...) -> str: ... - def set_param(self, param: str, value: str, # type: ignore + def set_param(self, param: str, value: str, header: str = ..., requote: bool = ..., charset: str = ..., language: str = ...) -> None: ... if sys.version_info >= (3, 3): def __init__(self, policy: Policy = ...) -> None: ... else: - def __init__(self) -> None: ... # type: ignore - -class EmailMessage: - def __init__(self, policy: Policy = ...) -> None: ... - def get_body(self, - preferencelist: Sequence[str] = ...) -> Optional[Message]: ... - def iter_attachments(self) -> Iterator[Message]: ... - def iter_parts(self) -> Iterator[Message]: ... - def get_content(self, *args: Any, - content_manager: Optional[ContentManager] = ..., - **kw: Any) -> Any: ... - def set_content(self, *args: Any, - content_manager: Optional[ContentManager] = ..., - **kw: Any) -> None: ... - def make_related(self, boundary: Optional[str] = ...) -> None: ... - def make_alternative(self, boundary: Optional[str] = ...) -> None: ... - def make_mixed(self, boundary: Optional[str] = ...) -> None: ... - def add_related(self, *args: Any, - content_manager: Optional[ContentManager] = ..., - **kw: Any) -> None: ... - def add_alternative(self, *args: Any, - content_manager: Optional[ContentManager] = ..., - **kw: Any) -> None: ... - def add_attachement(self, *args: Any, - content_manager: Optional[ContentManager] = ..., - **kw: Any) -> None: ... - def clear(self) -> None: ... - def clear_content(self) -> None: ... - if sys.version_info >= (3, 4, 2): - def is_attachment(self) -> bool: ... - else: - @property - def is_attachment(self) -> bool: ... + def __init__(self) -> None: ... class MIMEPart: - def __init__(self, policy: Policy = ...) -> None: ... + if sys.version_info >= (3, 3): + def __init__(self, policy: Policy = ...) -> None: ... + else: + def __init__(self) -> None: ... def get_body(self, preferencelist: Sequence[str] = ...) -> Optional[Message]: ... def iter_attachments(self) -> Iterator[Message]: ... @@ -148,3 +123,8 @@ class MIMEPart: else: @property def is_attachment(self) -> bool: ... + +class EmailMessage(MIMEPart): + def set_content(self, *args: Any, + content_manager: Optional[ContentManager] = ..., + **kw: Any) -> None: ... diff --git a/stdlib/3/email/parser.pyi b/stdlib/3/email/parser.pyi index d5e73483b..02c4ab646 100644 --- a/stdlib/3/email/parser.pyi +++ b/stdlib/3/email/parser.pyi @@ -3,7 +3,8 @@ from typing import Callable, Optional, TextIO, BinaryIO import email.feedparser from email.message import Message -from email.policy import Policy +if sys.version_info >= (3, 3): + from email.policy import Policy import sys FeedParser = email.feedparser.FeedParser @@ -15,7 +16,7 @@ class Parser: policy: Policy = ...) -> None: ... else: # TODO `strict` is positional - def __init__(self, # type: ignore + def __init__(self, _class: Callable[[], Message] = ..., *, strict: Optional[bool]) -> None: ... def parse(self, fp: TextIO, headersonly: bool = ...) -> Message: ... @@ -27,7 +28,7 @@ class HeaderParser(Parser): policy: Policy = ...) -> None: ... else: # TODO `strict` is positional - def __init__(self, # type: ignore + def __init__(self, _class: Callable[[], Message] = ..., *, strict: Optional[bool]) -> None: ... def parse(self, fp: TextIO, headersonly: bool = ...) -> Message: ... @@ -40,7 +41,7 @@ if sys.version_info >= (3, 3): policy: Policy = ...) -> None: ... else: # TODO `strict` is positional - def __init__(self, # type: ignore + def __init__(self, _class: Callable[[], Message] = ..., *, strict: Optional[bool]) -> None: ... def parse(self, fp: BinaryIO, headersonly: bool = ...) -> Message: ... @@ -53,7 +54,7 @@ if sys.version_info >= (3, 2): policy: Policy = ...) -> None: ... else: # TODO `strict` is positional - def __init__(self, # type: ignore + def __init__(self, _class: Callable[[], Message] = ..., *, strict: Optional[bool]) -> None: ... def parse(self, fp: BinaryIO, headersonly: bool = ...) -> Message: ... diff --git a/stdlib/3/email/policy.pyi b/stdlib/3/email/policy.pyi index 28f72bd41..c34ee5829 100644 --- a/stdlib/3/email/policy.pyi +++ b/stdlib/3/email/policy.pyi @@ -5,7 +5,8 @@ import sys from email.message import Message from email.errors import MessageDefect from email.header import Header -from email.contentmanager import ContentManager +if sys.version_info >= (3, 4): + from email.contentmanager import ContentManager from abc import abstractmethod if sys.version_info >= (3, 3): diff --git a/stdlib/3/heapq.pyi b/stdlib/3/heapq.pyi index 81b6135e8..f56ae7204 100644 --- a/stdlib/3/heapq.pyi +++ b/stdlib/3/heapq.pyi @@ -16,7 +16,7 @@ if sys.version_info >= (3, 5): def merge(*iterables: Iterable[_T], key: Callable[[_T], Any] = ..., reverse: bool = ...) -> Iterable[_T]: ... else: - def merge(*iterables: Iterable[_T]) -> Iterable[_T]: ... # type: ignore + def merge(*iterables: Iterable[_T]) -> Iterable[_T]: ... def nlargest(n: int, iterable: Iterable[_T], key: Callable[[_T], Any] = ...) -> List[_T]: ... def nsmallest(n: int, iterable: Iterable[_T], diff --git a/stdlib/3/html/parser.pyi b/stdlib/3/html/parser.pyi index f49627d33..a72d1942a 100644 --- a/stdlib/3/html/parser.pyi +++ b/stdlib/3/html/parser.pyi @@ -6,10 +6,10 @@ class HTMLParser(ParserBase): if sys.version_info >= (3, 5): def __init__(self, *, convert_charrefs: bool = ...) -> None: ... elif sys.version_info >= (3, 4): - def __init__(self, strict: bool = ..., *, # type: ignore + def __init__(self, strict: bool = ..., *, convert_charrefs: bool = ...) -> None: ... else: - def __init__(self, strict: bool = ...) -> None: ... # type: ignore + def __init__(self, strict: bool = ...) -> None: ... def feed(self, feed: str) -> None: ... def close(self) -> None: ... def reset(self) -> None: ... diff --git a/stdlib/3/http/client.pyi b/stdlib/3/http/client.pyi index c9b92d6c7..6c0e51136 100644 --- a/stdlib/3/http/client.pyi +++ b/stdlib/3/http/client.pyi @@ -146,13 +146,13 @@ class HTTPResponse(io.BufferedIOBase): class HTTPConnection: if sys.version_info >= (3, 4): - def __init__(self, # type: ignore + def __init__(self, host: str, port: Optional[int] = ..., timeout: int = ..., source_address: Optional[Tuple[str, int]] = ...) \ -> None: ... else: - def __init__(self, # type: ignore + def __init__(self, host: str, port: Optional[int] = ..., strict: bool = ..., timeout: int = ..., source_address: Optional[Tuple[str, int]] = ...) \ @@ -174,7 +174,7 @@ class HTTPConnection: class HTTPSConnection(HTTPConnection): if sys.version_info >= (3, 4): - def __init__(self, # type: ignore + def __init__(self, host: str, port: Optional[int] = ..., key_file: Optional[str] = ..., cert_file: Optional[str] = ..., @@ -183,7 +183,7 @@ class HTTPSConnection(HTTPConnection): *, context: Optional[ssl.SSLContext] = ..., check_hostname: Optional[bool] = ...) -> None: ... else: - def __init__(self, # type: ignore + def __init__(self, host: str, port: Optional[int] = ..., key_file: Optional[str] = ..., cert_file: Optional[str] = ..., diff --git a/stdlib/3/importlib/abc.pyi b/stdlib/3/importlib/abc.pyi index dad275bab..96b3e28e4 100644 --- a/stdlib/3/importlib/abc.pyi +++ b/stdlib/3/importlib/abc.pyi @@ -1,5 +1,6 @@ import abc -from _importlib_modulespec import ModuleSpec +if sys.version_info >= (3, 4): + from _importlib_modulespec import ModuleSpec import sys import types from typing import Any, Mapping, Optional, Sequence, Tuple, Union diff --git a/stdlib/3/importlib/machinery.pyi b/stdlib/3/importlib/machinery.pyi index d50b4a56d..2305e36f5 100644 --- a/stdlib/3/importlib/machinery.pyi +++ b/stdlib/3/importlib/machinery.pyi @@ -5,93 +5,147 @@ from typing import Any, Callable, List, Optional, Sequence, Tuple, Union # ModuleSpec is exported from this module, but for circular import # reasons exists in its own stub file (with Loader and ModuleType). -from _importlib_modulespec import ModuleSpec # Exported +if sys.version_info >= (3, 4): + from _importlib_modulespec import ModuleSpec as ModuleSpec # Exported -class BuiltinImporter(importlib.abc.MetaPathFinder, - importlib.abc.InspectLoader): - # MetaPathFinder - @classmethod - def find_module(cls, fullname: str, - path: Optional[Sequence[importlib.abc._Path]] - ) -> Optional[importlib.abc.Loader]: - ... - if sys.version_info >= (3, 4): +if sys.version_info >= (3, 3): + class BuiltinImporter(importlib.abc.MetaPathFinder, + importlib.abc.InspectLoader): + # MetaPathFinder @classmethod - def find_spec(cls, fullname: str, - path: Optional[Sequence[importlib.abc._Path]], - target: types.ModuleType = None) -> Optional[ModuleSpec]: + def find_module(cls, fullname: str, + path: Optional[Sequence[importlib.abc._Path]] + ) -> Optional[importlib.abc.Loader]: ... - # InspectLoader - @classmethod - def is_package(cls, fullname: str) -> bool: ... - @classmethod - def load_module(cls, fullname: str) -> types.ModuleType: ... - @classmethod - def get_code(cls, fullname: str) -> None: ... # type: ignore - @classmethod - def get_source(cls, fullname: str) -> None: ... # type: ignore - # Loader - @classmethod - def load_module(cls, fullname: str) -> types.ModuleType: ... - if sys.version_info >= (3, 3): - @staticmethod - def module_repr(module: types.ModuleType) -> str: ... # type: ignore - if sys.version_info >= (3, 4): + if sys.version_info >= (3, 4): + @classmethod + def find_spec(cls, fullname: str, + path: Optional[Sequence[importlib.abc._Path]], + target: types.ModuleType = None) -> Optional[ModuleSpec]: + ... + # InspectLoader @classmethod - def create_module(cls, spec: ModuleSpec) -> Optional[types.ModuleType]: + def is_package(cls, fullname: str) -> bool: ... + @classmethod + def load_module(cls, fullname: str) -> types.ModuleType: ... + @classmethod + def get_code(cls, fullname: str) -> None: ... # type: ignore + @classmethod + def get_source(cls, fullname: str) -> None: ... # type: ignore + # Loader + @classmethod + def load_module(cls, fullname: str) -> types.ModuleType: ... + if sys.version_info >= (3, 3): + @staticmethod + def module_repr(module: types.ModuleType) -> str: ... # type: ignore + if sys.version_info >= (3, 4): + @classmethod + def create_module(cls, spec: ModuleSpec) -> Optional[types.ModuleType]: + ... + @classmethod + def exec_module(cls, module: types.ModuleType) -> None: ... +else: + class BuiltinImporter(importlib.abc.InspectLoader): + # MetaPathFinder + @classmethod + def find_module(cls, fullname: str, + path: Optional[Sequence[importlib.abc._Path]] + ) -> Optional[importlib.abc.Loader]: ... + # InspectLoader @classmethod - def exec_module(cls, module: types.ModuleType) -> None: ... + def is_package(cls, fullname: str) -> bool: ... + @classmethod + def load_module(cls, fullname: str) -> types.ModuleType: ... + @classmethod + def get_code(cls, fullname: str) -> None: ... # type: ignore + @classmethod + def get_source(cls, fullname: str) -> None: ... # type: ignore + # Loader + @classmethod + def load_module(cls, fullname: str) -> types.ModuleType: ... -class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): - # MetaPathFinder - @classmethod - def find_module(cls, fullname: str, - path: Optional[Sequence[importlib.abc._Path]] - ) -> Optional[importlib.abc.Loader]: - ... - if sys.version_info >= (3, 4): +if sys.version_info >= (3, 3): + class FrozenImporter(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): + # MetaPathFinder @classmethod - def find_spec(cls, fullname: str, - path: Optional[Sequence[importlib.abc._Path]], - target: types.ModuleType = None) -> Optional[ModuleSpec]: + def find_module(cls, fullname: str, + path: Optional[Sequence[importlib.abc._Path]] + ) -> Optional[importlib.abc.Loader]: ... - # InspectLoader - @classmethod - def is_package(cls, fullname: str) -> bool: ... - @classmethod - def load_module(cls, fullname: str) -> types.ModuleType: ... - @classmethod - def get_code(cls, fullname: str) -> None: ... # type: ignore - @classmethod - def get_source(cls, fullname: str) -> None: ... # type: ignore - # Loader - @classmethod - def load_module(cls, fullname: str) -> types.ModuleType: ... - if sys.version_info >= (3, 3): - @staticmethod - def module_repr(module: types.ModuleType) -> str: ... # type: ignore - if sys.version_info >= (3, 4): + if sys.version_info >= (3, 4): + @classmethod + def find_spec(cls, fullname: str, + path: Optional[Sequence[importlib.abc._Path]], + target: types.ModuleType = None) -> Optional[ModuleSpec]: + ... + # InspectLoader @classmethod - def create_module(cls, spec: ModuleSpec) -> Optional[types.ModuleType]: + def is_package(cls, fullname: str) -> bool: ... + @classmethod + def load_module(cls, fullname: str) -> types.ModuleType: ... + @classmethod + def get_code(cls, fullname: str) -> None: ... # type: ignore + @classmethod + def get_source(cls, fullname: str) -> None: ... # type: ignore + # Loader + @classmethod + def load_module(cls, fullname: str) -> types.ModuleType: ... + if sys.version_info >= (3, 3): + @staticmethod + def module_repr(module: types.ModuleType) -> str: ... # type: ignore + if sys.version_info >= (3, 4): + @classmethod + def create_module(cls, spec: ModuleSpec) -> Optional[types.ModuleType]: + ... + @staticmethod + def exec_module(module: types.ModuleType) -> None: ... # type: ignore +else: + class FrozenImporter(importlib.abc.InspectLoader): + # MetaPathFinder + @classmethod + def find_module(cls, fullname: str, + path: Optional[Sequence[importlib.abc._Path]] + ) -> Optional[importlib.abc.Loader]: ... - @staticmethod - def exec_module(module: types.ModuleType) -> None: ... # type: ignore + # InspectLoader + @classmethod + def is_package(cls, fullname: str) -> bool: ... + @classmethod + def load_module(cls, fullname: str) -> types.ModuleType: ... + @classmethod + def get_code(cls, fullname: str) -> None: ... # type: ignore + @classmethod + def get_source(cls, fullname: str) -> None: ... # type: ignore + # Loader + @classmethod + def load_module(cls, fullname: str) -> types.ModuleType: ... -class WindowsRegisteryFinder(importlib.abc.MetaPathFinder): - @classmethod - def find_module(cls, fullname: str, - path: Optional[Sequence[importlib.abc._Path]] - ) -> Optional[importlib.abc.Loader]: - ... - if sys.version_info >= (3, 4): +if sys.version_info >= (3, 3): + class WindowsRegisteryFinder(importlib.abc.MetaPathFinder): @classmethod - def find_spec(cls, fullname: str, - path: Optional[Sequence[importlib.abc._Path]], - target: types.ModuleType = None) -> Optional[ModuleSpec]: + def find_module(cls, fullname: str, + path: Optional[Sequence[importlib.abc._Path]] + ) -> Optional[importlib.abc.Loader]: + ... + if sys.version_info >= (3, 4): + @classmethod + def find_spec(cls, fullname: str, + path: Optional[Sequence[importlib.abc._Path]], + target: types.ModuleType = None) -> Optional[ModuleSpec]: + ... +else: + class WindowsRegisteryFinder: + @classmethod + def find_module(cls, fullname: str, + path: Optional[Sequence[importlib.abc._Path]] + ) -> Optional[importlib.abc.Loader]: ... -class PathFinder(importlib.abc.MetaPathFinder): ... +if sys.version_info >= (3, 3): + class PathFinder(importlib.abc.MetaPathFinder): ... +else: + class PathFinder: ... if sys.version_info >= (3, 3): SOURCE_SUFFIXES = ... # type: List[str] @@ -121,4 +175,4 @@ if sys.version_info >= (3, 3): class ExtensionFileLoader(importlib.abc.ExecutionLoader): def get_filename(self, fullname: str) -> importlib.abc._Path: ... - def get_source(self, fullname: str) -> None: ... # type: ignore + def get_source(self, fullname: str) -> None: ... # type: ignore diff --git a/stdlib/3/io.pyi b/stdlib/3/io.pyi index 7b915fcad..de2c7a46e 100644 --- a/stdlib/3/io.pyi +++ b/stdlib/3/io.pyi @@ -52,11 +52,11 @@ class IOBase: def readline(self, size: int = ...) -> bytes: ... def __del__(self) -> None: ... else: - def readline(self, limit: int = ...) -> bytes: ... # type: ignore + def readline(self, limit: int = ...) -> bytes: ... if sys.version_info >= (3, 2): closed = ... # type: bool else: - def closed(self) -> bool: ... # type: ignore + def closed(self) -> bool: ... class RawIOBase(IOBase): def readall(self) -> bytes: ... @@ -65,7 +65,7 @@ class RawIOBase(IOBase): if sys.version_info >= (3, 4): def read(self, size: int = ...) -> Optional[bytes]: ... else: - def read(self, n: int = ...) -> Optional[bytes]: ... # type: ignore + def read(self, n: int = ...) -> Optional[bytes]: ... class BufferedIOBase(IOBase): def detach(self) -> RawIOBase: ... @@ -77,8 +77,8 @@ class BufferedIOBase(IOBase): def read(self, size: Optional[int] = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ... else: - def read(self, n: Optional[int] = ...) -> bytes: ... # type: ignore - def read1(self, n: int = ...) -> bytes: ... # type: ignore + def read(self, n: Optional[int] = ...) -> bytes: ... + def read1(self, n: int = ...) -> bytes: ... class FileIO(RawIOBase): @@ -91,7 +91,7 @@ class FileIO(RawIOBase): Callable[[Union[int, str], str], int]] = ...) \ -> None: ... else: - def __init__(self, name: Union[str, bytes, int], # type: ignore + def __init__(self, name: Union[str, bytes, int], mode: str = ..., closefd: bool = ...) -> None: ... # TODO should extend from BufferedIOBase @@ -124,11 +124,11 @@ class BytesIO(BinaryIO): def readline(self, size: int = ...) -> bytes: ... def __del__(self) -> None: ... else: - def readline(self, limit: int = ...): ... # type: ignore + def readline(self, limit: int = ...): ... if sys.version_info >= (3, 2): closed = ... # type: bool else: - def closed(self) -> bool: ... # type: ignore + def closed(self) -> bool: ... # copied from BufferedIOBase def detach(self) -> RawIOBase: ... def readinto(self, b: bytearray) -> int: ... @@ -139,15 +139,15 @@ class BytesIO(BinaryIO): def read(self, size: Optional[int] = ...) -> bytes: ... def read1(self, size: int = ...) -> bytes: ... else: - def read(self, n: Optional[int] = ...) -> bytes: ... # type: ignore - def read1(self, n: int = ...) -> bytes: ... # type: ignore + def read(self, n: Optional[int] = ...) -> bytes: ... + def read1(self, n: int = ...) -> bytes: ... class BufferedReader(BufferedIOBase): def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ... if sys.version_info >= (3, 4): def peek(self, size: int = ...) -> bytes: ... else: - def peek(self, n: int = ...) -> bytes: ... # type: ignore + def peek(self, n: int = ...) -> bytes: ... class BufferedWriter(BufferedIOBase): def __init__(self, raw: RawIOBase, buffer_size: int = ...) -> None: ... @@ -179,7 +179,7 @@ class TextIOBase(IOBase): elif sys.version_info >= (3, 2): def readline(self, limit: int = ...) -> str: ... # type: ignore else: - def readline(self) -> str: ... # type: ignore + def readline(self) -> str: ... if sys.version_info >= (3, 2): def seek(self, offset: int, whence: int = ...) -> int: ... def tell(self) -> int: ... @@ -194,7 +194,7 @@ class TextIOWrapper(TextIO): # line_buffering: bool = ..., write_through: bool = ...) \ # -> None: ... #else: - # def __init__(self, buffer: IO[bytes], # type: ignore + # def __init__(self, buffer: IO[bytes], # encoding: str = ..., errors: Optional[str] = ..., # newline: Optional[str] = ..., line_buffering: bool = ...) \ # -> None: ... @@ -222,23 +222,23 @@ class TextIOWrapper(TextIO): if sys.version_info >= (3, 2): closed = ... # type: bool else: - def closed(self) -> bool: ... # type: ignore + def closed(self) -> bool: ... # copied from TextIOBase encoding = ... # type: str errors = ... # type: Optional[str] newlines = ... # type: Union[str, Tuple[str, ...], None] - def __iter__(self) -> Iterator[str]: ... # type: ignore - def __next__(self) -> str: ... # type: ignore + def __iter__(self) -> Iterator[str]: ... + def __next__(self) -> str: ... def __enter__(self) -> 'TextIO': ... def detach(self) -> IOBase: ... def write(self, s: str) -> int: ... if sys.version_info >= (3, 4): - def readline(self, size: int = ...) -> str: ... # type: ignore + def readline(self, size: int = ...) -> str: ... def read(self, size: Optional[int] = ...) -> str: ... elif sys.version_info >= (3, 2): - def readline(self, limit: int = ...) -> str: ... # type: ignore + def readline(self, limit: int = ...) -> str: ... else: - def readline(self) -> str: ... # type: ignore + def readline(self) -> str: ... if sys.version_info >= (3, 2): def seek(self, offset: int, whence: int = ...) -> int: ... def tell(self) -> int: ... diff --git a/stdlib/3/ssl.pyi b/stdlib/3/ssl.pyi index 8a006d61d..046a2c407 100644 --- a/stdlib/3/ssl.pyi +++ b/stdlib/3/ssl.pyi @@ -15,9 +15,9 @@ _PasswordType = Union[Callable[[], Union[str, bytes]], str, bytes] if sys.version_info >= (3, 5): - _SC1ArgT = Union['SSLSocket', 'SSLObject'] + _SC1ArgT = Union[SSLSocket, SSLObject] else: - _SC1ArgT = 'SSLSocket' + _SC1ArgT = SSLSocket _SrvnmeCbType = Callable[[_SC1ArgT, Optional[str], 'SSLSocket'], Optional[int]] class SSLError(OSError): @@ -202,7 +202,7 @@ class SSLContext: binary_form: bool = ...) \ -> Union[List[_PeerCertRetDictType], List[bytes]]: ... else: - def load_verify_locations(self, # type: ignore + def load_verify_locations(self, cafile: Optional[str] = ..., capath: Optional[str] = ...) -> None: ... def set_default_verify_paths(self) -> None: ... diff --git a/stdlib/3/unittest.pyi b/stdlib/3/unittest.pyi index 41fe55412..a727709e7 100644 --- a/stdlib/3/unittest.pyi +++ b/stdlib/3/unittest.pyi @@ -232,7 +232,7 @@ class TestLoader: def loadTestsFromModule(self, module: ModuleType, *, pattern: Any = ...) -> TestSuite: ... else: - def loadTestsFromModule(self, # type: ignore + def loadTestsFromModule(self, module: ModuleType) -> TestSuite: ... def loadTestsFromName(self, name: str, module: Optional[ModuleType] = ...) -> TestSuite: ... @@ -297,7 +297,7 @@ class TextTestRunner(TestRunner): warnings: Optional[Type[Warning]] = ..., *, tb_locals: bool = ...) -> None: ... else: - def __init__(self, # type: ignore + def __init__(self, stream: Optional[TextIO] = ..., descriptions: bool = ..., verbosity: int = ..., failfast: bool = ..., buffer: bool = ..., @@ -308,7 +308,7 @@ class TextTestRunner(TestRunner): if sys.version_info >= (3, 4): _DefaultTestType = Union[str, Iterable[str], None] else: - _DefaultTestType = Optional[str] + _DefaultTestType = Union[str, None] # not really documented class TestProgram: diff --git a/stdlib/3/urllib/request.pyi b/stdlib/3/urllib/request.pyi index bdfa33658..6786510c9 100644 --- a/stdlib/3/urllib/request.pyi +++ b/stdlib/3/urllib/request.pyi @@ -38,7 +38,7 @@ class Request: @full_url.deleter def full_url(self) -> None: ... else: - full_url = ... # type: ignore # type: str + full_url = ... # type: str type = ... # type: str host = ... # type: str origin_req_host = ... # type: str diff --git a/tests/mypy_test.py b/tests/mypy_test.py index 73fbfb5e4..dc02246d1 100755 --- a/tests/mypy_test.py +++ b/tests/mypy_test.py @@ -117,6 +117,7 @@ def main(): runs += 1 flags = ['--python-version', '%d.%d' % (major, minor)] flags.append('--strict-optional') + ##flags.append('--warn-unused-ignores') sys.argv = ['mypy'] + flags + files if args.verbose: print("running", ' '.join(sys.argv)) diff --git a/third_party/3/pkg_resources.pyi b/third_party/3/pkg_resources.pyi index 933164220..a58a0a1c3 100644 --- a/third_party/3/pkg_resources.pyi +++ b/third_party/3/pkg_resources.pyi @@ -6,6 +6,7 @@ from typing import ( TypeVar, overload, ) import importlib.abc +import sys import types import zipimport @@ -244,7 +245,10 @@ class ExtractionError(Exception): original_error = ... # type: Exception -class _Importer(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): ... +if sys.version_info >= (3, 3): + class _Importer(importlib.abc.MetaPathFinder, importlib.abc.InspectLoader): ... +else: + class _Importer(importlib.abc.InspectLoader): ... def register_finder(importer_type: type, distribution_finder: _DistFinderType) -> None : ...