From 8b26422b9517c4b271887811279f4e58f400ec1e Mon Sep 17 00:00:00 2001 From: Andrey Vlasovskikh Date: Wed, 29 Mar 2017 20:09:24 +0200 Subject: [PATCH] Added missing attributes of typing.Generator and typing.AsyncGenerator (#886) --- stdlib/2/typing.pyi | 7 ++++++- stdlib/3/typing.pyi | 11 +++++++++++ 2 files changed, 17 insertions(+), 1 deletion(-) diff --git a/stdlib/2/typing.pyi b/stdlib/2/typing.pyi index aa8468f94..dc807a0e0 100644 --- a/stdlib/2/typing.pyi +++ b/stdlib/2/typing.pyi @@ -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: ... diff --git a/stdlib/3/typing.pyi b/stdlib/3/typing.pyi index a8af514fa..e57bcc100 100644 --- a/stdlib/3/typing.pyi +++ b/stdlib/3/typing.pyi @@ -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: ...