Fixed types in stdlib/3/concurrent/futures: (#557)

* Fixed types in stdlib/3/concurrent/futures:
 - Remove private classes from public interface
 - Add missing types

* Remove "generated by stubgen" headers from modified type stubs

* - Use ... as default value
- Fix space formatting

* Replace more default values with '...'

* Use 'None' as default value where specified by documentation

* Use explicit Optional[T] type instead of default value None
This commit is contained in:
Sebastian Meßmer
2016-09-19 17:13:12 +02:00
committed by Guido van Rossum
parent b5e372bc7f
commit 93ef68315b
4 changed files with 24 additions and 106 deletions

View File

@@ -1,7 +1,3 @@
# Stubs for concurrent.futures (Python 3.5)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from ._base import *
from .thread import *
from .process import *

View File

@@ -1,8 +1,4 @@
# Stubs for concurrent.futures._base (Python 3.5)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from typing import TypeVar, Generic, Any, Iterable, Iterator, Callable, Tuple
from typing import TypeVar, Generic, Any, Iterable, Iterator, Callable, Tuple, Optional
from collections import namedtuple
FIRST_COMPLETED = ... # type: Any
@@ -19,41 +15,6 @@ class Error(Exception): ...
class CancelledError(Error): ...
class TimeoutError(Error): ...
class _Waiter:
event = ... # type: Any
finished_futures = ... # type: Any
def __init__(self): ...
def add_result(self, future): ...
def add_exception(self, future): ...
def add_cancelled(self, future): ...
class _AsCompletedWaiter(_Waiter):
lock = ... # type: Any
def __init__(self): ...
def add_result(self, future): ...
def add_exception(self, future): ...
def add_cancelled(self, future): ...
class _FirstCompletedWaiter(_Waiter):
def add_result(self, future): ...
def add_exception(self, future): ...
def add_cancelled(self, future): ...
class _AllCompletedWaiter(_Waiter):
num_pending_calls = ... # type: Any
stop_on_exception = ... # type: Any
lock = ... # type: Any
def __init__(self, num_pending_calls, stop_on_exception): ...
def add_result(self, future): ...
def add_exception(self, future): ...
def add_cancelled(self, future): ...
class _AcquireFutures:
futures = ... # type: Any
def __init__(self, futures): ...
def __enter__(self): ...
def __exit__(self, *args): ...
DoneAndNotDoneFutures = namedtuple('DoneAndNotDoneFutures', 'done not_done')
_T = TypeVar('_T')
@@ -65,19 +26,19 @@ class Future(Generic[_T]):
def running(self) -> bool: ...
def done(self) -> bool: ...
def add_done_callback(self, fn: Callable[[Future], Any]) -> None: ...
def result(self, timeout: float = ...) -> _T: ...
def exception(self, timeout: float = ...) -> Exception: ...
def result(self, timeout: Optional[float] = ...) -> _T: ...
def exception(self, timeout: Optional[float] = ...) -> Exception: ...
def set_running_or_notify_cancel(self) -> None: ...
def set_result(self, result: _T) -> None: ...
def set_exception(self, exception: Exception) -> None: ...
class Executor:
def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ...
def map(self, func: Callable[..., _T], *iterables: Any, timeout: float = ...) -> Iterable[_T]: ...
def map(self, func: Callable[..., _T], *iterables: Any, timeout: Optional[float] = ..., chunksize: int = ...) -> Iterable[_T]: ...
def shutdown(self, wait: bool = ...) -> None: ...
def __enter__(self) -> Executor: ...
def __exit__(self, exc_type: Any, exc_val: Any, exc_tb: Any) -> bool: ...
def as_completed(fs: Iterable[Future], timeout: float = ...) -> Iterator[Future]: ...
def as_completed(fs: Iterable[Future], timeout: Optional[float] = ...) -> Iterator[Future]: ...
def wait(fs: Iterable[Future], timeout: float = ..., return_when: str = ...) -> Tuple[Iterable[Future], Iterable[Future]]: ...
def wait(fs: Iterable[Future], timeout: Optional[float] = ..., return_when: str = ...) -> Tuple[Iterable[Future], Iterable[Future]]: ...

View File

@@ -1,46 +1,15 @@
# Stubs for concurrent.futures.process (Python 3.5)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from typing import Any
from . import _base
from typing import Any, Callable, TypeVar, Iterable, Optional
from ._base import Future, Executor
EXTRA_QUEUED_CALLS = ... # type: Any
class _RemoteTraceback(Exception):
tb = ... # type: Any
def __init__(self, tb): ...
class _ExceptionWithTraceback:
exc = ... # type: Any
tb = ... # type: Any
def __init__(self, exc, tb): ...
def __reduce__(self): ...
class _WorkItem:
future = ... # type: Any
fn = ... # type: Any
args = ... # type: Any
kwargs = ... # type: Any
def __init__(self, future, fn, args, kwargs): ...
class _ResultItem:
work_id = ... # type: Any
exception = ... # type: Any
result = ... # type: Any
def __init__(self, work_id, exception=None, result=None): ...
class _CallItem:
work_id = ... # type: Any
fn = ... # type: Any
args = ... # type: Any
kwargs = ... # type: Any
def __init__(self, work_id, fn, args, kwargs): ...
class BrokenProcessPool(RuntimeError): ...
class ProcessPoolExecutor(_base.Executor):
def __init__(self, max_workers=None): ...
def submit(self, fn, *args, **kwargs): ...
def map(self, fn, *iterables, timeout=None, chunksize=1): ...
def shutdown(self, wait=True): ...
_T = TypeVar('_T')
class ProcessPoolExecutor(Executor):
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ...
def map(self, func: Callable[..., _T], *iterables: Any, timeout: Optional[float] = ..., chunksize: int = ...) -> Iterable[_T]: ...
def shutdown(self, wait: bool = ...) -> None: ...

View File

@@ -1,19 +1,11 @@
# Stubs for concurrent.futures.thread (Python 3.5)
#
# NOTE: This dynamically typed stub was automatically generated by stubgen.
from typing import Any, TypeVar, Callable, Iterable, Optional
from ._base import Executor, Future
from typing import Any
from . import _base
_T = TypeVar('_T')
class _WorkItem:
future = ... # type: Any
fn = ... # type: Any
args = ... # type: Any
kwargs = ... # type: Any
def __init__(self, future, fn, args, kwargs): ...
def run(self): ...
class ThreadPoolExecutor(Executor):
def __init__(self, max_workers: Optional[int] = ...) -> None: ...
def submit(self, fn: Callable[..., _T], *args: Any, **kwargs: Any) -> Future[_T]: ...
def map(self, func: Callable[..., _T], *iterables: Any, timeout: Optional[float] = ..., chunksize: int = ...) -> Iterable[_T]: ...
def shutdown(self, wait: bool = ...) -> None: ...
class ThreadPoolExecutor(_base.Executor):
def __init__(self, max_workers=None): ...
def submit(self, fn, *args, **kwargs): ...
def shutdown(self, wait=True): ...