I'm a bit confused as to why Traversable was ever implemented in the first place.
Seems like Traversable is supposed to represent file system paths, however I was sure that's why we have Paths.
Whatever Traversable's added value is, I still think the class should be coupled to Path type-wise. Maybe by marking Traversable as PathLike.
At the moment, functions like importlib.resources.files specify a return type of Iterator[Traversable] but in reality return Iterator[Path]. This results in confusing type hint warnings since IDEs have no way to know that Traversable and Path are related.
I'm not very experienced with the newer versions of importlib so my assumptions might be a bit off, hoping one of could shed some light.
Thanks
Originally posted by @moomoohk in #88366 (comment)
I'm a bit confused as to why
Traversablewas ever implemented in the first place.Seems like
Traversableis supposed to represent file system paths, however I was sure that's why we havePaths.Whatever
Traversable's added value is, I still think the class should be coupled toPathtype-wise. Maybe by markingTraversableasPathLike.At the moment, functions like
importlib.resources.filesspecify a return type ofIterator[Traversable]but in reality returnIterator[Path]. This results in confusing type hint warnings since IDEs have no way to know thatTraversableandPathare related.I'm not very experienced with the newer versions of
importlibso my assumptions might be a bit off, hoping one of could shed some light.Thanks
Originally posted by @moomoohk in #88366 (comment)