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

Use _typeshed.Self with __enter__ #5712

Merged
merged 2 commits into from
Jun 29, 2021

Conversation

gruebel
Copy link
Contributor

@gruebel gruebel commented Jun 29, 2021

Relates to #5676

I also removed TypeVar usage, where it became obsolete. In cProfile it also made sense to replace the _SelfT references with Self.

@github-actions

This comment has been minimized.

@github-actions
Copy link
Contributor

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

Copy link
Member

@JelleZijlstra JelleZijlstra left a comment

Choose a reason for hiding this comment

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

Thanks! I double-checked all these except the Python 2 stuff.

@@ -82,7 +82,7 @@ def open(
) -> TextIO: ...

class BZ2File(BaseStream, IO[bytes]):
def __enter__(self: _T) -> _T: ...
def __enter__(self: Self) -> Self: ...
Copy link
Member

Choose a reason for hiding this comment

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

This method doesn't actually exist at runtime; I guess it is inherited from an IO-related base class.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are correct, I think it is IOBase, but I would need to check.

@JelleZijlstra JelleZijlstra merged commit c38171a into python:master Jun 29, 2021
@gruebel gruebel deleted the adjust-enter-self branch June 30, 2021 19:56
@graingert
Copy link
Contributor

Probably needs a scan for __aenter__ calls

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.

4 participants