GH-127381: pathlib ABCs: remove remaining uncommon PathBase methods (#127714)

Remove the following methods from `pathlib._abc.PathBase`:

- `expanduser()`
- `hardlink_to()`
- `touch()`
- `chmod()`
- `lchmod()`
- `owner()`
- `group()`
- `from_uri()`
- `as_uri()`

These operations aren't regularly supported in virtual filesystems, so they
don't win a place in the `PathBase` interface. (Some of them probably don't
deserve a place in `Path` :P.) They're quasi-abstract (except `lchmod()`),
and they're not called by other `PathBase` methods.
This commit is contained in:
Barney Gale 2024-12-12 06:49:34 +00:00 committed by GitHub
parent 8bbd379ee3
commit 292afd1d51
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 27 additions and 67 deletions

View file

@ -1312,21 +1312,9 @@ class PathBaseTest(PurePathBaseTest):
self.assertRaises(e, lambda: list(p.glob('*')))
self.assertRaises(e, lambda: list(p.rglob('*')))
self.assertRaises(e, lambda: list(p.walk()))
self.assertRaises(e, p.expanduser)
self.assertRaises(e, p.readlink)
self.assertRaises(e, p.symlink_to, 'foo')
self.assertRaises(e, p.hardlink_to, 'foo')
self.assertRaises(e, p.mkdir)
self.assertRaises(e, p.touch)
self.assertRaises(e, p.chmod, 0o755)
self.assertRaises(e, p.lchmod, 0o755)
self.assertRaises(e, p.owner)
self.assertRaises(e, p.group)
self.assertRaises(e, p.as_uri)
def test_as_uri_common(self):
e = UnsupportedOperation
self.assertRaises(e, self.cls('').as_uri)
def test_fspath_common(self):
self.assertRaises(TypeError, os.fspath, self.cls(''))