mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-02-17 08:14:42 +04:00
special rmtree is not needed for TemporaryDirectory in 3.8+
This commit is contained in:
parent
092e9a50ae
commit
0a0754e44a
4 changed files with 4 additions and 24 deletions
|
|
@ -9,7 +9,6 @@ import shutil
|
|||
import stat
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
from types import TracebackType
|
||||
from typing import Any
|
||||
from typing import Callable
|
||||
|
|
@ -52,18 +51,6 @@ def clean_path_on_failure(path: str) -> Generator[None, None, None]:
|
|||
raise
|
||||
|
||||
|
||||
@contextlib.contextmanager
|
||||
def tmpdir() -> Generator[str, None, None]:
|
||||
"""Contextmanager to create a temporary directory. It will be cleaned up
|
||||
afterwards.
|
||||
"""
|
||||
tempdir = tempfile.mkdtemp()
|
||||
try:
|
||||
yield tempdir
|
||||
finally:
|
||||
rmtree(tempdir)
|
||||
|
||||
|
||||
def resource_bytesio(filename: str) -> IO[bytes]:
|
||||
return importlib.resources.open_binary('pre_commit.resources', filename)
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue