mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-06 12:14:27 +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: ...
|
||||
|
||||
@@ -14,6 +14,11 @@ consistent_files = [
|
||||
{'stdlib/3.4/enum.pyi', 'third_party/3/enum.pyi'},
|
||||
{'stdlib/2/os/path.pyi', 'stdlib/3/os/path.pyi'},
|
||||
{'stdlib/3/unittest/mock.pyi', 'third_party/2and3/mock.pyi'},
|
||||
{'stdlib/3/concurrent/__init__.pyi', 'third_party/2/concurrent/__init__.pyi'},
|
||||
{'stdlib/3/concurrent/futures/__init__.pyi', 'third_party/2/concurrent/futures/__init__.pyi'},
|
||||
{'stdlib/3/concurrent/futures/_base.pyi', 'third_party/2/concurrent/futures/_base.pyi'},
|
||||
{'stdlib/3/concurrent/futures/thread.pyi', 'third_party/2/concurrent/futures/thread.pyi'},
|
||||
{'stdlib/3/concurrent/futures/process.pyi', 'third_party/2/concurrent/futures/process.pyi'},
|
||||
]
|
||||
|
||||
def main():
|
||||
|
||||
49
third_party/2/concurrent/futures/__init__.pyi
vendored
49
third_party/2/concurrent/futures/__init__.pyi
vendored
@@ -1,46 +1,3 @@
|
||||
# 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')
|
||||
|
||||
class Error(Exception): ...
|
||||
class CancelledError(Error): ...
|
||||
class TimeoutError(Error): ...
|
||||
|
||||
class Future(Generic[_T]):
|
||||
def cancel(self) -> bool: ...
|
||||
def cancelled(self) -> bool: ...
|
||||
def running(self) -> bool: ...
|
||||
def done(self) -> bool: ...
|
||||
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[_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: 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] = ...) -> Iterator[_T]: ...
|
||||
def shutdown(self, wait: bool = ...) -> None: ...
|
||||
def __enter__(self) -> Executor: ...
|
||||
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool: ...
|
||||
|
||||
class ThreadPoolExecutor(Executor):
|
||||
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
|
||||
|
||||
class ProcessPoolExecutor(Executor):
|
||||
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
|
||||
|
||||
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[_T]], timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ...
|
||||
from ._base import * # noqa: F403
|
||||
from .thread import * # noqa: F403
|
||||
from .process import * # noqa: F403
|
||||
|
||||
54
third_party/2/concurrent/futures/_base.pyi
vendored
Normal file
54
third_party/2/concurrent/futures/_base.pyi
vendored
Normal file
@@ -0,0 +1,54 @@
|
||||
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
|
||||
ALL_COMPLETED = ... # type: str
|
||||
PENDING = ... # type: Any
|
||||
RUNNING = ... # type: Any
|
||||
CANCELLED = ... # type: Any
|
||||
CANCELLED_AND_NOTIFIED = ... # type: Any
|
||||
FINISHED = ... # type: Any
|
||||
LOGGER = ... # type: Any
|
||||
|
||||
class Error(Exception): ...
|
||||
class CancelledError(Error): ...
|
||||
class TimeoutError(Error): ...
|
||||
|
||||
_T = TypeVar('_T')
|
||||
|
||||
class Future(Generic[_T]):
|
||||
def __init__(self) -> None: ...
|
||||
def cancel(self) -> bool: ...
|
||||
def cancelled(self) -> bool: ...
|
||||
def running(self) -> bool: ...
|
||||
def done(self) -> bool: ...
|
||||
def add_done_callback(self, fn: Callable[[Future[_T]], Any]) -> None: ...
|
||||
def result(self, timeout: Optional[float] = ...) -> _T: ...
|
||||
def set_running_or_notify_cancel(self) -> bool: ...
|
||||
def set_result(self, result: _T) -> 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]: ...
|
||||
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: ...
|
||||
|
||||
def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ...
|
||||
|
||||
def wait(fs: Iterable[Future[_T]], timeout: Optional[float] = ..., return_when: str = ...) -> Tuple[Set[Future[_T]], Set[Future[_T]]]: ...
|
||||
11
third_party/2/concurrent/futures/process.pyi
vendored
Normal file
11
third_party/2/concurrent/futures/process.pyi
vendored
Normal file
@@ -0,0 +1,11 @@
|
||||
from typing import Optional, Any
|
||||
from ._base import Future, Executor
|
||||
import sys
|
||||
|
||||
EXTRA_QUEUED_CALLS = ... # type: Any
|
||||
|
||||
if sys.version_info >= (3,):
|
||||
class BrokenProcessPool(RuntimeError): ...
|
||||
|
||||
class ProcessPoolExecutor(Executor):
|
||||
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
|
||||
10
third_party/2/concurrent/futures/thread.pyi
vendored
Normal file
10
third_party/2/concurrent/futures/thread.pyi
vendored
Normal file
@@ -0,0 +1,10 @@
|
||||
from typing import Optional
|
||||
from ._base import Executor, Future
|
||||
import sys
|
||||
|
||||
class ThreadPoolExecutor(Executor):
|
||||
if sys.version_info >= (3, 6):
|
||||
def __init__(self, max_workers: Optional[int] = ...,
|
||||
thread_name_prefix: str = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
|
||||
Reference in New Issue
Block a user