-
Notifications
You must be signed in to change notification settings - Fork 258
Add AsyncContextManager generic class #438
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
Add AsyncContextManager generic class #438
Conversation
yield 42 | ||
|
||
cm = manager() | ||
self.assertNotIsInstance(cm, typing.AsyncContextManager) |
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'd add a test that also serves as an example of how to use AsyncContextManager (presumably in async with ...
?
I was planning to do this after AbstractAsyncContextManager is merged into CPython (python/cpython#1412), but there's really no need to wait. The code looks good to me. It would be nice if this can make it into 3.6.2. |
Thanks! |
Implements: - python/typing#438 - python/cpython#360 python/cpython#1412, which adds contextlib.AbstractAsyncContextManager, has not yet been merged.
) Implements: - python/typing#438 - python/cpython#360 Note that python/cpython#1412, which adds contextlib.AbstractAsyncContextManager, has not yet been merged.
Asynchronous context managers are defined by PEP 492, but there is no corresponding generic abstract class in
typing
. This PR adds it for Python 3.5+.