Skip to content

Commit a9366df

Browse files
li-danJelleZijlstra
authored andcommitted
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.
1 parent 56c93c8 commit a9366df

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

third_party/2/concurrent/futures/__init__.pyi

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,12 +17,12 @@ class Future(Generic[_T]):
1717
def result(self, timeout: Optional[float] = ...) -> _T: ...
1818
def exception(self, timeout: Optional[float] = ...) -> Any: ...
1919
def exception_info(self, timeout: Optional[float] = ...) -> Tuple[Any, Optional[TracebackType]]: ...
20-
def add_done_callback(self, fn: Callable[[Future], Any]) -> None: ...
20+
def add_done_callback(self, fn: Callable[[Future[_T]], Any]) -> None: ...
2121

2222
def set_running_or_notify_cancel(self) -> bool: ...
2323
def set_result(self, result: _T) -> None: ...
2424
def set_exception(self, exception: Any) -> None: ...
25-
def set_exception_info(self, exception: Any, traceback: TracebackType) -> None: ...
25+
def set_exception_info(self, exception: Any, traceback: Optional[TracebackType]) -> None: ...
2626

2727
class Executor:
2828
def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ...
@@ -37,10 +37,10 @@ class ThreadPoolExecutor(Executor):
3737
class ProcessPoolExecutor(Executor):
3838
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
3939

40-
def wait(fs: Iterable[Future], timeout: Optional[float] = ..., return_when: str = ...) -> Tuple[Set[Future], Set[Future]]: ...
40+
def wait(fs: Iterable[Future[_T]], timeout: Optional[float] = ..., return_when: str = ...) -> Tuple[Set[Future[_T]], Set[Future[_T]]]: ...
4141

4242
FIRST_COMPLETED = ... # type: str
4343
FIRST_EXCEPTION = ... # type: str
4444
ALL_COMPLETED = ... # type: str
4545

46-
def as_completed(fs: Iterable[Future], timeout: Optional[float] = ...) -> Iterator[Future]: ...
46+
def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ...

0 commit comments

Comments
 (0)