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

FSFile should support any PathLike objects #1516

Closed
gerritholl opened this issue Jan 29, 2021 · 0 comments · Fixed by #1519
Closed

FSFile should support any PathLike objects #1516

gerritholl opened this issue Jan 29, 2021 · 0 comments · Fixed by #1519
Assignees
Labels

Comments

@gerritholl
Copy link
Member

Feature Request

Is your feature request related to a problem? Please describe.

When the FSFile constructor is passed anything that isn't a string, the FSFile.__str__ method triggers a TypeError:

import pathlib
from satpy.readers import FSFile
from fsspec.implementations.local import LocalFileSystem
fsf = FSFile(pathlib.Path("/tmp/abc"), LocalFileSystem())
print(str(fsf))

which gives:

Traceback (most recent call last):
  File "mwe/mwe002.py", line 5, in <module>
    print(str(fsf))
TypeError: __str__ returned non-string (type PosixPath)

This is not a bug because the FSFile docstring does state it expects a string, but it would be nice if other pathlike objects could be passed as well.

Describe the solution you'd like

I would like that the FSFile constructor supports the file system protocol, such that the code above would work as intended.

Describe any changes to existing user workflow

None reasonably expected.

Additional context

It would save me a call to __fspath__ or str(...) prior to creating the FSFile objects.

@gerritholl gerritholl self-assigned this Jan 29, 2021
@djhoese djhoese added blocked Waiting on an external action (eg release of other package) bug and removed blocked Waiting on an external action (eg release of other package) labels Jan 29, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants