mirror of
https://github.com/pre-commit/pre-commit.git
synced 2026-01-27 19:38:35 -06:00
special rmtree is not needed for TemporaryDirectory in 3.8+
This commit is contained in:
@@ -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)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user