From a9366df7e8c21d5e051525ec5b7dc09c76a4269f Mon Sep 17 00:00:00 2001 From: Daniel Li Date: Fri, 15 Jun 2018 11:21:01 -0400 Subject: [PATCH] Improve signatures in concurrent.futures backport (#2233) Use parameterized types in Future.add_done_callback(), wait(), and as_completed(). Mark the traceback argument to Future.set_exception_info() as optional. --- third_party/2/concurrent/futures/__init__.pyi | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/third_party/2/concurrent/futures/__init__.pyi b/third_party/2/concurrent/futures/__init__.pyi index 4604830ed..dfae50b23 100644 --- a/third_party/2/concurrent/futures/__init__.pyi +++ b/third_party/2/concurrent/futures/__init__.pyi @@ -17,12 +17,12 @@ class Future(Generic[_T]): 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 add_done_callback(self, fn: Callable[[Future[_T]], 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: ... + def set_exception_info(self, exception: Any, traceback: Optional[TracebackType]) -> None: ... class Executor: def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ... @@ -37,10 +37,10 @@ class ThreadPoolExecutor(Executor): class ProcessPoolExecutor(Executor): def __init__(self, max_workers: Optional[int] = ...) -> None: ... -def wait(fs: Iterable[Future], timeout: Optional[float] = ..., return_when: str = ...) -> Tuple[Set[Future], Set[Future]]: ... +def wait(fs: Iterable[Future[_T]], timeout: Optional[float] = ..., return_when: str = ...) -> Tuple[Set[Future[_T]], Set[Future[_T]]]: ... FIRST_COMPLETED = ... # type: str FIRST_EXCEPTION = ... # type: str ALL_COMPLETED = ... # type: str -def as_completed(fs: Iterable[Future], timeout: Optional[float] = ...) -> Iterator[Future]: ... +def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ...