From d937970196ef54e5c9bb1c58dd06c2bd40068ffa Mon Sep 17 00:00:00 2001 From: Eliah Kagan Date: Sun, 8 Oct 2023 20:27:08 -0400 Subject: [PATCH] Revise and update rmtree docstrings and comments --- git/util.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/git/util.py b/git/util.py index 8a4a20253..d7f348d48 100644 --- a/git/util.py +++ b/git/util.py @@ -170,17 +170,18 @@ def patch_env(name: str, value: str) -> Generator[None, None, None]: def rmtree(path: PathLike) -> None: - """Remove the given recursively. + """Remove the given directory tree recursively. - :note: we use shutil rmtree but adjust its behaviour to see whether files that - couldn't be deleted are read-only. Windows will not remove them in that case""" + :note: We use :func:`shutil.rmtree` but adjust its behaviour to see whether files that + couldn't be deleted are read-only. Windows will not remove them in that case.""" def handler(function: Callable, path: PathLike, _excinfo: Any) -> None: - # Is the error an access error ? + """Callback for :func:`shutil.rmtree`. Works either as ``onexc`` or ``onerror``.""" + # Is the error an access error? os.chmod(path, stat.S_IWUSR) try: - function(path) # Will scream if still not possible to delete. + function(path) except PermissionError as ex: if HIDE_WINDOWS_KNOWN_ERRORS: from unittest import SkipTest