mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-08 04:54:47 +08:00
Fix up uses of Future as an argument in asyncio
Most functions which can take a Future can take Generators as well.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Awaitable, TypeVar, List, Callable, Tuple, Union, Dict
|
||||
from typing import Any, Awaitable, TypeVar, List, Callable, Tuple, Union, Dict, Generator
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from asyncio.futures import Future
|
||||
|
||||
@@ -34,7 +34,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
|
||||
@abstractmethod
|
||||
def run_forever(self) -> None: ...
|
||||
@abstractmethod
|
||||
def run_until_complete(self, future: Union[Awaitable[_T], Future[_T]]) -> _T: ...
|
||||
def run_until_complete(self, future: Union[Awaitable[_T], Future[_T], Generator[Any, Any, _T]]) -> _T: ...
|
||||
@abstractmethod
|
||||
def stop(self) -> None: ...
|
||||
@abstractmethod
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
from typing import Any, Iterable, TypeVar, Set, Dict, List, TextIO, Union, Tuple, Generic, Callable
|
||||
from typing import Any, Iterable, TypeVar, Set, Dict, List, TextIO, Union, Tuple, Generic, Callable, Generator
|
||||
from asyncio.events import AbstractEventLoop
|
||||
from asyncio.futures import Future
|
||||
# __all__ = ['iscoroutinefunction', 'iscoroutine',
|
||||
@@ -18,7 +18,7 @@ def coroutine(f: _T) -> _T: ... # Here comes and go a function
|
||||
def sleep(delay: float, result: _T = ..., loop: AbstractEventLoop = ...) -> Future[_T]: ...
|
||||
def wait(fs: List[Task[_T]], *, loop: AbstractEventLoop = ...,
|
||||
timeout: float = ..., return_when: str = ...) -> Future[Tuple[Set[Future[_T]], Set[Future[_T]]]]: ...
|
||||
def wait_for(fut: Future[_T], timeout: float, *, loop: AbstractEventLoop = ...) -> Future[_T]: ...
|
||||
def wait_for(fut: Union[Future[_T], Generator[Any, None, _T]], timeout: float, *, loop: AbstractEventLoop = ...) -> Future[_T]: ...
|
||||
|
||||
|
||||
class Task(Future[_T], Generic[_T]):
|
||||
@@ -28,7 +28,7 @@ class Task(Future[_T], Generic[_T]):
|
||||
def current_task(cls, loop: AbstractEventLoop = ...) -> Task: ...
|
||||
@classmethod
|
||||
def all_tasks(cls, loop: AbstractEventLoop = ...) -> Set[Task]: ...
|
||||
def __init__(self, coro: Future[_T], *, loop: AbstractEventLoop = ...) -> None: ...
|
||||
def __init__(self, coro: Union[Future[_T], Generator[Any, None, _T]], *, loop: AbstractEventLoop = ...) -> None: ...
|
||||
def __repr__(self) -> str: ...
|
||||
def get_stack(self, *, limit: int = ...) -> List[Any]: ... # return List[stackframe]
|
||||
def print_stack(self, *, limit: int = ..., file: TextIO = ...) -> None: ...
|
||||
|
||||
Reference in New Issue
Block a user