mirror of
https://github.com/davidhalter/typeshed.git
synced 2025-12-07 04:34:28 +08:00
Added missing attributes of typing.Generator and typing.AsyncGenerator (#886)
This commit is contained in:
committed by
Guido van Rossum
parent
72d275bbf5
commit
8b26422b95
@@ -1,8 +1,9 @@
|
||||
# Stubs for typing (Python 2.7)
|
||||
|
||||
from abc import abstractmethod, ABCMeta
|
||||
from types import CodeType, FrameType
|
||||
|
||||
# Definitions of special type checking related constructs. Their definition
|
||||
# Definitions of special type checking related constructs. Their definitions
|
||||
# are not used, so their value does not matter.
|
||||
|
||||
overload = object()
|
||||
@@ -109,6 +110,10 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
|
||||
@abstractmethod
|
||||
def close(self) -> None: ...
|
||||
|
||||
gi_code = ... # type: CodeType
|
||||
gi_frame = ... # type: FrameType
|
||||
gi_running = ... # type: bool
|
||||
|
||||
class Container(Generic[_T_co]):
|
||||
@abstractmethod
|
||||
def __contains__(self, x: object) -> bool: ...
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
import sys
|
||||
from abc import abstractmethod, ABCMeta
|
||||
from types import CodeType, FrameType
|
||||
|
||||
# Definitions of special type checking related constructs. Their definition
|
||||
# are not used, so their value does not matter.
|
||||
@@ -120,6 +121,11 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
|
||||
@abstractmethod
|
||||
def __iter__(self) -> 'Generator[_T_co, _T_contra, _V_co]': ...
|
||||
|
||||
gi_code = ... # type: CodeType
|
||||
gi_frame = ... # type: FrameType
|
||||
gi_running = ... # type: bool
|
||||
gi_yieldfrom = ... # type: Optional[Generator]
|
||||
|
||||
# TODO: Several types should only be defined if sys.python_version >= (3, 5):
|
||||
# Awaitable, AsyncIterator, AsyncIterable, Coroutine, Collection, ContextManager.
|
||||
# See https: //github.com/python/typeshed/issues/655 for why this is not easy.
|
||||
@@ -175,6 +181,11 @@ if sys.version_info >= (3, 6):
|
||||
@abstractmethod
|
||||
def __aiter__(self) -> 'AsyncGenerator[_T_co, _T_contra]': ...
|
||||
|
||||
ag_await = ... # type: Any
|
||||
ag_code = ... # type: CodeType
|
||||
ag_frame = ... # type: FrameType
|
||||
ag_running = ... # type: bool
|
||||
|
||||
class Container(Generic[_T_co]):
|
||||
@abstractmethod
|
||||
def __contains__(self, x: object) -> bool: ...
|
||||
|
||||
Reference in New Issue
Block a user