Skip to content

use Self in async context managers - #5724

Merged
srittau merged 4 commits into
python:masterfrom
Akuli:self
Jul 6, 2021
Merged

srittau merged 4 commits into
python:masterfrom
Akuli:self

Conversation

@Akuli

@Akuli Akuli commented Jul 4, 2021

Copy link
Copy Markdown
Collaborator

Resolves this comment #5712 (comment)

Comment thread stdlib/contextlib.pyi
def callback(self, callback: Callable[..., Any], *args: Any, **kwds: Any) -> Callable[..., Any]: ...
def push_async_callback(self, callback: _CallbackCoroFunc, *args: Any, **kwds: Any) -> _CallbackCoroFunc: ...
def pop_all(self: _S) -> _S: ...
def pop_all(self: Self) -> Self: ...

@graingert graingert Jul 4, 2021 •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This method is on _BaseExitStack

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

The purpose of _BaseExitStack is to avoid copy/pasta in the implementation. On the one hand, we don't need it in typeshed because the stubs are short anyway, but on the other hand, it is generally good if stubs match the implementation. Either way, adding _BaseExitStack is beyond the scope of this PR.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

This will need to be fixed on both copies of pop_all instead

@github-actions

This comment has been minimized.

@Akuli Akuli changed the title use Self in contextlib.AsyncExitStack use Self in async context managers Jul 4, 2021
@github-actions

This comment has been minimized.

1 similar comment
@github-actions

This comment has been minimized.

@github-actions

github-actions Bot commented Jul 5, 2021

Copy link
Copy Markdown
Contributor

According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉

@srittau
srittau merged commit 42247fe into python:master Jul 6, 2021
@Akuli
Akuli deleted the self branch July 6, 2021 19:16
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.

3 participants