mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-09 13:34:58 +08:00
add types.AsyncGeneratorType (#1322)
This commit is contained in:
committed by
Guido van Rossum
parent
fefdf185c7
commit
e8013fd808
@@ -5,8 +5,8 @@
|
||||
|
||||
import sys
|
||||
from typing import (
|
||||
Any, Callable, Dict, Generic, Iterator, Mapping, Optional, Tuple, TypeVar,
|
||||
Union, overload
|
||||
Any, Awaitable, Callable, Dict, Generic, Iterator, Mapping, Optional, Tuple, TypeVar,
|
||||
Union, overload, Type
|
||||
)
|
||||
|
||||
# ModuleType is exported from this module, but for circular import
|
||||
@@ -14,6 +14,8 @@ from typing import (
|
||||
from _importlib_modulespec import ModuleType as ModuleType # Exported
|
||||
|
||||
_T = TypeVar('_T')
|
||||
_T_co = TypeVar('_T_co', covariant=True)
|
||||
_T_contra = TypeVar('_T_contra', contravariant=True)
|
||||
_KT = TypeVar('_KT')
|
||||
_VT = TypeVar('_VT')
|
||||
|
||||
@@ -92,6 +94,21 @@ class GeneratorType:
|
||||
@overload
|
||||
def throw(self, typ: type, val: BaseException = ..., tb: 'TracebackType' = ...) -> Any: ...
|
||||
|
||||
if sys.version_info >= (3, 6):
|
||||
class AsyncGeneratorType(Generic[_T_co, _T_contra]):
|
||||
ag_await: Optional[Awaitable[Any]]
|
||||
ag_frame: FrameType
|
||||
ag_running: bool
|
||||
ag_code: CodeType
|
||||
def __aiter__(self) -> Awaitable[AsyncGeneratorType[_T_co, _T_contra]]: ...
|
||||
def __anext__(self) -> Awaitable[_T_co]: ...
|
||||
def asend(self, val: _T_contra) -> Awaitable[_T_co]: ...
|
||||
@overload
|
||||
def athrow(self, val: BaseException) -> Awaitable[_T_co]: ...
|
||||
@overload
|
||||
def athrow(self, typ: Type[BaseException], val: BaseException, tb: TracebackType = ...) -> Awaitable[_T_co]: ...
|
||||
def aclose(self) -> Awaitable[_T_co]: ...
|
||||
|
||||
class CoroutineType:
|
||||
cr_await = ... # type: Optional[Any]
|
||||
cr_code = ... # type: CodeType
|
||||
|
||||
Reference in New Issue
Block a user