Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions stdlib/contextlib.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -172,15 +172,15 @@ class _RedirectStream(AbstractContextManager[_SupportsRedirectT, None]):
class redirect_stdout(_RedirectStream[_SupportsRedirectT]): ...
class redirect_stderr(_RedirectStream[_SupportsRedirectT]): ...

class _BaseExitStack(Generic[_ExitT_co]):
class _BaseExitStack(Generic[_ExitT_co], metaclass=abc.ABCMeta):
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This is not true at runtime, the metaclass is type.

def enter_context(self, cm: AbstractContextManager[_T, _ExitT_co]) -> _T: ...
def push(self, exit: _CM_EF) -> _CM_EF: ...
def callback(self, callback: Callable[_P, _T], /, *args: _P.args, **kwds: _P.kwargs) -> Callable[_P, _T]: ...
def pop_all(self) -> Self: ...

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

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