From 688f8134573ab938df7873cb01917448edea4b70 Mon Sep 17 00:00:00 2001 From: Elliott Beach Date: Mon, 8 Jan 2018 08:02:30 -0600 Subject: [PATCH] fix subclassing ExitStack (#1810) --- stdlib/2and3/contextlib.pyi | 3 +++ 1 file changed, 3 insertions(+) diff --git a/stdlib/2and3/contextlib.pyi b/stdlib/2and3/contextlib.pyi index 480546fb9..21f640a17 100644 --- a/stdlib/2and3/contextlib.pyi +++ b/stdlib/2and3/contextlib.pyi @@ -53,6 +53,8 @@ if sys.version_info >= (3,): class ContextDecorator: def __call__(self, func: Callable[..., None]) -> Callable[..., ContextManager[None]]: ... + _U = TypeVar('_U', bound='ExitStack') + class ExitStack(ContextManager[ExitStack]): def __init__(self) -> None: ... def enter_context(self, cm: ContextManager[_T]) -> _T: ... @@ -61,3 +63,4 @@ if sys.version_info >= (3,): *args: Any, **kwds: Any) -> Callable[..., None]: ... def pop_all(self) -> ExitStack: ... def close(self) -> None: ... + def __enter__(self: _U) -> _U: ...