Skip to content
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

bpo-41543: contextlib.nullcontext can fill in for an async context manager #21870

Merged
merged 2 commits into from
Nov 9, 2020

Conversation

tomgrin10
Copy link
Contributor

@tomgrin10 tomgrin10 commented Aug 13, 2020

Make contextlib.nullcontext implement AbstractAsyncContextManager, so it can be used as a fill in for async context mangers.

https://bugs.python.org/issue41543

@tomgrin10 tomgrin10 requested a review from 1st1 as a code owner August 13, 2020 21:19
@tomgrin10 tomgrin10 changed the title bpo-41543: contextlib.nullcontext can fill in an async context manager bpo-41543: contextlib.nullcontext can fill in for an async context manager Aug 13, 2020
Copy link
Member

@iritkatriel iritkatriel left a comment

Choose a reason for hiding this comment

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

Missing a test

@1st1
Copy link
Member

1st1 commented Aug 14, 2020

Yes, please add a test and update the docs.

@iritkatriel
Copy link
Member

It might be tidier to have a separate NullAsyncContext.

@tomgrin10
Copy link
Contributor Author

It might be tidier to have a separate NullAsyncContext.

Because nullcontext is used as a fill in for other objects, I think it would be confusing to have two versions of it.

@tomgrin10
Copy link
Contributor Author

Added test and updated docs :)

Copy link
Member

@iritkatriel iritkatriel left a comment

Choose a reason for hiding this comment

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

Still need to squash the commits.

Doc/library/contextlib.rst Show resolved Hide resolved
@tomgrin10
Copy link
Contributor Author

I fixed the example and squashed the commits

@iritkatriel
Copy link
Member

Looks like there are still 4 commits. It will be easier for people looking at this change in the future if the code change, test, and documentation change are all in a single commit.

@tomgrin10
Copy link
Contributor Author

My bad, thought that if the commits get merge --squashed, they shouldn't all be in one commit, now they're actually squashed 😅

@ZackerySpytz
Copy link
Contributor

For what it's worth, the developer's guide states that squashing should be avoided.

Doc/library/contextlib.rst Outdated Show resolved Hide resolved
@tomgrin10
Copy link
Contributor Author

Is this gonna get merged?

@tomgrin10 tomgrin10 closed this Aug 20, 2020
@tomgrin10 tomgrin10 reopened this Aug 20, 2020
@iritkatriel
Copy link
Member

@ZackerySpytz, I see what you mean now - the core devs squash commits on merge so it doesn't matter if the PR is messy. Thanks for pointing this out.

@1st1
Copy link
Member

1st1 commented Sep 2, 2020

Yes, this is ready for merge. Just trying to get the CI pass.

@tomgrin10 tomgrin10 closed this Sep 5, 2020
@tomgrin10 tomgrin10 reopened this Sep 5, 2020
@iritkatriel
Copy link
Member

I guess this can be merged now.

@tomgrin10 tomgrin10 closed this Oct 5, 2020
@tomgrin10 tomgrin10 reopened this Oct 5, 2020
@tomgrin10
Copy link
Contributor Author

Is this gonna get merged someday? Is there a way to fix the broken CI?

@tomgrin10 tomgrin10 closed this Oct 26, 2020
@tomgrin10 tomgrin10 reopened this Oct 26, 2020
@tomgrin10 tomgrin10 requested a review from 1st1 October 26, 2020 19:54
Copy link
Contributor

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

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

LGTM.

As the aiohttp author, I never use such approach :)

Copy link
Contributor

@asvetlov asvetlov left a comment

Choose a reason for hiding this comment

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

Need ..versionchanged:: 3.10 directive in docs that says 'added support for async context manager' or something like this

@bedevere-bot
Copy link

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@tomgrin10
Copy link
Contributor Author

tomgrin10 commented Nov 4, 2020

Need ..versionchanged:: 3.10 directive in docs that says 'added support for async context manager' or something like this

@asvetlov Do you feel it's better to add the directive before my example, or that an another example for nullcontext is redundant and just the directive is enough?

…nager

Add NEWS.d blurb


Add tests


Fix test


Update nullcontext docs


Fix example in docs


Format lines
@asvetlov
Copy link
Contributor

asvetlov commented Nov 4, 2020

I expect to see ..versionchanged:: 3.10 at the next line to ..versionadded:: 3.7 (plus an empty line as a separator).

@tomgrin10
Copy link
Contributor Author

I expect to see ..versionchanged:: 3.10 at the next line to ..versionadded:: 3.7 (plus an empty line as a separator).

I got that, but I question whether to remove my example entirely and leave only the directive.
What do you think?

@asvetlov
Copy link
Contributor

asvetlov commented Nov 9, 2020

I think the example is fine, but versionadded should mention the change.

Updated docs.

@asvetlov
Copy link
Contributor

asvetlov commented Nov 9, 2020

Thanks for the patience!

adorilson pushed a commit to adorilson/cpython that referenced this pull request Mar 13, 2021
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.

7 participants