liormizr / s3path

s3path is a pathlib extension for AWS S3 Service
Apache License 2.0
206 stars 39 forks source link

Wrong type hint on S3Path factories inherited from PureS3Path #147

Closed mgab closed 7 months ago

mgab commented 9 months ago

When creating an S3Path from a classmethod factory inherited from PureS3Path, such as from_uri, the typing hint infers the result to be of type PureS3Path while in reality it's of type S3Path.

For example, doing

from s3path import S3Path, PureS3Path

a = PureS3Path.from_uri('s3://bucket/key/path')
# Revealed type is "s3path.PureS3Path"

b = S3Path.from_uri('s3://bucket/key/path')
# Revealed type is "s3path.PureS3Path"

While one would expect

from s3path import S3Path, PureS3Path

a = PureS3Path.from_uri('s3://bucket/key/path')
# Revealed type is "s3path.S3Path"

b = S3Path.from_uri('s3://bucket/key/path')
# Revealed type is "s3path.PureS3Path"
liormizr commented 7 months ago

Hi

I'll remove the type hint from the classmethods

mgab commented 7 months ago

Thanks @liormizr. I'd say there's no need though, in PR #148 I tried to make the changes so that the correct type is deduced also for subclasses

liormizr commented 7 months ago

@mgab I prefer to remove the hints from the classmethods But thank you for your PR..

liormizr commented 7 months ago

New Version deployed 0.5.1 with this card fix