Add missing methods to Python 2 concurrent.futures (#1236)

* Add missing methods to Python 2 concurrent.futures

Future.exception_info() and Future.set_exception_info() are methods
present only in the Python 2 backport of concurrent.futures.

* Mark timeout args as optional
This commit is contained in:
li-dan
2017-05-04 11:24:50 -04:00
committed by Jelle Zijlstra
parent 2d96eecd30
commit e080d8ea77

View File

@@ -1,4 +1,7 @@
# Stubs for concurrent.futures (Python 2)
from typing import TypeVar, Generic, Any, Iterable, Iterator, Callable, Optional, Set, Tuple, Union
from types import TracebackType
_T = TypeVar('_T')
@@ -11,17 +14,19 @@ class Future(Generic[_T]):
def cancelled(self) -> bool: ...
def running(self) -> bool: ...
def done(self) -> bool: ...
def result(self, timeout: float = ...) -> _T: ...
def exception(self, timeout: float = ...) -> Any: ...
def result(self, timeout: Optional[float] = ...) -> _T: ...
def exception(self, timeout: Optional[float] = ...) -> Any: ...
def exception_info(self, timeout: Optional[float] = ...) -> Tuple[Any, Optional[TracebackType]]: ...
def add_done_callback(self, fn: Callable[[Future], Any]) -> None: ...
def set_running_or_notify_cancel(self) -> bool: ...
def set_result(self, result: _T) -> None: ...
def set_exception(self, exception: Any) -> None: ...
def set_exception_info(self, exception: Any, traceback: TracebackType) -> None: ...
class Executor:
def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ...
def map(self, func: Callable[..., _T], *iterables: Any, timeout: float = ...) -> Iterable[_T]: ...
def map(self, func: Callable[..., _T], *iterables: Any, timeout: Optional[float] = ...) -> Iterable[_T]: ...
def shutdown(self, wait: bool = ...) -> None: ...
def __enter__(self) -> Executor: ...
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool: ...
@@ -38,4 +43,4 @@ FIRST_COMPLETED = ... # type: str
FIRST_EXCEPTION = ... # type: str
ALL_COMPLETED = ... # type: str
def as_completed(fs: Iterable[Future], timeout: float = ...) -> Iterator[Future]: ...
def as_completed(fs: Iterable[Future], timeout: Optional[float] = ...) -> Iterator[Future]: ...