@@ -178,9 +178,15 @@ 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+ # this class is to avoid putting `metaclass=abc.ABCMeta` on the implementations directly, as this would make them
182+ # appear explicitly abstract to some tools. this is due to the implementations not subclassing `AbstractContextManager`
183+ # see note on the subclasses
184+ @type_check_only
185+ class _BaseExitStackAbstract (_BaseExitStack [_ExitT_co ], metaclass = abc .ABCMeta ): ...
186+
181187# In reality this is a subclass of `AbstractContextManager`;
182188# see #7961 for why we don't do that in the stub
183- class ExitStack (_BaseExitStack [_ExitT_co ], metaclass = abc . ABCMeta ):
189+ class ExitStack (_BaseExitStackAbstract [_ExitT_co ]):
184190 def close (self ) -> None : ...
185191 def __enter__ (self ) -> Self : ...
186192 def __exit__ (
@@ -194,7 +200,7 @@ _ACM_EF = TypeVar("_ACM_EF", bound=AbstractAsyncContextManager[Any, Any] | _Exit
194200
195201# In reality this is a subclass of `AbstractAsyncContextManager`;
196202# see #7961 for why we don't do that in the stub
197- class AsyncExitStack (_BaseExitStack [_ExitT_co ], metaclass = abc . ABCMeta ):
203+ class AsyncExitStack (_BaseExitStackAbstract [_ExitT_co ]):
198204 async def enter_async_context (self , cm : AbstractAsyncContextManager [_T , _ExitT_co ]) -> _T : ...
199205 def push_async_exit (self , exit : _ACM_EF ) -> _ACM_EF : ...
200206 def push_async_callback (
0 commit comments