Skip to content

Commit c6e24f0

Browse files
committed
make ExitStack/AsyncExitStack not appear as abstract
1 parent b0401bc commit c6e24f0

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

stdlib/contextlib.pyi

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -178,9 +178,12 @@ class _BaseExitStack(Generic[_ExitT_co]):
178178
def callback(self, callback: Callable[_P, _T], /, *args: _P.args, **kwds: _P.kwargs) -> Callable[_P, _T]: ...
179179
def pop_all(self) -> Self: ...
180180

181+
@type_check_only
182+
class _ExitStackBase(metaclass=abc.ABCMeta): ...
183+
181184
# In reality this is a subclass of `AbstractContextManager`;
182185
# see #7961 for why we don't do that in the stub
183-
class ExitStack(_BaseExitStack[_ExitT_co], metaclass=abc.ABCMeta):
186+
class ExitStack(_ExitStackBase, _BaseExitStack[_ExitT_co]):
184187
def close(self) -> None: ...
185188
def __enter__(self) -> Self: ...
186189
def __exit__(
@@ -194,7 +197,7 @@ _ACM_EF = TypeVar("_ACM_EF", bound=AbstractAsyncContextManager[Any, Any] | _Exit
194197

195198
# In reality this is a subclass of `AbstractAsyncContextManager`;
196199
# see #7961 for why we don't do that in the stub
197-
class AsyncExitStack(_BaseExitStack[_ExitT_co], metaclass=abc.ABCMeta):
200+
class AsyncExitStack(_ExitStackBase, _BaseExitStack[_ExitT_co]):
198201
async def enter_async_context(self, cm: AbstractAsyncContextManager[_T, _ExitT_co]) -> _T: ...
199202
def push_async_exit(self, exit: _ACM_EF) -> _ACM_EF: ...
200203
def push_async_callback(

0 commit comments

Comments
 (0)