GH-128520: pathlib ABCs: tighten up argument types (#131621)

In `JoinablePath.full_match()` and `ReadablePath.glob()`, accept a `str`
pattern argument rather than `JoinablePath | str`.

In `ReadablePath.copy()` and `copy_into()`, accept a `WritablePath` target
argument rather than `WritablePath | str`.
This commit is contained in:
Barney Gale 2025-03-24 15:39:08 +00:00 committed by GitHub
parent d2d886215c
commit d372472896
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 29 deletions

View file

@ -1105,11 +1105,7 @@ class Path(PurePath):
if not hasattr(target, 'with_segments'):
target = self.with_segments(target)
ensure_distinct_paths(self, target)
try:
copy_to_target = target._copy_from
except AttributeError:
raise TypeError(f"Target path is not writable: {target!r}") from None
copy_to_target(self, **kwargs)
target._copy_from(self, **kwargs)
return target.joinpath() # Empty join to ensure fresh metadata.
def copy_into(self, target_dir, **kwargs):