mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-19 09:04:41 +04:00
Merge pull request #3194 from pre-commit/handle-readonly-3-12
adjust _handle_readonly for typeshed updates
This commit is contained in:
commit
d7e21cd29c
2 changed files with 5 additions and 4 deletions
|
|
@ -205,10 +205,11 @@ else: # pragma: no cover
|
||||||
def _handle_readonly(
|
def _handle_readonly(
|
||||||
func: Callable[[str], object],
|
func: Callable[[str], object],
|
||||||
path: str,
|
path: str,
|
||||||
exc: OSError,
|
exc: Exception,
|
||||||
) -> None:
|
) -> None:
|
||||||
if (
|
if (
|
||||||
func in (os.rmdir, os.remove, os.unlink) and
|
func in (os.rmdir, os.remove, os.unlink) and
|
||||||
|
isinstance(exc, OSError) and
|
||||||
exc.errno in {errno.EACCES, errno.EPERM}
|
exc.errno in {errno.EACCES, errno.EPERM}
|
||||||
):
|
):
|
||||||
for p in (path, os.path.dirname(path)):
|
for p in (path, os.path.dirname(path)):
|
||||||
|
|
@ -222,7 +223,7 @@ if sys.version_info < (3, 12): # pragma: <3.12 cover
|
||||||
def _handle_readonly_old(
|
def _handle_readonly_old(
|
||||||
func: Callable[[str], object],
|
func: Callable[[str], object],
|
||||||
path: str,
|
path: str,
|
||||||
excinfo: tuple[type[OSError], OSError, TracebackType],
|
excinfo: tuple[type[Exception], Exception, TracebackType],
|
||||||
) -> None:
|
) -> None:
|
||||||
return _handle_readonly(func, path, excinfo[1])
|
return _handle_readonly(func, path, excinfo[1])
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -91,8 +91,8 @@ def test_ruby_additional_deps(tmp_path):
|
||||||
tmp_path,
|
tmp_path,
|
||||||
ruby,
|
ruby,
|
||||||
'ruby -e',
|
'ruby -e',
|
||||||
args=('require "tins"',),
|
args=('require "jmespath"',),
|
||||||
deps=('tins',),
|
deps=('jmespath',),
|
||||||
)
|
)
|
||||||
assert ret == (0, b'')
|
assert ret == (0, b'')
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue