-
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Add stub for AsyncExitContext added by bpo-29302. #1876
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
a14d125
7fe061d
f207d24
216b3b6
598b57c
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
- Loading branch information
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -64,3 +64,29 @@ if sys.version_info >= (3,): | |
def pop_all(self) -> ExitStack: ... | ||
def close(self) -> None: ... | ||
def __enter__(self: _U) -> _U: ... | ||
|
||
if sys.version_info >= (3, 7): | ||
from asyncio.futures import Future | ||
|
||
_U = TypeVar('_U', bound='AsyncExitStack') | ||
|
||
_ExitCoroFunc = Callable[[Optional[Type[BaseException]], | ||
Optional[BaseException], | ||
Optional[TracebackType]], Future[bool]] | ||
_CallbackCoroFunc = Callable[..., Future[None]] | ||
_ACM_EF = TypeVar('_ACM_EF', AsyncContextManager, _ExitCoroFunc) | ||
|
||
class AsyncExitStack(AsyncContextManager[AsyncExitStack]): | ||
def __init__(self) -> None: ... | ||
def enter_context(self, cm: ContextManager[_T]) -> _T: ... | ||
def enter_async_context(self, cm: AsyncContextManager[_T]) -> Future[_T]: ... | ||
def push(self, exit: _CM_EF) -> _CM_EF: ... | ||
def push_async_exit(self, exit: _ACM_EF) -> _ACM_EF: ... | ||
def callback(self, callback: Callable[..., None], | ||
*args: Any, **kwds: Any) -> Callable[..., None]: ... | ||
def push_async_callback(self, callback: _CallbackCoroFunc, | ||
*args: Any, **kwds: Any) -> _CallbackCoroFunc: ... | ||
def pop_all(self) -> ExitStack: ... | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Should return AsyncExitStack. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Actually, I think it should be implemented as Probably that should also be fixed for There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Thanks! Would you mind fixing it there too while you're at it? |
||
def aclose(self) -> Future[None]: ... | ||
def __enter__(self: _U) -> _U: ... | ||
def __aenter__(self: _U) -> Future[_U]: ... |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not use typing.Awaitable instead of Future?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was looking at stubs for
asyncio.tasks
as an example.On the second look I agree,
Awaitable
should be used instead.