Make Future stub resemble reality better.

This commit is contained in:
Guido van Rossum
2016-01-19 14:23:09 -08:00
parent 740568ed25
commit a080d6cee5

View File

@@ -1,4 +1,4 @@
from typing import Any, Callable, TypeVar, List, Generic, Iterable, Iterator
from typing import Any, Union, Callable, TypeVar, List, Generic, Iterable, Generator
from asyncio.events import AbstractEventLoop
# __all__ = ['CancelledError', 'TimeoutError',
# 'InvalidStateError',
@@ -10,16 +10,16 @@ _T = TypeVar('_T')
class _TracebackLogger:
__slots__ = [] # type: List[str]
exc = ... # type: Exception
exc = ... # type: BaseException
tb = [] # type: List[str]
def __init__(self, exc: Any, loop: AbstractEventLoop) -> None: ...
def activate(self) -> None: ...
def clear(self) -> None: ...
def __del__(self) -> None: ...
class Future(Iterator[_T], Generic[_T]):
class Future(Iterable[_T], Generic[_T]):
_state = ... # type: str
_exception = ... # type: Exception
_exception = ... # type: BaseException
_blocking = False
_log_traceback = False
_tb_logger = _TracebackLogger
@@ -31,11 +31,10 @@ class Future(Iterator[_T], Generic[_T]):
def cancelled(self) -> bool: ...
def done(self) -> bool: ...
def result(self) -> _T: ...
def exception(self) -> Any: ...
def exception(self) -> BaseException: ...
def add_done_callback(self, fn: Callable[[Future[_T]], Any]) -> None: ...
def remove_done_callback(self, fn: Callable[[Future[_T]], Any]) -> int: ...
def set_result(self, result: _T) -> None: ...
def set_exception(self, exception: Any) -> None: ...
def set_exception(self, exception: Union[type, BaseException]) -> None: ...
def _copy_state(self, other: Any) -> None: ...
def __iter__(self) -> Iterator[_T]: ...
def __next__(self) -> _T: ...
def __iter__(self) -> Generator[Any, None, _T]: ...