Skip to content

Commit

Permalink
adjust _handle_readonly for typeshed updates
Browse files Browse the repository at this point in the history
  • Loading branch information
asottile committed Apr 30, 2024
1 parent 85fe182 commit 0d4c6da
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions pre_commit/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -205,10 +205,11 @@ def cmd_output_p(
def _handle_readonly(
func: Callable[[str], object],
path: str,
exc: OSError,
exc: Exception,
) -> None:
if (
func in (os.rmdir, os.remove, os.unlink) and
isinstance(exc, OSError) and
exc.errno in {errno.EACCES, errno.EPERM}
):
for p in (path, os.path.dirname(path)):
Expand All @@ -222,7 +223,7 @@ def _handle_readonly(
def _handle_readonly_old(
func: Callable[[str], object],
path: str,
excinfo: tuple[type[OSError], OSError, TracebackType],
excinfo: tuple[type[Exception], Exception, TracebackType],
) -> None:
return _handle_readonly(func, path, excinfo[1])

Expand Down

0 comments on commit 0d4c6da

Please sign in to comment.