mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-18 18:05:57 +08:00
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.
This commit is contained in:
committed by
Jelle Zijlstra
parent
56c93c85c0
commit
a9366df7e8
@@ -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]]: ...
|
||||
|
||||
Reference in New Issue
Block a user