Change return type of PureS3Path class methods to Self #199
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.
Thanks for adding type hints to s3path!
I saw your comments about type hints adding to the maintenance burden, and I don't want that to be the case because the benefit of type hints are great. This is a PR to address what I believe is an error in the type hint implementation added in 0.6.3.
Closes #198
This PR changes the return type of
PureS3Path.from_uri
andPureS3Path.from_bucket_key
to beSelf
instead ofPureS3Path
. Both class methods return an instance ofcls
which is not necessarily aPureS3Path
if the class method is invoked from a subclass.I believe this is the desired behavior because this allows construction of a concrete
S3Path
from a uri string.The alternative is that
PureS3Path.from_uri
should only ever return a PureS3Path and not be allowed to return anS3Path
or any other subclass ofPureS3Path
. If this is the case, instead of changing the return type hints, the implementation of the class methods should be changed to return aPureS3Path
instead ofcls
.