8000 add AsyncGenerator to typing.pyi, collections/abc.pyi and collections… · python/typeshed@df9d11b · GitHub
[go: up one dir, main page]

Skip to content

Commit df9d11b

Browse files
JelleZijlstragvanrossum
authored andcommitted
add AsyncGenerator to typing.pyi, collections/abc.pyi and collections/__init__.pyi (#815)
This parallels python/typing#346
1 parent 2195b9d commit df9d11b

File tree

3 files changed

+22
-0
lines changed

3 files changed

+22
-0
lines changed

stdlib/3/collections/__init__.pyi

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
# TODO more abstract base classes (interfaces in mypy)
66

77
# These are not exported.
8+
import sys
89
from typing import (
910
TypeVar, Generic, Dict, overload, List, Tuple,
1011
Callable, Any, Type, Optional, Union
@@ -35,6 +36,8 @@ from typing import (
3536
MutableSet as MutableSet,
3637
AbstractSet as Set,
3738
)
39+
if sys.version_info >= (3, 6):
40+
from typing import AsyncGenerator as AsyncGenerator
3841

3942
_T = TypeVar('_T')
4043
_KT = TypeVar('_KT')

stdlib/3/collections/abc.pyi

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,4 +35,5 @@ if sys.version_info >= (3, 5):
3535
if sys.version_info >= (3, 6):
3636
from . import (
3737
Reversible as Reversible,
38+
AsyncGenerator as AsyncGenerator,
3839
)

stdlib/3/typing.pyi

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -151,6 +151,24 @@ class AsyncIterator(AsyncIterable[_T_co],
151151
def __anext__(self) -> Awaitable[_T_co]: ...
152152
def __aiter__(self) -> 'AsyncIterator[_T_co]': ...
153153

154+
if sys.version_info >= (3, 6):
155+
class AsyncGenerator(AsyncIterator[_T_co], Generic[_T_co, _T_contra]):
156+
@abstractmethod
157+
def __anext__(self) -> Awaitable[_T_co]: ...
158+
159+
@abstractmethod
160+
def asend(self, value: _T_contra) -> Awaitable[_T_co]: ...
161+
162+
@abstractmethod
163+
def athrow(self, typ: Type[BaseException], val: Optional[BaseException] = None,
164+
tb: Any = None) -> Awaitable[None]: ...
165+
166+
@abstractmethod
167+
def aclose(self) -> Awaitable[None]: ...
168+
169+
@abstractmethod
170+
def __aiter__(self) -> 'AsyncGenerator[_T_co, _T_contra]': ...
171+
154172
class Container(Generic[_T_co]):
155173
@abstractmethod
156174
def __contains__(self, x: object) -> bool: ...

0 commit comments

Comments
 (0)
0