special rmtree is not needed for TemporaryDirectory in 3.8+

This commit is contained in:
Anthony Sottile
2023-01-01 17:12:28 -05:00
parent 092e9a50ae
commit 0a0754e44a
4 changed files with 4 additions and 24 deletions

View File

@@ -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)