fsspec / universal_pathlib

pathlib api extended to use fsspec backends
MIT License
240 stars 42 forks source link

/ (__truediv__) does not handle trailing slash correctly #165

Closed michael-bily closed 7 months ago

michael-bily commented 9 months ago

Hey,

I found a surprising behavior

In [1]: from upath import UPath

In [2]: a = UPath("s3://sf-crypto-integration-tests/aupxqnx2/")

In [3]: a = UPath("s3://bucket/folder/")

In [4]: a / "hello.txt" Out[4]: S3Path('s3://bucket/folder//hello.txt')

I'd expect S3Path('s3://bucket/folder/hello.txt') - without the extra /

I see that PosixUPath trims the / already during instantiation.

Thank you for looking into this.

ap-- commented 7 months ago

Fixed in universal_pathlib>=0.2.0

>>> from upath import UPath
>>> a = UPath("s3://sf-crypto-integration-tests/aupxqnx2/")
>>> a / "hello.txt"
S3Path('s3://sf-crypto-integration-tests/aupxqnx2/hello.txt')
>>> b = UPath("s3://sf-crypto-integration-tests/aupxqnx2")
>>> b / "hello.txt"
S3Path('s3://sf-crypto-integration-tests/aupxqnx2/hello.txt')