mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-02 17:43:25 +08:00
apply black and isort (#4287)
* apply black and isort * move some type ignores
This commit is contained in:
@@ -1,18 +1,20 @@
|
||||
import sys
|
||||
|
||||
from ._base import (
|
||||
ALL_COMPLETED as ALL_COMPLETED,
|
||||
FIRST_COMPLETED as FIRST_COMPLETED,
|
||||
FIRST_EXCEPTION as FIRST_EXCEPTION,
|
||||
ALL_COMPLETED as ALL_COMPLETED,
|
||||
CancelledError as CancelledError,
|
||||
TimeoutError as TimeoutError,
|
||||
Future as Future,
|
||||
Executor as Executor,
|
||||
wait as wait,
|
||||
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
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
from ._base import InvalidStateError as InvalidStateError
|
||||
if sys.version_info >= (3, 7):
|
||||
from ._base import BrokenExecutor as BrokenExecutor
|
||||
from .thread import ThreadPoolExecutor as ThreadPoolExecutor
|
||||
from .process import ProcessPoolExecutor as ProcessPoolExecutor
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
import sys
|
||||
import threading
|
||||
from logging import Logger
|
||||
from typing import TypeVar, Generic, Any, Iterable, Iterator, Callable, Tuple, Optional, Set, List
|
||||
from types import TracebackType
|
||||
import sys
|
||||
from typing import Any, Callable, Generic, Iterable, Iterator, List, Optional, Set, Tuple, TypeVar
|
||||
|
||||
FIRST_COMPLETED: str
|
||||
FIRST_EXCEPTION: str
|
||||
@@ -17,13 +17,14 @@ LOGGER: Logger
|
||||
class Error(Exception): ...
|
||||
class CancelledError(Error): ...
|
||||
class TimeoutError(Error): ...
|
||||
|
||||
if sys.version_info >= (3, 8):
|
||||
class InvalidStateError(Error): ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
class BrokenExecutor(RuntimeError): ...
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_T = TypeVar("_T")
|
||||
|
||||
class Future(Generic[_T]):
|
||||
def __init__(self) -> None: ...
|
||||
@@ -35,7 +36,6 @@ class Future(Generic[_T]):
|
||||
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: ...
|
||||
@@ -45,12 +45,12 @@ class Future(Generic[_T]):
|
||||
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]: ...
|
||||
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: ...
|
||||
@@ -58,9 +58,9 @@ class Executor:
|
||||
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: Iterable[Future[_T]], timeout: Optional[float] = ..., return_when: str = ...) -> Tuple[Set[Future[_T]],
|
||||
Set[Future[_T]]]: ...
|
||||
def wait(
|
||||
fs: Iterable[Future[_T]], timeout: Optional[float] = ..., return_when: str = ...
|
||||
) -> Tuple[Set[Future[_T]], Set[Future[_T]]]: ...
|
||||
|
||||
class _Waiter:
|
||||
event: threading.Event
|
||||
@@ -70,7 +70,6 @@ class _Waiter:
|
||||
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: ...
|
||||
@@ -78,13 +77,11 @@ class _AsCompletedWaiter(_Waiter):
|
||||
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
|
||||
@@ -94,7 +91,6 @@ class _AllCompletedWaiter(_Waiter):
|
||||
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: ...
|
||||
|
||||
@@ -1,23 +1,28 @@
|
||||
from typing import Any, Callable, Optional, Tuple
|
||||
from ._base import Executor
|
||||
import sys
|
||||
from typing import Any, Callable, Optional, Tuple
|
||||
|
||||
from ._base import Executor
|
||||
|
||||
EXTRA_QUEUED_CALLS: Any
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from ._base import BrokenExecutor
|
||||
class BrokenProcessPool(BrokenExecutor): ...
|
||||
|
||||
elif sys.version_info >= (3,):
|
||||
class BrokenProcessPool(RuntimeError): ...
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from multiprocessing.context import BaseContext
|
||||
|
||||
class ProcessPoolExecutor(Executor):
|
||||
def __init__(self, max_workers: Optional[int] = ...,
|
||||
mp_context: Optional[BaseContext] = ...,
|
||||
initializer: Optional[Callable[..., None]] = ...,
|
||||
initargs: Tuple[Any, ...] = ...) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
max_workers: Optional[int] = ...,
|
||||
mp_context: Optional[BaseContext] = ...,
|
||||
initializer: Optional[Callable[..., None]] = ...,
|
||||
initargs: Tuple[Any, ...] = ...,
|
||||
) -> None: ...
|
||||
|
||||
else:
|
||||
class ProcessPoolExecutor(Executor):
|
||||
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
|
||||
|
||||
@@ -1,26 +1,28 @@
|
||||
from typing import Any, Callable, Iterable, Mapping, Optional, Tuple, TypeVar, Generic
|
||||
from ._base import Executor, Future
|
||||
import sys
|
||||
from typing import Any, Callable, Generic, Iterable, Mapping, Optional, Tuple, TypeVar
|
||||
|
||||
from ._base import Executor, Future
|
||||
|
||||
if sys.version_info >= (3, 7):
|
||||
from ._base import BrokenExecutor
|
||||
class BrokenThreadPool(BrokenExecutor): ...
|
||||
|
||||
_S = TypeVar('_S')
|
||||
_S = TypeVar("_S")
|
||||
|
||||
class ThreadPoolExecutor(Executor):
|
||||
if sys.version_info >= (3, 7):
|
||||
def __init__(self, max_workers: Optional[int] = ...,
|
||||
thread_name_prefix: str = ...,
|
||||
initializer: Optional[Callable[..., None]] = ...,
|
||||
initargs: Tuple[Any, ...] = ...) -> None: ...
|
||||
def __init__(
|
||||
self,
|
||||
max_workers: Optional[int] = ...,
|
||||
thread_name_prefix: str = ...,
|
||||
initializer: Optional[Callable[..., None]] = ...,
|
||||
initargs: Tuple[Any, ...] = ...,
|
||||
) -> None: ...
|
||||
elif sys.version_info >= (3, 6) or sys.version_info < (3,):
|
||||
def __init__(self, max_workers: Optional[int] = ...,
|
||||
thread_name_prefix: str = ...) -> None: ...
|
||||
def __init__(self, max_workers: Optional[int] = ..., thread_name_prefix: str = ...) -> None: ...
|
||||
else:
|
||||
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
|
||||
|
||||
|
||||
class _WorkItem(Generic[_S]):
|
||||
future: Future[_S]
|
||||
fn: Callable[..., _S]
|
||||
|
||||
Reference in New Issue
Block a user