Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/python_discovery/_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@
import logging
import os
import stat
import tempfile
from contextlib import contextmanager, suppress
from hashlib import sha256
from pathlib import Path
from tempfile import NamedTemporaryFile
from typing import TYPE_CHECKING, Final, Protocol, runtime_checkable

if TYPE_CHECKING:
Expand Down Expand Up @@ -115,7 +115,7 @@ def write(self, content: dict) -> None:
self._folder.mkdir(parents=True, exist_ok=True)
temporary: Path | None = None
try:
with tempfile.NamedTemporaryFile(
with NamedTemporaryFile(
mode="w", encoding="utf-8", dir=self._folder, prefix=f".{self._key}.", delete=False
) as file:
temporary = Path(file.name)
Expand Down
3 changes: 2 additions & 1 deletion src/python_discovery/_discovery.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
from contextlib import suppress
from dataclasses import dataclass
from itertools import tee
from os.path import basename
from pathlib import Path
from typing import TYPE_CHECKING, Final

Expand Down Expand Up @@ -514,7 +515,7 @@ def _resolve_shim(exe_path: str, env: Mapping[str, str]) -> str | None:

def _resolve_shim_to_binary(exe_name: str, versions_dir: str, env: Mapping[str, str]) -> str | None:
for version in _active_versions(env):
if version in {"", ".", ".."} or os.path.basename(version) != version:
if version in {"", ".", ".."} or basename(version) != version:
_LOGGER.debug("ignoring invalid version name %r", version)
continue
resolved = os.path.join(versions_dir, version, "bin", exe_name)
Expand Down
2 changes: 1 addition & 1 deletion tests/test_cache.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,7 +291,7 @@ def test_disk_content_store_write_is_private_with_lax_umask(tmp_path: Path) -> N
@pytest.mark.parametrize(
"target",
[
pytest.param("python_discovery._cache.tempfile.NamedTemporaryFile", id="create"),
pytest.param("python_discovery._cache.NamedTemporaryFile", id="create"),
pytest.param("pathlib.Path.replace", id="replace"),
],
)
Expand Down