Skip to content

Commit 84ac784

Browse files
committed
prefer stdlib TemporaryDirectory
1 parent 0fa27fe commit 84ac784

File tree

4 files changed

+10
-10
lines changed

4 files changed

+10
-10
lines changed

src/poetry/inspection/info.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import zipfile
1010

1111
from pathlib import Path
12+
from tempfile import TemporaryDirectory
1213
from typing import TYPE_CHECKING
1314
from typing import Any
1415

@@ -18,7 +19,6 @@
1819
from poetry.core.packages.dependency import Dependency
1920
from poetry.core.packages.package import Package
2021
from poetry.core.utils.helpers import parse_requires
21-
from poetry.core.utils.helpers import temporary_directory
2222
from poetry.core.version.markers import InvalidMarker
2323
from poetry.core.version.requirements import InvalidRequirement
2424

@@ -308,7 +308,7 @@ def _from_sdist_file(cls, path: Path) -> PackageInfo:
308308

309309
context = tarfile.open
310310

311-
with temporary_directory() as tmp_str:
311+
with TemporaryDirectory() as tmp_str:
312312
tmp = Path(tmp_str)
313313
with context(path.as_posix()) as archive:
314314
archive.extractall(tmp.as_posix())

src/poetry/installation/chef.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,12 @@
77
from contextlib import redirect_stdout
88
from io import StringIO
99
from pathlib import Path
10+
from tempfile import TemporaryDirectory
1011
from typing import TYPE_CHECKING
1112

1213
from build import BuildBackendException
1314
from build import ProjectBuilder
1415
from build.env import IsolatedEnv as BaseIsolatedEnv
15-
from poetry.core.utils.helpers import temporary_directory
1616
from pyproject_hooks import quiet_subprocess_runner # type: ignore[import]
1717

1818
from poetry.utils._compat import decode
@@ -160,7 +160,7 @@ def _prepare_sdist(self, archive: Path, destination: Path | None = None) -> Path
160160
else:
161161
context = tarfile.open
162162

163-
with temporary_directory() as tmp_dir:
163+
with TemporaryDirectory() as tmp_dir:
164164
with context(archive.as_posix()) as archive_archive:
165165
archive_archive.extractall(tmp_dir)
166166

src/poetry/repositories/http_repository.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@
88

99
from collections import defaultdict
1010
from pathlib import Path
11+
from tempfile import TemporaryDirectory
1112
from typing import TYPE_CHECKING
1213
from typing import Any
1314

@@ -16,7 +17,6 @@
1617
from poetry.core.constraints.version import parse_constraint
1718
from poetry.core.packages.dependency import Dependency
1819
from poetry.core.packages.utils.link import Link
19-
from poetry.core.utils.helpers import temporary_directory
2020
from poetry.core.version.markers import parse_marker
2121

2222
from poetry.repositories.cached_repository import CachedRepository
@@ -83,7 +83,7 @@ def _get_info_from_wheel(self, url: str) -> PackageInfo:
8383

8484
filename = os.path.basename(wheel_name)
8585

86-
with temporary_directory() as temp_dir:
86+
with TemporaryDirectory() as temp_dir:
8787
filepath = Path(temp_dir) / filename
8888
self._download(url, filepath)
8989

@@ -99,7 +99,7 @@ def _get_info_from_sdist(self, url: str) -> PackageInfo:
9999

100100
filename = os.path.basename(sdist_name)
101101

102-
with temporary_directory() as temp_dir:
102+
with TemporaryDirectory() as temp_dir:
103103
filepath = Path(temp_dir) / filename
104104
self._download(url, filepath)
105105

@@ -237,7 +237,7 @@ def _links_to_data(self, links: list[Link], data: PackageInfo) -> dict[str, Any]
237237
and link.hash_name not in ("sha256", "sha384", "sha512")
238238
and hasattr(hashlib, link.hash_name)
239239
):
240-
with temporary_directory() as temp_dir:
240+
with TemporaryDirectory() as temp_dir:
241241
filepath = Path(temp_dir) / link.filename
242242
self._download(link.url, filepath)
243243

src/poetry/utils/env.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
from copy import deepcopy
2020
from pathlib import Path
2121
from subprocess import CalledProcessError
22+
from tempfile import TemporaryDirectory
2223
from typing import TYPE_CHECKING
2324
from typing import Any
2425

@@ -34,7 +35,6 @@
3435
from packaging.tags import sys_tags
3536
from poetry.core.constraints.version import Version
3637
from poetry.core.constraints.version import parse_constraint
37-
from poetry.core.utils.helpers import temporary_directory
3838
from virtualenv.seed.wheels.embed import get_embed_wheel
3939

4040
from poetry.toml.file import TOMLFile
@@ -1959,7 +1959,7 @@ def ephemeral_environment(
19591959
executable: Path | None = None,
19601960
flags: dict[str, bool] | None = None,
19611961
) -> Iterator[VirtualEnv]:
1962-
with temporary_directory() as tmp_dir:
1962+
with TemporaryDirectory() as tmp_dir:
19631963
# TODO: cache PEP 517 build environment corresponding to each project venv
19641964
venv_dir = Path(tmp_dir) / ".venv"
19651965
EnvManager.build_venv(

0 commit comments

Comments
 (0)