mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-02-16 23:13:37 +08:00
Re-organize directory structure (#4971)
See discussion in #2491 Co-authored-by: Ivan Levkivskyi <ilevkivskyi@dropbox.com>
This commit is contained in:
3
stubs/futures/METADATA.toml
Normal file
3
stubs/futures/METADATA.toml
Normal file
@@ -0,0 +1,3 @@
|
||||
version = "0.1"
|
||||
python2 = true
|
||||
python3 = false
|
||||
0
stubs/futures/concurrent/__init__.pyi
Normal file
0
stubs/futures/concurrent/__init__.pyi
Normal file
13
stubs/futures/concurrent/futures/__init__.pyi
Normal file
13
stubs/futures/concurrent/futures/__init__.pyi
Normal file
@@ -0,0 +1,13 @@
|
||||
from ._base import (
|
||||
ALL_COMPLETED as ALL_COMPLETED,
|
||||
FIRST_COMPLETED as FIRST_COMPLETED,
|
||||
FIRST_EXCEPTION as FIRST_EXCEPTION,
|
||||
CancelledError as CancelledError,
|
||||
Executor as Executor,
|
||||
Future as Future,
|
||||
TimeoutError as TimeoutError,
|
||||
as_completed as as_completed,
|
||||
wait as wait,
|
||||
)
|
||||
from .process import ProcessPoolExecutor as ProcessPoolExecutor
|
||||
from .thread import ThreadPoolExecutor as ThreadPoolExecutor
|
||||
92
stubs/futures/concurrent/futures/_base.pyi
Normal file
92
stubs/futures/concurrent/futures/_base.pyi
Normal file
@@ -0,0 +1,92 @@
|
||||
import threading
|
||||
from abc import abstractmethod
|
||||
from logging import Logger
|
||||
from types import TracebackType
|
||||
from typing import Any, Callable, Container, Generic, Iterable, Iterator, List, Optional, Protocol, Set, Tuple, TypeVar
|
||||
|
||||
FIRST_COMPLETED: str
|
||||
FIRST_EXCEPTION: str
|
||||
ALL_COMPLETED: str
|
||||
PENDING: str
|
||||
RUNNING: str
|
||||
CANCELLED: str
|
||||
CANCELLED_AND_NOTIFIED: str
|
||||
FINISHED: str
|
||||
LOGGER: Logger
|
||||
|
||||
class Error(Exception): ...
|
||||
class CancelledError(Error): ...
|
||||
class TimeoutError(Error): ...
|
||||
|
||||
_T = TypeVar("_T")
|
||||
|
||||
_T_co = TypeVar("_T_co", covariant=True)
|
||||
|
||||
# Copied over Collection implementation as it does not exist in Python 2 and <3.6.
|
||||
# Also to solve pytype issues with _Collection.
|
||||
class _Collection(Iterable[_T_co], Container[_T_co], Protocol[_T_co]):
|
||||
# Implement Sized (but don't have it as a base class).
|
||||
@abstractmethod
|
||||
def __len__(self) -> int: ...
|
||||
|
||||
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: ...
|
||||
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] = ...) -> 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) -> Optional[bool]: ...
|
||||
|
||||
def as_completed(fs: Iterable[Future[_T]], timeout: Optional[float] = ...) -> Iterator[Future[_T]]: ...
|
||||
def wait(
|
||||
fs: _Collection[Future[_T]], timeout: Optional[float] = ..., return_when: str = ...
|
||||
) -> Tuple[Set[Future[_T]], Set[Future[_T]]]: ...
|
||||
|
||||
class _Waiter:
|
||||
event: threading.Event
|
||||
finished_futures: List[Future[Any]]
|
||||
def __init__(self) -> None: ...
|
||||
def add_result(self, future: Future[Any]) -> None: ...
|
||||
def add_exception(self, future: Future[Any]) -> None: ...
|
||||
def add_cancelled(self, future: Future[Any]) -> None: ...
|
||||
|
||||
class _AsCompletedWaiter(_Waiter):
|
||||
lock: threading.Lock
|
||||
def __init__(self) -> None: ...
|
||||
def add_result(self, future: Future[Any]) -> None: ...
|
||||
def add_exception(self, future: Future[Any]) -> None: ...
|
||||
def add_cancelled(self, future: Future[Any]) -> None: ...
|
||||
|
||||
class _FirstCompletedWaiter(_Waiter):
|
||||
def add_result(self, future: Future[Any]) -> None: ...
|
||||
def add_exception(self, future: Future[Any]) -> None: ...
|
||||
def add_cancelled(self, future: Future[Any]) -> None: ...
|
||||
|
||||
class _AllCompletedWaiter(_Waiter):
|
||||
num_pending_calls: int
|
||||
stop_on_exception: bool
|
||||
lock: threading.Lock
|
||||
def __init__(self, num_pending_calls: int, stop_on_exception: bool) -> None: ...
|
||||
def add_result(self, future: Future[Any]) -> None: ...
|
||||
def add_exception(self, future: Future[Any]) -> None: ...
|
||||
def add_cancelled(self, future: Future[Any]) -> None: ...
|
||||
|
||||
class _AcquireFutures:
|
||||
futures: Iterable[Future[Any]]
|
||||
def __init__(self, futures: Iterable[Future[Any]]) -> None: ...
|
||||
def __enter__(self) -> None: ...
|
||||
def __exit__(self, *args: Any) -> None: ...
|
||||
8
stubs/futures/concurrent/futures/process.pyi
Normal file
8
stubs/futures/concurrent/futures/process.pyi
Normal file
@@ -0,0 +1,8 @@
|
||||
from typing import Any, Optional
|
||||
|
||||
from ._base import Executor
|
||||
|
||||
EXTRA_QUEUED_CALLS: Any
|
||||
|
||||
class ProcessPoolExecutor(Executor):
|
||||
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
|
||||
16
stubs/futures/concurrent/futures/thread.pyi
Normal file
16
stubs/futures/concurrent/futures/thread.pyi
Normal file
@@ -0,0 +1,16 @@
|
||||
from typing import Any, Callable, Generic, Iterable, Mapping, Optional, Tuple, TypeVar
|
||||
|
||||
from ._base import Executor, Future
|
||||
|
||||
_S = TypeVar("_S")
|
||||
|
||||
class ThreadPoolExecutor(Executor):
|
||||
def __init__(self, max_workers: Optional[int] = ..., thread_name_prefix: str = ...) -> None: ...
|
||||
|
||||
class _WorkItem(Generic[_S]):
|
||||
future: Future[_S]
|
||||
fn: Callable[..., _S]
|
||||
args: Iterable[Any]
|
||||
kwargs: Mapping[str, Any]
|
||||
def __init__(self, future: Future[_S], fn: Callable[..., _S], args: Iterable[Any], kwargs: Mapping[str, Any]) -> None: ...
|
||||
def run(self) -> None: ...
|
||||
Reference in New Issue
Block a user