mirror of
https://github.com/python/cpython.git
synced 2025-08-04 00:48:58 +00:00
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:
parent
d2d886215c
commit
d372472896
2 changed files with 9 additions and 29 deletions
|
@ -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):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue