FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

GH-130608: Remove `dirs_exist_ok` argument from `pathlib.Path.copy()` by barneygale · Pull Request #130610 · python/cpython · GitHub

/ cpython Public

GH-130608: Remove dirs_exist_ok argument from pathlib.Path.copy() - #130610

Merged
barneygale merged 1 commit into
python:mainfrom
barneygale:copy-drop-dirs-exist-ok
Feb 28, 2025
Merged

GH-130608: Remove dirs_exist_ok argument from pathlib.Path.copy()#130610
barneygale merged 1 commit into
python:mainfrom
barneygale:copy-drop-dirs-exist-ok

Conversation

barneygale commented Feb 26, 2025
edited
Loading

Copy link
Copy Markdown
Contributor

Per the issue:

(Background: pathlib.Path.copy() is new in Python 3.14, so it hasn't been released yet.)

I don't think there's a compelling case to support a dirs_exist_ok argument in the initial version of Path.copy(). Most Python users don't need "copy and merge directory" functionality. Particularly unlucky users might use the wrong source or target path, and perform a large directory tree merge that is difficult to unpick.

We could add this back in later, in response to user demand.


📚 Documentation preview 📚: https://cpython-previews--130610.org.readthedocs.build/

…opy()`

This feature isn't sufficiently motivated.

Copy link
Copy Markdown
Contributor Author

Hi Paul, I requested your review because you helped with a similar PR few months back: #123337

To explain my motivations a bit:

I'm trying to be extremely careful about adding pathlib features I might later regret. It's already happened more than once while I've been maintaining pathlib 🙃

In this case, the implementation uses WritablePath.mkdir(exist_ok=dirs_exist_ok), but I'd like to remove the exist_ok argument because it implies readability, whereas WritablePath is otherwise write-only. Maybe this is solvable some other way, but for now I'd quite like to play it safe.

Hope that makes sense, thank you.

pfmoore commented Feb 28, 2025

Copy link
Copy Markdown
Member

Looks OK to me, and I agree with your reasoning. Until we know how people are going to use the new extensibility, it's better to keep the requirements minimal. We can add functionality later if it's needed, and 3rd party providers won't have a problem with it.

barneygale commented Feb 28, 2025
edited
Loading

Copy link
Copy Markdown
Contributor Author

Excellent, thanks for your help :]

barneygale merged commit b545450 into python:main Feb 28, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants


Back | FazBrowse Home | New Git URL