[issue44200] Recommend importlib.abc.Traversable users to implement __fspath__

2021-05-23 Thread Filipe Laíns
Filipe Laíns added the comment: CompatibilityFiles would use this. We could add a dispatch for that too, but that's 2 different cases now and `os.PathLike` would be able to handle both. -- ___ Python tracker

[issue44200] Recommend importlib.abc.Traversable users to implement __fspath__

2021-05-23 Thread Jason R. Coombs
Jason R. Coombs added the comment: > I think `as_file` should learn to behave like `path`, if `__fspath__` is > available, it will use that path. Oh, that's an interesting idea. And that's effectively what happens

[issue44200] Recommend importlib.abc.Traversable users to implement __fspath__

2021-05-23 Thread Filipe Laíns
Filipe Laíns added the comment: That's why I said it should be optional. If the object can implement it, it should. `pathlib.Path` certainly can, `zipfile.Path` can't, and that's alright. If the Traversable does not represent a path on the file-system, it does not make sense to implement

[issue44200] Recommend importlib.abc.Traversable users to implement __fspath__

2021-05-23 Thread Jason R. Coombs
Jason R. Coombs added the comment: The problem with the `__fspath__` protocol is that it assumes a file system. The `importlib.resources` and `Traversable` protocols are trying to provide a lower-level interface that doesn't assume a file system. Fortunately, there already exists a helper

[issue44200] Recommend importlib.abc.Traversable users to implement __fspath__

2021-05-20 Thread Filipe Laíns
Change by Filipe Laíns : -- assignee: -> docs@python components: +Documentation nosy: +docs@python ___ Python tracker ___ ___

[issue44200] Recommend importlib.abc.Traversable users to implement __fspath__

2021-05-20 Thread Filipe Laíns
Filipe Laíns added the comment: I am gonna wait until/if GH-26272 (#44196) gets merged because this would conflict with that. -- ___ Python tracker ___

[issue44200] Recommend importlib.abc.Traversable users to implement __fspath__

2021-05-20 Thread Filipe Laíns
New submission from Filipe Laíns : The files()/Traversable api is meant to replace ResourceReader api, but it falls short in one dimension, tying the abstraction to a file system path. I propose to document that Traversable users *should* implement __fspath__ if the Traversable represents a