Skip to content

Commit 1e8b953

Browse files
KentzoJelleZijlstra
authored andcommitted
Add stub for AsyncExitContext added by bpo-29302. (#1876)
* Add stub for AsyncExitContext added by bpo-29302. * ExitStack's pop_all returns an instance of type(self).
1 parent 18ae67d commit 1e8b953

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

stdlib/2and3/contextlib.pyi

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -61,6 +61,31 @@ if sys.version_info >= (3,):
6161
def push(self, exit: _CM_EF) -> _CM_EF: ...
6262
def callback(self, callback: Callable[..., None],
6363
*args: Any, **kwds: Any) -> Callable[..., None]: ...
64-
def pop_all(self) -> ExitStack: ...
64+
def pop_all(self: _U) -> _U: ...
6565
def close(self) -> None: ...
6666
def __enter__(self: _U) -> _U: ...
67+
68+
if sys.version_info >= (3, 7):
69+
from typing import Awaitable
70+
71+
_U = TypeVar('_U', bound='AsyncExitStack')
72+
73+
_ExitCoroFunc = Callable[[Optional[Type[BaseException]],
74+
Optional[BaseException],
75+
Optional[TracebackType]], Awaitable[bool]]
76+
_CallbackCoroFunc = Callable[..., Awaitable[None]]
77+
_ACM_EF = TypeVar('_ACM_EF', AsyncContextManager, _ExitCoroFunc)
78+
79+
class AsyncExitStack(AsyncContextManager[AsyncExitStack]):
80+
def __init__(self) -> None: ...
81+
def enter_context(self, cm: ContextManager[_T]) -> _T: ...
82+
def enter_async_context(self, cm: AsyncContextManager[_T]) -> Awaitable[_T]: ...
83+
def push(self, exit: _CM_EF) -> _CM_EF: ...
84+
def push_async_exit(self, exit: _ACM_EF) -> _ACM_EF: ...
85+
def callback(self, callback: Callable[..., None],
86+
*args: Any, **kwds: Any) -> Callable[..., None]: ...
87+
def push_async_callback(self, callback: _CallbackCoroFunc,
88+
*args: Any, **kwds: Any) -> _CallbackCoroFunc: ...
89+
def pop_all(self: _U) -> _U: ...
90+
def aclose(self) -> Awaitable[None]: ...
91+
def __aenter__(self: _U) -> Awaitable[_U]: ...

0 commit comments

Comments
 (0)