Thanks to visit codestin.com
Credit goes to github.com

Skip to content

bpo-30241: implement contextlib.AbstractAsyncContextManager #1412

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

Merged
merged 6 commits into from
Dec 14, 2017

Conversation

JelleZijlstra
Copy link
Member

@JelleZijlstra JelleZijlstra commented May 3, 2017

@mention-bot
Copy link

@JelleZijlstra, thanks for your PR! By analyzing the history of the files in this pull request, we identified @ncoghlan, @birkenfeld and @rhettinger to be potential reviewers.

def __subclasshook__(cls, C):
if cls is AbstractAsyncContextManager:
if (any("__aenter__" in B.__dict__ for B in C.__mro__) and
any("__aexit__" in B.__dict__ for B in C.__mro__)):
Copy link
Member

Choose a reason for hiding this comment

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

I understand you just copied this from above, but I think both should be updated to support the explicit "anti-registration" __enter__ = None pattern, like all classes in collections.abc, see _check_methods function in _collections_abc.py.

Copy link
Member Author

Choose a reason for hiding this comment

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

Maybe that should be a separate issue? AbstractContextManager should arguably be fixed even in 3.6, and this PR only targets 3.7. I can fix AbstractAsyncContextManager though.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, a separate PR for 3.6 is needed. But I think it makes sense to already fix the async version here.

Copy link
Member Author

Choose a reason for hiding this comment

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

Filed http://bugs.python.org/issue30266 to track that.

@gvanrossum
Copy link
Member

Wait, isn't this a new feature that should go into 3.7?

@ilevkivskyi
Copy link
Member

Wait, isn't this a new feature that should go into 3.7?

Oh yes, sorry, this one is not urgent then.

JelleZijlstra added a commit to JelleZijlstra/typeshed that referenced this pull request Jun 24, 2017
Implements:
- python/typing#438
- python/cpython#360

python/cpython#1412, which adds
contextlib.AbstractAsyncContextManager, has not yet been merged.
gvanrossum pushed a commit to python/typeshed that referenced this pull request Jun 27, 2017
)

Implements:
- python/typing#438
- python/cpython#360

Note that python/cpython#1412, which adds
contextlib.AbstractAsyncContextManager, has not yet been merged.
@1st1
Copy link
Member

1st1 commented Oct 10, 2017

Please add a NEWS entry and I'll merge this in.

@JelleZijlstra
Copy link
Member Author

Thanks, just pushed a NEWS entry.

@@ -29,6 +29,15 @@ Functions and classes provided:
.. versionadded:: 3.6


.. class:: AbstractAsyncContextManager

An :term:`abstract base class` similar to
Copy link
Member

Choose a reason for hiding this comment

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

I'm wondering if we could just copy the paragraph from AbstractContextManager doc. "similar to" isn't easy to read here.

@Kentzo
Copy link
Contributor

Kentzo commented Dec 11, 2017

The PR #4790 adds AsyncExitStack subclass. It should inherit from AbstractAsyncContextManager.

@ilevkivskyi
Copy link
Member

@JelleZijlstra Could you please fix the merge conflict and update the docs as @1st1 proposed? I would like to have this merged soon.

@1st1 1st1 merged commit 176baa3 into python:master Dec 14, 2017
@1st1
Copy link
Member

1st1 commented Dec 14, 2017

Thanks @JelleZijlstra!

@JelleZijlstra JelleZijlstra deleted the aacm branch December 14, 2017 01:28
@JelleZijlstra
Copy link
Member Author

Thanks, and sorry for dropping the ball on making the docs change!

@1st1
Copy link
Member

1st1 commented Dec 14, 2017

NP ;)

@ilevkivskyi
Copy link
Member

Thank you @JelleZijlstra and @1st1 !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants