[Python-ideas] Introduce typing.SupportsFsPath
Guido van Rossum
guido at python.org
Mon Oct 8 21:12:18 EDT 2018
In typeshed there is os.PathLike which is close. You should be able to use
Union[str, os.PathLike[str]] for what you want (or define an alias).
We generally don't want to add more things to typing that aren't closely
related to the type system. (Adding the io and re classes was already less
than ideal, and we don't want to do more of those.)
On Mon, Oct 8, 2018 at 3:10 PM <robert.hoelzl at posteo.de> wrote:
> Since __fspath__ was introduced in PEP 519 it is possible to create
> object classes that are representing file system paths.
> But there is no corresponding type object in the "typing" module. Thus I
> cannot specify functions, that accept any kind of object which supports
> the __fspath__ protocol.
> Please note that "Path" is not a replacement for "SupportsFsPath", since
> the concept of PEP 519 is, that I could implement new objects (without
> dependency to "Path")
> that are implementing the __fspath__ protocol.
> Python-ideas mailing list
> Python-ideas at python.org
> Code of Conduct: http://python.org/psf/codeofconduct/
--Guido van Rossum (python.org/~guido)
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the Python-ideas