mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-18 00:24:47 +04:00
Need to also use an Exception parameter, not an OSError parameter. So we apply a cast for this to work.
This commit is contained in:
parent
9a3f2cbb99
commit
86fc829f4d
1 changed files with 4 additions and 3 deletions
|
|
@ -12,6 +12,7 @@ from collections.abc import Generator
|
|||
from types import TracebackType
|
||||
from typing import Any
|
||||
from typing import Callable
|
||||
from typing import cast
|
||||
|
||||
from pre_commit import parse_shebang
|
||||
|
||||
|
|
@ -205,11 +206,11 @@ else: # pragma: no cover
|
|||
def _handle_readonly(
|
||||
func: Callable[[str], object],
|
||||
path: str,
|
||||
exc: OSError,
|
||||
exc: Exception,
|
||||
) -> object:
|
||||
if (
|
||||
func in (os.rmdir, os.remove, os.unlink) and
|
||||
exc.errno in {errno.EACCES, errno.EPERM}
|
||||
func in (os.rmdir, os.remove, os.unlink) and exc is OSError and
|
||||
cast(OSError, exc).errno in {errno.EACCES, errno.EPERM}
|
||||
):
|
||||
for p in (path, os.path.dirname(path)):
|
||||
os.chmod(p, os.stat(p).st_mode | stat.S_IWUSR)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue