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

@@ -89,11 +89,13 @@ class GeneratorType:
def __iter__(self) -> GeneratorType: ...
def close(self) -> None: ...
def next(self) -> Any: ...
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 ClassType: ...
class UnboundMethodType:

View File

@@ -136,11 +136,17 @@ class Generator(Iterator[_T_co], Generic[_T_co, _T_contra, _V_co]):
def next(self) -> _T_co: ...
@abstractmethod
def send(self, value: _T_contra) -> _T_co: ...
def send(self, __value: _T_contra) -> _T_co: ...
@overload
@abstractmethod
def throw(self, typ: Type[BaseException], val: Optional[BaseException] = ...,
tb: TracebackType = ...) -> _T_co: ...
def throw(self, __typ: Type[BaseException], __val: Union[BaseException, object] = ...,
__tb: Optional[TracebackType] = ...) -> _T_co: ...
@overload
@abstractmethod
def throw(self, __typ: BaseException, __val: None = ...,
__tb: Optional[TracebackType] = ...) -> _T_co: ...
@abstractmethod
def close(self) -> None: ...
@property