mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-16 00:37:10 +08:00
Make concurrent.futures stubs identical (#2237)
Make the Python 2 and 3 concurrent.futures stubs identical so fixes get applied to both. For example, #1305 and #2233 fixed the same problem at different times, as did #1078 and #1911. By making the stubs identical, we apply the fix from #1711 to Python 2. Fixes #2234.
This commit is contained in:
committed by
Jelle Zijlstra
parent
a9366df7e8
commit
5054465746
@@ -1,4 +1,6 @@
|
||||
from typing import TypeVar, Generic, Any, Iterable, Iterator, Callable, Tuple, Optional, Set, NamedTuple
|
||||
from types import TracebackType
|
||||
import sys
|
||||
|
||||
FIRST_COMPLETED = ... # type: str
|
||||
FIRST_EXCEPTION = ... # type: str
|
||||
@@ -24,14 +26,25 @@ class Future(Generic[_T]):
|
||||
def done(self) -> bool: ...
|
||||
def add_done_callback(self, fn: Callable[[Future[_T]], Any]) -> None: ...
|
||||
def result(self, timeout: Optional[float] = ...) -> _T: ...
|
||||
def exception(self, timeout: Optional[float] = ...) -> Optional[BaseException]: ...
|
||||
def set_running_or_notify_cancel(self) -> bool: ...
|
||||
def set_result(self, result: _T) -> None: ...
|
||||
def set_exception(self, exception: Optional[BaseException]) -> None: ...
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
def exception(self, timeout: Optional[float] = ...) -> Optional[BaseException]: ...
|
||||
def set_exception(self, exception: Optional[BaseException]) -> None: ...
|
||||
else:
|
||||
def exception(self, timeout: Optional[float] = ...) -> Any: ...
|
||||
def exception_info(self, timeout: Optional[float] = ...) -> Tuple[Any, Optional[TracebackType]]: ...
|
||||
def set_exception(self, exception: Any) -> 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]: ...
|
||||
def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ..., chunksize: int = ...) -> Iterator[_T]: ...
|
||||
if sys.version_info >= (3, 5):
|
||||
def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ..., chunksize: int = ...) -> Iterator[_T]: ...
|
||||
else:
|
||||
def map(self, func: Callable[..., _T], *iterables: Iterable[Any], timeout: Optional[float] = ...,) -> Iterator[_T]: ...
|
||||
def shutdown(self, wait: bool = ...) -> None: ...
|
||||
def __enter__(self: _T) -> _T: ...
|
||||
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool: ...
|
||||
|
||||
@@ -1,9 +1,11 @@
|
||||
from typing import Optional, Any
|
||||
from ._base import Future, Executor
|
||||
import sys
|
||||
|
||||
EXTRA_QUEUED_CALLS = ... # type: Any
|
||||
|
||||
class BrokenProcessPool(RuntimeError): ...
|
||||
if sys.version_info >= (3,):
|
||||
class BrokenProcessPool(RuntimeError): ...
|
||||
|
||||
class ProcessPoolExecutor(Executor):
|
||||
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user