Skip to content

Commit

Permalink
Merge pull request #3194 from pre-commit/handle-readonly-3-12
Browse files Browse the repository at this point in the history
adjust _handle_readonly for typeshed updates
  • Loading branch information
asottile committed Apr 30, 2024
2 parents 85fe182 + 5c3d006 commit d7e21cd
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 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
4 changes: 2 additions & 2 deletions tests/languages/ruby_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,8 @@ def test_ruby_additional_deps(tmp_path):
tmp_path,
ruby,
'ruby -e',
args=('require "tins"',),
deps=('tins',),
args=('require "jmespath"',),
deps=('jmespath',),
)
assert ret == (0, b'')

Expand Down

0 comments on commit d7e21cd

Please sign in to comment.