mirror of
https://github.com/explosion/spaCy.git
synced 2025-01-26 09:14:32 +03:00
Use tempfile.TemporaryDirectory (#12285)
This commit is contained in:
parent
b95123060a
commit
dd3f138830
|
@ -1028,12 +1028,11 @@ def make_tempdir() -> Generator[Path, None, None]:
|
|||
|
||||
YIELDS (Path): The path of the temp directory.
|
||||
"""
|
||||
d = Path(tempfile.mkdtemp())
|
||||
yield d
|
||||
try:
|
||||
shutil.rmtree(str(d))
|
||||
with tempfile.TemporaryDirectory() as td:
|
||||
yield Path(td)
|
||||
except PermissionError as e:
|
||||
warnings.warn(Warnings.W091.format(dir=d, msg=e))
|
||||
warnings.warn(Warnings.W091.format(dir=td, msg=e))
|
||||
|
||||
|
||||
def is_cwd(path: Union[Path, str]) -> bool:
|
||||
|
|
Loading…
Reference in New Issue
Block a user