Request for review: pathlib._PathBase

Hello! Would anyone be able to help review this PR?

The new class sits between PurePath and Path in the pathlib class hierarchy. After extensive discussion elsewhere on the forum and in previous PRs and issues, I’m pretty confident in the overall design. However, I don’t feel comfortable merging until these aspects have had some review:

  1. _PathBase.resolve(), which uses absolute() and readlink() to implement pathname resolution.
  2. _PathBase._scandir(), which uses iterdir(). We might want want to adjust how iterdir() raises exceptions - see discussion on PR.
  3. _PathBase.is_junction(), which uses stat() and feels a bit artificial compared to the other is_*() methods.

Would anyone be willing to look over the code and share their thoughts? Many thanks :slight_smile:


This will be great! I had difficulty finding the right magic to satisfy type checkers when subclassing:

That’s a slightly different thing! It wasn’t possible to directly subclass PurePath and Path (issue here), but it’s fixed in Python 3.12 (PR here).

This feature is about providing a base class that can be used to implement things like TarPath, FTPPath, etc, similar to how io.IOBase helps users to implement custom file objects.

1 Like

a nice addition would be if we had acessor paths, where the path object is implemented in terms of accessor

an accessor could be something like posix, windows, windows+unc, tarfile, zipfile, “another path”