diff --git a/stdlib/2and3/contextlib.pyi b/stdlib/2and3/contextlib.pyi index 0f14afaee..6ff18d846 100644 --- a/stdlib/2and3/contextlib.pyi +++ b/stdlib/2and3/contextlib.pyi @@ -20,7 +20,12 @@ class ContextManager(Generic[_T]): exc_val: Optional[Exception], exc_tb: Optional[TracebackType]) -> bool: ... -def contextmanager(func: Callable[..., Iterator[_T]]) -> Callable[..., ContextManager[_T]]: ... +if sys.version_info >= (3, 2): + class GeneratorContextManager(Generic[_T], ContextManager[_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,): def nested(*mgr: ContextManager[Any]) -> ContextManager[Iterable[Any]]: ...