Use a TypeVar for the return types of TarFile classmethods.#5602
Merged
Conversation
srittau
reviewed
Jun 9, 2021
| @classmethod | ||
| def open( | ||
| cls, | ||
| cls: Type[_TF], |
Contributor
Author
There was a problem hiding this comment.
mypy doesn't like type[_TF] because of python/mypy#10303
Collaborator
There was a problem hiding this comment.
Sorry about that. I actually tested it before this comment, but it seems that it worked in my small test for some reason, but not here. 😕
Contributor
Author
There was a problem hiding this comment.
I have switched back to Type[_TF] for now.
This comment has been minimized.
This comment has been minimized.
2 similar comments
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
Contributor
|
According to mypy_primer, this change has no effect on the checked open source code. 🤖🎉 |
Akuli
approved these changes
Jun 12, 2021
Collaborator
|
Nit for future reference: We generally prefer adding more commits as opposed to force-pushing. When we merge the PR, it's combined into a single commit anyway. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The implementations of the classmethods (and
__enter__) return the same type as the class, including for subclasses. However, the current stubs show the methods unconditionally returningTarFile, and never its subclasses.