Skip to content

Commit 7f22db0

Browse files
author
Roy Williams
committed
Add Async classes to typing stub.
1 parent 30af935 commit 7f22db0

File tree

2 files changed

+31
-3
lines changed

2 files changed

+31
-3
lines changed

stdlib/3.4/asyncio/events.pyi

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from typing import Any, TypeVar, List, Callable, Tuple, Union, Dict
1+
from typing import Any, Awaitable, TypeVar, List, Callable, Tuple, Union, Dict
22
from abc import ABCMeta, abstractmethod
33
from asyncio.futures import Future
44

@@ -34,7 +34,7 @@ class AbstractEventLoop(metaclass=ABCMeta):
3434
@abstractmethod
3535
def run_forever(self) -> None: ...
3636
@abstractmethod
37-
def run_until_complete(self, future: Future[_T]) -> _T: ...
37+
def run_until_complete(self, future: Union[Awaitable[_T], Future[_T]]) -> _T: ...
3838
@abstractmethod
3939
def stop(self) -> None: ...
4040
@abstractmethod

stdlib/3/typing.pyi

Lines changed: 29 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
# Stubs for typing
22

33
from abc import abstractmethod, ABCMeta
4+
from asyncio.futures import Future
45

56
# Definitions of special type checking related constructs. Their definition
67
# are not used, so their value does not matter.
@@ -94,7 +95,34 @@ class Iterable(Generic[_T_co]):
9495
class Iterator(Iterable[_T_co], Generic[_T_co]):
9596
@abstractmethod
9697
def __next__(self) -> _T_co: ...
97-
def __iter__(self) -> Iterator[_T_co]: ...
98+
def __iter__(self) -> 'Iterator[_T_co]': ...
99+
100+
class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
101+
@abstractmethod
102+
def __next__(self) -> _T_co:...
103+
104+
@abstractmethod
105+
def send(self, value: _T_contra) -> _T_co:...
106+
107+
@abstractmethod
108+
def throw(self, typ: BaseException, val: Any=None, tb=None) -> None:...
109+
110+
@abstractmethod
111+
def close(self) -> None:...
112+
113+
class Awaitable(Generic[_T_co]):
114+
@abstractmethod
115+
def __await__(self) -> Generator[Future, Any, _T_co]:...
116+
117+
class AsyncIterable(Generic[_T_co]):
118+
@abstractmethod
119+
def __anext__(self) -> Awaitable[_T_co]:...
120+
121+
class AsyncIterator(AsyncIterable[_T_co],
122+
Generic[_T_co]):
123+
@abstractmethod
124+
def __anext__(self) -> Awaitable[_T_co]:...
125+
def __aiter__(self) -> 'AsyncIterator[_T_co]':...
98126

99127
class Container(Generic[_T_co]):
100128
@abstractmethod

0 commit comments

Comments
 (0)