Fix __call__ type for GeneratorContextManager (#3143)

This commit is contained in:
Michael J. Sullivan
2019-07-24 13:20:15 -07:00
committed by Sebastian Rittau
parent bf50612d76
commit b3f7be523a

View File

@@ -18,6 +18,7 @@ if sys.version_info >= (3, 7):
from typing import AsyncContextManager as AbstractAsyncContextManager
_T = TypeVar('_T')
_F = TypeVar('_F', bound=Callable[..., Any])
_ExitFunc = Callable[[Optional[Type[BaseException]],
Optional[BaseException],
@@ -26,11 +27,11 @@ _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 __call__(self, func: _F) -> _F: ...
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 __call__(self, func: _F) -> _F: ...
def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ...
if sys.version_info >= (3, 7):