Fix type hint of generator throw method (#4253)

* Fix type hint of generator throw method

* Incorporated changes from #4252
This commit is contained in:
Milap Sheth
2020-06-21 18:23:28 -04:00
committed by GitHub
parent 9b3edda33b
commit 66a9a4b5ce
4 changed files with 53 additions and 24 deletions

View File

@@ -138,11 +138,13 @@ class GeneratorType:
def __iter__(self) -> GeneratorType: ...
def __next__(self) -> Any: ...
def close(self) -> None: ...
def send(self, arg: Any) -> Any: ...
def send(self, __arg: Any) -> Any: ...
@overload
def throw(self, val: BaseException) -> Any: ...
def throw(self, __typ: Type[BaseException], __val: Union[BaseException, object] = ...,
__tb: Optional[TracebackType] = ...) -> Any: ...
@overload
def throw(self, typ: type, val: BaseException = ..., tb: TracebackType = ...) -> Any: ...
def throw(self, __typ: BaseException, __val: None = ...,
__tb: Optional[TracebackType] = ...) -> Any: ...
if sys.version_info >= (3, 6):
class AsyncGeneratorType(Generic[_T_co, _T_contra]):
@@ -152,11 +154,13 @@ if sys.version_info >= (3, 6):
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]: ...
def asend(self, __val: _T_contra) -> Awaitable[_T_co]: ...
@overload
def athrow(self, val: BaseException) -> Awaitable[_T_co]: ...
def athrow(self, __typ: Type[BaseException], __val: Union[BaseException, object] = ...,
__tb: Optional[TracebackType] = ...) -> Awaitable[_T_co]: ...
@overload
def athrow(self, typ: Type[BaseException], val: BaseException, tb: TracebackType = ...) -> Awaitable[_T_co]: ...
def athrow(self, __typ: BaseException, __val: None = ...,
__tb: Optional[TracebackType] = ...) -> Awaitable[_T_co]: ...
def aclose(self) -> Awaitable[None]: ...
class CoroutineType:
@@ -165,11 +169,13 @@ class CoroutineType:
cr_frame: FrameType
cr_running: bool
def close(self) -> None: ...
def send(self, arg: Any) -> Any: ...
def send(self, __arg: Any) -> Any: ...
@overload
def throw(self, val: BaseException) -> Any: ...
def throw(self, __typ: Type[BaseException], __val: Union[BaseException, object] = ...,
__tb: Optional[TracebackType] = ...) -> Any: ...
@overload
def throw(self, typ: type, val: BaseException = ..., tb: TracebackType = ...) -> Any: ...
def throw(self, __typ: BaseException, __val: None = ...,
__tb: Optional[TracebackType] = ...) -> Any: ...
class _StaticFunctionType:
"""Fictional type to correct the type of MethodType.__func__.