Fix contextlib GeneratorContextManager name for py>=3.2 (#3083)

This commit is contained in:
Rafi Blecher
2019-07-02 02:56:40 -07:00
committed by Ivan Levkivskyi
parent e1e5c83795
commit 668d050476

View File

@@ -25,10 +25,12 @@ _ExitFunc = Callable[[Optional[Type[BaseException]],
_CM_EF = TypeVar('_CM_EF', ContextManager, _ExitFunc)
if sys.version_info >= (3, 2):
class _GeneratorContextManager(ContextManager[_T], Generic[_T]):
def __call__(self, func: Callable[..., _T]) -> Callable[..., _T]: ...
def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., _GeneratorContextManager[_T]]: ...
else:
class GeneratorContextManager(ContextManager[_T], Generic[_T]):
def __call__(self, func: Callable[..., _T]) -> Callable[..., _T]: ...
def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., GeneratorContextManager[_T]]: ...
else:
def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ...
if sys.version_info >= (3, 7):