GH-127381: pathlib ABCs: remove ReadablePath.exists() and is_*() (#130520)

Remove `ReadablePath` methods duplicated by `ReadablePath.info`. To be
specific, we remove `exists()`, `is_dir()`, `is_file()` and `is_symlink()`.

The public `Path` class retains these methods.
This commit is contained in:
Barney Gale 2025-03-01 21:24:19 +00:00 committed by GitHub
parent 5181ddb29f
commit a55dffd66d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 89 additions and 130 deletions

View file

@ -219,38 +219,6 @@ class ReadablePath(JoinablePath):
"""
raise NotImplementedError
def exists(self, *, follow_symlinks=True):
"""
Whether this path exists.
This method normally follows symlinks; to check whether a symlink exists,
add the argument follow_symlinks=False.
"""
info = self.joinpath().info
return info.exists(follow_symlinks=follow_symlinks)
def is_dir(self, *, follow_symlinks=True):
"""
Whether this path is a directory.
"""
info = self.joinpath().info
return info.is_dir(follow_symlinks=follow_symlinks)
def is_file(self, *, follow_symlinks=True):
"""
Whether this path is a regular file (also True for symlinks pointing
to regular files).
"""
info = self.joinpath().info
return info.is_file(follow_symlinks=follow_symlinks)
def is_symlink(self):
"""
Whether this path is a symbolic link.
"""
info = self.joinpath().info
return info.is_symlink()
@abstractmethod
def __open_rb__(self, buffering=-1):
"""