mirror of
https://github.com/davidhalter/typeshed.git
synced 2026-01-11 14:08:22 +08:00
Add Async classes to typing stub.
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
from typing import Any, TypeVar, List, Callable, Tuple, Union, Dict
|
||||
from typing import Any, Awaitable, TypeVar, List, Callable, Tuple, Union, Dict
|
||||
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: Future[_T]) -> _T: ...
|
||||
def run_until_complete(self, future: Union[Awaitable[_T], Future[_T]]) -> _T: ...
|
||||
@abstractmethod
|
||||
def stop(self) -> None: ...
|
||||
@abstractmethod
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
# Stubs for typing
|
||||
|
||||
from abc import abstractmethod, ABCMeta
|
||||
from asyncio.futures import Future
|
||||
|
||||
# Definitions of special type checking related constructs. Their definition
|
||||
# are not used, so their value does not matter.
|
||||
@@ -94,7 +95,34 @@ class Iterable(Generic[_T_co]):
|
||||
class Iterator(Iterable[_T_co], Generic[_T_co]):
|
||||
@abstractmethod
|
||||
def __next__(self) -> _T_co: ...
|
||||
def __iter__(self) -> Iterator[_T_co]: ...
|
||||
def __iter__(self) -> 'Iterator[_T_co]': ...
|
||||
|
||||
class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
|
||||
@abstractmethod
|
||||
def __next__(self) -> _T_co:...
|
||||
|
||||
@abstractmethod
|
||||
def send(self, value: _T_contra) -> _T_co:...
|
||||
|
||||
@abstractmethod
|
||||
def throw(self, typ: BaseException, val: Any=None, tb=None) -> None:...
|
||||
|
||||
@abstractmethod
|
||||
def close(self) -> None:...
|
||||
|
||||
class Awaitable(Generic[_T_co]):
|
||||
@abstractmethod
|
||||
def __await__(self) -> Generator[Future, Any, _T_co]:...
|
||||
|
||||
class AsyncIterable(Generic[_T_co]):
|
||||
@abstractmethod
|
||||
def __anext__(self) -> Awaitable[_T_co]:...
|
||||
|
||||
class AsyncIterator(AsyncIterable[_T_co],
|
||||
Generic[_T_co]):
|
||||
@abstractmethod
|
||||
def __anext__(self) -> Awaitable[_T_co]:...
|
||||
def __aiter__(self) -> 'AsyncIterator[_T_co]':...
|
||||
|
||||
class Container(Generic[_T_co]):
|
||||
@abstractmethod
|
||||
|
||||
Reference in New Issue
Block a user