From 91af6291b1c9aeb4538682de530e7fda77bd1dee Mon Sep 17 00:00:00 2001 From: Jelle Zijlstra Date: Mon, 11 Jun 2018 14:04:05 -0700 Subject: [PATCH] make shlex.shlex and multiprocessing.pool.IMapIterator instantiable (#2120) Part of #1476. --- stdlib/3/multiprocessing/pool.pyi | 4 ++++ stdlib/3/shlex.pyi | 8 ++++++-- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/stdlib/3/multiprocessing/pool.pyi b/stdlib/3/multiprocessing/pool.pyi index c641e141a..f077b4c56 100644 --- a/stdlib/3/multiprocessing/pool.pyi +++ b/stdlib/3/multiprocessing/pool.pyi @@ -15,8 +15,12 @@ class AsyncResult(): def ready(self) -> bool: ... def successful(self) -> bool: ... +_IMIT = TypeVar('_IMIT', bound=IMapIterator) + class IMapIterator(Iterable[Any]): + def __iter__(self: _IMIT) -> _IMIT: ... def next(self, timeout: Optional[float] = ...) -> Any: ... + def __next__(self, timeout: Optional[float] = ...) -> Any: ... class Pool(ContextManager[Pool]): def __init__(self, processes: Optional[int] = ..., diff --git a/stdlib/3/shlex.pyi b/stdlib/3/shlex.pyi index 6936d61d1..891d10698 100644 --- a/stdlib/3/shlex.pyi +++ b/stdlib/3/shlex.pyi @@ -2,7 +2,7 @@ # Based on http://docs.python.org/3.2/library/shlex.html -from typing import List, Tuple, Any, TextIO, Union, Optional, Iterator +from typing import List, Tuple, Any, TextIO, Union, Optional, Iterable, TypeVar import sys def split(s: str, comments: bool = ..., @@ -11,7 +11,9 @@ def split(s: str, comments: bool = ..., # Added in 3.3, use (undocumented) pipes.quote in previous versions. def quote(s: str) -> str: ... -class shlex(Iterator[str]): +_SLT = TypeVar('_SLT', bound=shlex) + +class shlex(Iterable[str]): commenters = ... # type: str wordchars = ... # type: str whitespace = ... # type: str @@ -44,3 +46,5 @@ class shlex(Iterator[str]): def pop_source(self) -> None: ... def error_leader(self, infile: str = ..., lineno: int = ...) -> None: ... + def __iter__(self: _SLT) -> _SLT: ... + def __next__(self) -> str: ...