diff --git a/ops/model.py b/ops/model.py index 1e8206ab8..12dd2bece 100644 --- a/ops/model.py +++ b/ops/model.py @@ -2520,7 +2520,15 @@ def remove_path(self, path: Union[str, PurePath], *, recursive: bool = False): Args: path: Path of the file or directory to delete from the remote system. - recursive: If True, recursively delete path and everything under it. + recursive: If True, and path is a directory, recursively delete it and + everything under it. If path is a file, delete the file. In + either case, do nothing if the file or directory does not + exist. Behaviourally similar to ``rm -rf ``. + + Raises: + pebble.PathError: If a relative path is provided, or if `recursive` is False + and the file or directory cannot be removed (it does not exist or is not empty). + """ self._pebble.remove_path(str(path), recursive=recursive) diff --git a/ops/pebble.py b/ops/pebble.py index 6eef4aab6..365418534 100644 --- a/ops/pebble.py +++ b/ops/pebble.py @@ -2164,10 +2164,14 @@ def remove_path(self, path: str, *, recursive: bool = False): Args: path: Path of the file or directory to delete from the remote system. - recursive: If True, and path is a directory recursively deletes it and - everything under it. If the path is a file, delete the file and - do nothing if the file is non-existent. Behaviourally similar - to ``rm -rf ``. + recursive: If True, and path is a directory, recursively delete it and + everything under it. If path is a file, delete the file. In + either case, do nothing if the file or directory does not + exist. Behaviourally similar to ``rm -rf ``. + + Raises: + pebble.PathError: If a relative path is provided, or if `recursive` is False + and the file or directory cannot be removed (it does not exist or is not empty). """ info: Dict[str, Any] = {'path': path}