Description
Feature or enhancement
Currently pathlib
is missing some shutil
features: rmtree
or copy
Pitch
pathlib.Path
define an Interface / API that many third party modules implement:
- zipfile.Path
- importlib.resource.Transversable
- epath.Path
- universal_pathlib
- gitpathlib.GitPath
- Many others: https://pypi.org/search/?q=pathlib
Having a consistent API is great as I can write code for pathlib, and it is automatically compatible with all pathlib-like backends without any code changes.
(e.g. user can replace pathlib.Path
by epath.Path
and the function magically work with cloud storage likegs://
, s3://
,...).
However due to the lack of .rmtree
and .copy
supports, some operations are impossible. It means each pathlib-like backend who want to support recursive directory deletion or copy has to come up with their own API, leading to inconsistency.
(technically it is possible to implement some rmtree(path.Path())
implemented only using pathlib
function, but this would lead in very inefficient performance on remote storage)
Defining them directly in pathlib would make them part of the standard, with well defined semantic. This would allow implementations to rely on them and to switch between pathlib-like objects.
This will be even more relevant when pathlib will provide an explicit interface that users an inherit from: https://discuss.python.org/t/make-pathlib-extensible/3428/7