Repository: wntrblm/nox
Pull request #895 (2024-11-25 06:22:40)

tests: use tmp_path instead of tmpdir
Replace the deprecated `tmpdir` with `tmp_path`. Used the new static typing in tests to help find the needed updates for py.path (`LEGACY_PATH`) -> Path.

The which/run commands in `nox.command` now support `os.PathLike`.


Patch:
diff --git a/.github/workflows/action.yml b/.github/workflows/action.yml
index 62fe99c..4db5a7c 100644
--- a/.github/workflows/action.yml
+++ b/.github/workflows/action.yml
@@ -27,7 +27,7 @@ jobs:
           - macos-14
     steps:
       - uses: actions/checkout@v4
-      - uses: astral-sh/setup-uv@v3
+      - uses: astral-sh/setup-uv@v4
       - uses: ./
       - run: nox --non-interactive --error-on-missing-interpreter --session github_actions_default_tests
 
diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index 1e3bf8d..d75c8fb 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -44,7 +44,7 @@ jobs:
           python-version: ${{ matrix.python-version }}
           allow-prereleases: true
       - name: Setup uv
-        uses: astral-sh/setup-uv@v3
+        uses: astral-sh/setup-uv@v4
       - name: Set up Miniconda
         uses: conda-incubator/setup-miniconda@v3
         with:
@@ -76,7 +76,7 @@ jobs:
         with:
           python-version: "3.12"
       - name: Setup uv
-        uses: astral-sh/setup-uv@v3
+        uses: astral-sh/setup-uv@v4
       - name: Install Nox-under-test
         run:  uv pip install --system .
       - name: Download individual coverage reports
@@ -110,7 +110,7 @@ jobs:
         with:
           python-version: "3.12"
       - name: Setup uv
-        uses: astral-sh/setup-uv@v3
+        uses: astral-sh/setup-uv@v4
       - name: Install Nox-under-test
         run:  uv pip install --system .
       - name: Docs
diff --git a/nox/command.py b/nox/command.py
index 976e7f9..1af13d0 100644
--- a/nox/command.py
+++ b/nox/command.py
@@ -40,10 +40,12 @@ class CommandFailed(Exception):
         self.reason = reason
 
 
-def which(program: str | os.PathLike[str], paths: Sequence[str] | None) -> str:
+def which(
+    program: str | os.PathLike[str], paths: Sequence[str | os.PathLike[str]] | None
+) -> str:
     """Finds the full path to an executable."""
     if paths is not None:
-        full_path = shutil.which(program, path=os.pathsep.join(paths))
+        full_path = shutil.which(program, path=os.pathsep.join(str(p) for p in paths))
         if full_path:
             return os.fspath(full_path)
 
@@ -79,7 +81,7 @@ def run(
     *,
     env: Mapping[str, str | None] | None = ...,
     silent: Literal[True],
-    paths: Sequence[str] | None = ...,
+    paths: Sequence[str | os.PathLike[str]] | None = ...,
     success_codes: Iterable[int] | None = ...,
     log: bool = ...,
     external: ExternalType = ...,
@@ -96,7 +98,7 @@ def run(
     *,
     env: Mapping[str, str | None] | None = ...,
     silent: Literal[False] = ...,
-    paths: Sequence[str] | None = ...,
+    paths: Sequence[str | os.PathLike[str]] | None = ...,
     success_codes: Iterable[int] | None = ...,
     log: bool = ...,
     external: ExternalType = ...,
@@ -113,7 +115,7 @@ def run(
     *,
     env: Mapping[str, str | None] | None = ...,
     silent: bool,
-    paths: Sequence[str] | None = ...,
+    paths: Sequence[str | os.PathLike[str]] | None = ...,
     success_codes: Iterable[int] | None = ...,
     log: bool = ...,
     external: ExternalType = ...,
@@ -129,7 +131,7 @@ def run(
     *,
     env: Mapping[str, str | None] | None = None,
     silent: bool = False,
-    paths: Sequence[str] | None = None,
+    paths: Sequence[str | os.PathLike[str]] | None = None,
     success_codes: Iterable[int] | None = None,
     log: bool = True,
     external: ExternalType = False,
@@ -153,7 +155,7 @@ def run(
         logger.info(full_cmd)
 
         is_external_tool = paths is not None and not any(
-            cmd_path.startswith(path) for path in paths
+            cmd_path.startswith(str(path)) for path in paths
         )
         if is_external_tool:
             if external == "error":


Test patch:
diff --git a/tests/test_command.py b/tests/test_command.py
index 62c783c..bfb8527 100644
--- a/tests/test_command.py
+++ b/tests/test_command.py
@@ -25,7 +25,7 @@ import sys
 import time
 from pathlib import Path
 from textwrap import dedent
-from typing import TYPE_CHECKING, Any
+from typing import Any
 from unittest import mock
 
 import pytest
@@ -33,9 +33,6 @@ import pytest
 import nox.command
 import nox.popen
 
-if TYPE_CHECKING:
-    from _pytest.compat import LEGACY_PATH
-
 PYTHON = sys.executable
 
 skip_on_windows_primary_console_session = pytest.mark.skipif(
@@ -214,36 +211,30 @@ def test_run_path_existent(tmp_path: Path) -> None:
         )
 
 
-def test_run_external_warns(
-    tmpdir: LEGACY_PATH, caplog: pytest.LogCaptureFixture
-) -> None:
+def test_run_external_warns(tmp_path: Path, caplog: pytest.LogCaptureFixture) -> None:
     caplog.set_level(logging.WARNING)
 
-    nox.command.run([PYTHON, "--version"], silent=True, paths=[tmpdir.strpath])
+    nox.command.run([PYTHON, "--version"], silent=True, paths=[tmp_path])
 
     assert "external=True" in caplog.text
 
 
 def test_run_external_silences(
-    tmpdir: LEGACY_PATH, caplog: pytest.LogCaptureFixture
+    tmp_path: Path, caplog: pytest.LogCaptureFixture
 ) -> None:
     caplog.set_level(logging.WARNING)
 
-    nox.command.run(
-        [PYTHON, "--version"], silent=True, paths=[tmpdir.strpath], external=True
-    )
+    nox.command.run([PYTHON, "--version"], silent=True, paths=[tmp_path], external=True)
 
     assert "external=True" not in caplog.text
 
 
-def test_run_external_raises(
-    tmpdir: LEGACY_PATH, caplog: pytest.LogCaptureFixture
-) -> None:
+def test_run_external_raises(tmp_path: Path, caplog: pytest.LogCaptureFixture) -> None:
     caplog.set_level(logging.ERROR)
 
     with pytest.raises(nox.command.CommandFailed):
         nox.command.run(
-            [PYTHON, "--version"], silent=True, paths=[tmpdir.strpath], external="error"
+            [PYTHON, "--version"], silent=True, paths=[tmp_path], external="error"
         )
 
     assert "external=True" in caplog.text
@@ -430,8 +421,8 @@ def test_interrupt_handled_on_windows() -> None:
     run_pytest_in_new_console_session("test_interrupt_handled")
 
 
-def test_custom_stdout(capsys: pytest.CaptureFixture[str], tmpdir: LEGACY_PATH) -> None:
-    with open(str(tmpdir / "out.txt"), "w+") as stdout:
+def test_custom_stdout(capsys: pytest.CaptureFixture[str], tmp_path: Path) -> None:
+    with (tmp_path / "out.txt").open("w+", encoding="utf-8") as stdout:
         nox.command.run(
             [
                 PYTHON,
@@ -453,16 +444,16 @@ def test_custom_stdout(capsys: pytest.CaptureFixture[str], tmpdir: LEGACY_PATH)
         assert "err" in tempfile_contents
 
 
-def test_custom_stdout_silent_flag(tmpdir: LEGACY_PATH) -> None:
-    with open(str(tmpdir / "out.txt"), "w+") as stdout:  # noqa: SIM117
+def test_custom_stdout_silent_flag(tmp_path: Path) -> None:
+    with (tmp_path / "out.txt").open("w+", encoding="utf-8") as stdout:  # noqa: SIM117
         with pytest.raises(ValueError, match="silent"):
             nox.command.run([PYTHON, "-c", 'print("hi")'], stdout=stdout, silent=True)
 
 
 def test_custom_stdout_failed_command(
-    capsys: pytest.CaptureFixture[str], tmpdir: LEGACY_PATH
+    capsys: pytest.CaptureFixture[str], tmp_path: Path
 ) -> None:
-    with open(str(tmpdir / "out.txt"), "w+") as stdout:
+    with (tmp_path / "out.txt").open("w+", encoding="utf-8") as stdout:
         with pytest.raises(nox.command.CommandFailed):
             nox.command.run(
                 [
@@ -485,8 +476,8 @@ def test_custom_stdout_failed_command(
         assert "err" in tempfile_contents
 
 
-def test_custom_stderr(capsys: pytest.CaptureFixture[str], tmpdir: LEGACY_PATH) -> None:
-    with open(str(tmpdir / "err.txt"), "w+") as stderr:
+def test_custom_stderr(capsys: pytest.CaptureFixture[str], tmp_path: Path) -> None:
+    with (tmp_path / "err.txt").open("w+", encoding="utf-8") as stderr:
         nox.command.run(
             [
                 PYTHON,
@@ -509,9 +500,9 @@ def test_custom_stderr(capsys: pytest.CaptureFixture[str], tmpdir: LEGACY_PATH)
 
 
 def test_custom_stderr_failed_command(
-    capsys: pytest.CaptureFixture[str], tmpdir: LEGACY_PATH
+    capsys: pytest.CaptureFixture[str], tmp_path: Path
 ) -> None:
-    with open(str(tmpdir / "out.txt"), "w+") as stderr:
+    with (tmp_path / "out.txt").open("w+", encoding="utf-8") as stderr:
         with pytest.raises(nox.command.CommandFailed):
             nox.command.run(
                 [
diff --git a/tests/test_sessions.py b/tests/test_sessions.py
index 1ed2352..f96e404 100644
--- a/tests/test_sessions.py
+++ b/tests/test_sessions.py
@@ -40,9 +40,6 @@ import nox.virtualenv
 from nox import _options
 from nox.logger import logger
 
-if typing.TYPE_CHECKING:
-    from _pytest.compat import LEGACY_PATH
-
 HAS_CONDA = shutil.which("conda") is not None
 has_conda = pytest.mark.skipif(not HAS_CONDA, reason="Missing conda command.")
 
@@ -212,50 +209,54 @@ class TestSession:
 
             assert session.interactive is False
 
-    def test_chdir(self, tmpdir: LEGACY_PATH) -> None:
-        cdto = str(tmpdir.join("cdbby").ensure(dir=True))
+    def test_chdir(self, tmp_path: Path) -> None:
+        cdbby = tmp_path / "cdbby"
+        cdbby.mkdir()
         current_cwd = os.getcwd()
 
         session, _ = self.make_session_and_runner()
 
-        session.chdir(cdto)
+        session.chdir(str(cdbby))
 
-        assert os.getcwd() == cdto
+        assert cdbby.samefile(".")
         os.chdir(current_cwd)
 
-    def test_chdir_ctx(self, tmpdir: LEGACY_PATH) -> None:
-        cdto = str(tmpdir.join("cdbby").ensure(dir=True))
-        current_cwd = os.getcwd()
+    def test_chdir_ctx(self, tmp_path: Path) -> None:
+        cdbby = tmp_path / "cdbby"
+        cdbby.mkdir()
+        current_cwd = Path.cwd().resolve()
 
         session, _ = self.make_session_and_runner()
 
-        with session.chdir(cdto):
-            assert os.getcwd() == cdto
+        with session.chdir(cdbby):
+            assert cdbby.samefile(".")
 
-        assert os.getcwd() == current_cwd
+        assert current_cwd.samefile(".")
 
         os.chdir(current_cwd)
 
-    def test_invoked_from(self, tmpdir: LEGACY_PATH) -> None:
-        cdto = str(tmpdir.join("cdbby").ensure(dir=True))
-        current_cwd = os.getcwd()
+    def test_invoked_from(self, tmp_path: Path) -> None:
+        cdbby = tmp_path / "cdbby"
+        cdbby.mkdir()
+        current_cwd = Path.cwd().resolve()
 
         session, _ = self.make_session_and_runner()
 
-        session.chdir(cdto)
+        session.chdir(cdbby)
 
-        assert session.invoked_from == current_cwd
+        assert current_cwd.samefile(session.invoked_from)
         os.chdir(current_cwd)
 
-    def test_chdir_pathlib(self, tmpdir: LEGACY_PATH) -> None:
-        cdto = str(tmpdir.join("cdbby").ensure(dir=True))
-        current_cwd = os.getcwd()
+    def test_chdir_pathlib(self, tmp_path: Path) -> None:
+        cdbby = tmp_path / "cdbby"
+        cdbby.mkdir()
+        current_cwd = Path.cwd().resolve()
 
         session, _ = self.make_session_and_runner()
 
-        session.chdir(Path(cdto))
+        session.chdir(cdbby)
 
-        assert os.getcwd() == cdto
+        assert cdbby.samefile(".")
         os.chdir(current_cwd)
 
     def test_run_bad_args(self) -> None:
diff --git a/tests/test_tox_to_nox.py b/tests/test_tox_to_nox.py
index ac0093b..4146ea4 100644
--- a/tests/test_tox_to_nox.py
+++ b/tests/test_tox_to_nox.py
@@ -14,16 +14,17 @@
 
 from __future__ import annotations
 
+import os
 import sys
 import textwrap
-from typing import TYPE_CHECKING, Any
+from pathlib import Path
+from typing import TYPE_CHECKING
 
 import pytest
 
 if TYPE_CHECKING:
     from collections.abc import Callable
 
-    from _pytest.compat import LEGACY_PATH
 
 tox_to_nox = pytest.importorskip("nox.tox_to_nox")
 
@@ -33,21 +34,22 @@ PYTHON_VERSION_NODOT = PYTHON_VERSION.replace(".", "")
 
 
 @pytest.fixture
-def makeconfig(tmpdir: LEGACY_PATH) -> Callable[[str], str]:
+def makeconfig(tmp_path: Path) -> Callable[[str], str]:
     def makeconfig(toxini_content: str) -> str:
-        tmpdir.join("tox.ini").write_text(toxini_content, encoding="utf8")
-        old = tmpdir.chdir()
+        tmp_path.joinpath("tox.ini").write_text(toxini_content, encoding="utf-8")
+        old = Path.cwd().resolve()
+        os.chdir(tmp_path)
         try:
             sys.argv = [sys.executable]
             tox_to_nox.main()
-            return tmpdir.join("noxfile.py").read_text(encoding="utf8")  # type: ignore[no-any-return]
+            return tmp_path.joinpath("noxfile.py").read_text(encoding="utf-8")
         finally:
-            old.chdir()
+            os.chdir(old)
 
     return makeconfig
 
 
-def test_trivial(makeconfig: Callable[..., Any]) -> None:
+def test_trivial(makeconfig: Callable[[str], str]) -> None:
     result = makeconfig(
         textwrap.dedent(
             f"""
@@ -72,7 +74,7 @@ def test_trivial(makeconfig: Callable[..., Any]) -> None:
     )
 
 
-def test_skipinstall(makeconfig: Callable[..., Any]) -> None:
+def test_skipinstall(makeconfig: Callable[[str], str]) -> None:
     result = makeconfig(
         textwrap.dedent(
             f"""
@@ -99,7 +101,7 @@ def test_skipinstall(makeconfig: Callable[..., Any]) -> None:
     )
 
 
-def test_usedevelop(makeconfig: Callable[..., Any]) -> None:
+def test_usedevelop(makeconfig: Callable[[str], str]) -> None:
     result = makeconfig(
         textwrap.dedent(
             f"""
@@ -127,7 +129,7 @@ def test_usedevelop(makeconfig: Callable[..., Any]) -> None:
     )
 
 
-def test_commands(makeconfig: Callable[..., Any]) -> None:
+def test_commands(makeconfig: Callable[[str], str]) -> None:
     result = makeconfig(
         textwrap.dedent(
             f"""
@@ -163,7 +165,7 @@ def test_commands(makeconfig: Callable[..., Any]) -> None:
     )
 
 
-def test_deps(makeconfig: Callable[..., Any]) -> None:
+def test_deps(makeconfig: Callable[[str], str]) -> None:
     result = makeconfig(
         textwrap.dedent(
             f"""
@@ -195,7 +197,7 @@ def test_deps(makeconfig: Callable[..., Any]) -> None:
     )
 
 
-def test_env(makeconfig: Callable[..., Any]) -> None:
+def test_env(makeconfig: Callable[[str], str]) -> None:
     result = makeconfig(
         textwrap.dedent(
             f"""
@@ -229,7 +231,7 @@ def test_env(makeconfig: Callable[..., Any]) -> None:
     )
 
 
-def test_chdir(makeconfig: Callable[..., Any]) -> None:
+def test_chdir(makeconfig: Callable[[str], str]) -> None:
     result = makeconfig(
         textwrap.dedent(
             f"""
@@ -259,7 +261,7 @@ def test_chdir(makeconfig: Callable[..., Any]) -> None:
     )
 
 
-def test_dash_in_envname(makeconfig: Callable[..., Any]) -> None:
+def test_dash_in_envname(makeconfig: Callable[[str], str]) -> None:
     result = makeconfig(
         textwrap.dedent(
             f"""
@@ -289,7 +291,7 @@ def test_dash_in_envname(makeconfig: Callable[..., Any]) -> None:
 
 @pytest.mark.skipif(TOX4, reason="Not supported in tox 4.")
 def test_non_identifier_in_envname(
-    makeconfig: Callable[..., Any], capfd: pytest.CaptureFixture[str]
+    makeconfig: Callable[[str], str], capfd: pytest.CaptureFixture[str]
 ) -> None:
     result = makeconfig(
         textwrap.dedent(
@@ -325,7 +327,7 @@ def test_non_identifier_in_envname(
     )
 
 
-def test_descriptions_into_docstrings(makeconfig: Callable[..., Any]) -> None:
+def test_descriptions_into_docstrings(makeconfig: Callable[[str], str]) -> None:
     result = makeconfig(
         textwrap.dedent(
             f"""
diff --git a/tests/test_virtualenv.py b/tests/test_virtualenv.py
index 1e281fa..a05885c 100644
--- a/tests/test_virtualenv.py
+++ b/tests/test_virtualenv.py
@@ -36,8 +36,6 @@ import nox.virtualenv
 if TYPE_CHECKING:
     from collections.abc import Callable
 
-    from _pytest.compat import LEGACY_PATH
-
     from nox.virtualenv import CondaEnv, ProcessEnv, VirtualEnv
 
 IS_WINDOWS = nox.virtualenv._SYSTEM == "Windows"
@@ -57,31 +55,29 @@ class TextProcessResult(NamedTuple):
 
 @pytest.fixture
 def make_one(
-    tmpdir: LEGACY_PATH,
-) -> Callable[
-    ..., tuple[nox.virtualenv.VirtualEnv | nox.virtualenv.ProcessEnv, LEGACY_PATH]
-]:
+    tmp_path: Path,
+) -> Callable[..., tuple[nox.virtualenv.VirtualEnv | nox.virtualenv.ProcessEnv, Path]]:
     def factory(
         *args: Any, venv_backend: str = "virtualenv", **kwargs: Any
-    ) -> tuple[nox.virtualenv.VirtualEnv | nox.virtualenv.ProcessEnv, LEGACY_PATH]:
-        location = tmpdir.join("venv")
+    ) -> tuple[nox.virtualenv.VirtualEnv | nox.virtualenv.ProcessEnv, Path]:
+        location = tmp_path.joinpath("venv")
         try:
             venv_fn = nox.virtualenv.ALL_VENVS[venv_backend]
         except KeyError:
             venv_fn = functools.partial(
                 nox.virtualenv.VirtualEnv, venv_backend=venv_backend
             )
-        venv = venv_fn(location.strpath, *args, **kwargs)
+        venv = venv_fn(str(location), *args, **kwargs)
         return (venv, location)
 
     return factory
 
 
 @pytest.fixture
-def make_conda(tmpdir: LEGACY_PATH) -> Callable[..., tuple[CondaEnv, LEGACY_PATH]]:
-    def factory(*args: Any, **kwargs: Any) -> tuple[CondaEnv, LEGACY_PATH]:
-        location = tmpdir.join("condaenv")
-        venv = nox.virtualenv.CondaEnv(location.strpath, *args, **kwargs)
+def make_conda(tmp_path: Path) -> Callable[..., tuple[CondaEnv, Path]]:
+    def factory(*args: Any, **kwargs: Any) -> tuple[CondaEnv, Path]:
+        location = tmp_path.joinpath("condaenv")
+        venv = nox.virtualenv.CondaEnv(str(location), *args, **kwargs)
         return (venv, location)
 
     return factory
@@ -150,7 +146,7 @@ def test_process_env_create() -> None:
 
 def test_invalid_venv_create(
     make_one: Callable[
-        ..., tuple[nox.virtualenv.VirtualEnv | nox.virtualenv.ProcessEnv, LEGACY_PATH]
+        ..., tuple[nox.virtualenv.VirtualEnv | nox.virtualenv.ProcessEnv, Path]
     ],
 ) -> None:
     with pytest.raises(ValueError, match="venv_backend 'invalid' not recognized"):
@@ -158,7 +154,7 @@ def test_invalid_venv_create(
 
 
 def test_condaenv_constructor_defaults(
-    make_conda: Callable[..., tuple[CondaEnv, Any]],
+    make_conda: Callable[..., tuple[CondaEnv, Path]],
 ) -> None:
     venv, _ = make_conda()
     assert venv.location
@@ -167,7 +163,7 @@ def test_condaenv_constructor_defaults(
 
 
 def test_condaenv_constructor_explicit(
-    make_conda: Callable[..., tuple[CondaEnv, Any]],
+    make_conda: Callable[..., tuple[CondaEnv, Path]],
 ) -> None:
     venv, _ = make_conda(interpreter="3.5", reuse_existing=True)
     assert venv.location
@@ -176,67 +172,67 @@ def test_condaenv_constructor_explicit(
 
 
 @has_conda
-def test_condaenv_create(make_conda: Callable[..., tuple[CondaEnv, Any]]) -> None:
+def test_condaenv_create(make_conda: Callable[..., tuple[CondaEnv, Path]]) -> None:
     venv, dir_ = make_conda()
     venv.create()
 
     if IS_WINDOWS:
-        assert dir_.join("python.exe").check()
-        assert dir_.join("Scripts", "pip.exe").check()
-        assert dir_.join("Library").check()
+        assert dir_.joinpath("python.exe").exists()
+        assert dir_.joinpath("Scripts", "pip.exe").exists()
+        assert dir_.joinpath("Library").exists()
     else:
-        assert dir_.join("bin", "python").check()
-        assert dir_.join("bin", "pip").check()
-        assert dir_.join("lib").check()
+        assert dir_.joinpath("bin", "python").exists()
+        assert dir_.joinpath("bin", "pip").exists()
+        assert dir_.joinpath("lib").exists()
 
     # Test running create on an existing environment. It should be deleted.
-    dir_.ensure("test.txt")
+    dir_.joinpath("test.txt").touch()
     venv.create()
-    assert not dir_.join("test.txt").check()
+    assert not dir_.joinpath("test.txt").exists()
 
     # Test running create on an existing environment with reuse_existing
     # enabled, it should not be deleted.
-    dir_.ensure("test.txt")
-    assert dir_.join("test.txt").check()
+    dir_.joinpath("test.txt").touch()
+    assert dir_.joinpath("test.txt").exists()
     venv.reuse_existing = True
     venv.create()
-    assert dir_.join("test.txt").check()
+    assert dir_.joinpath("test.txt").exists()
     assert venv._reused
 
 
 @has_conda
 def test_condaenv_create_with_params(
-    make_conda: Callable[..., tuple[CondaEnv, Any]],
+    make_conda: Callable[..., tuple[CondaEnv, Path]],
 ) -> None:
     venv, dir_ = make_conda(venv_params=["--verbose"])
     venv.create()
     if IS_WINDOWS:
-        assert dir_.join("python.exe").check()
-        assert dir_.join("Scripts", "pip.exe").check()
+        assert dir_.joinpath("python.exe").exists()
+        assert dir_.joinpath("Scripts", "pip.exe").exists()
     else:
-        assert dir_.join("bin", "python").check()
-        assert dir_.join("bin", "pip").check()
+        assert dir_.joinpath("bin", "python").exists()
+        assert dir_.joinpath("bin", "pip").exists()
 
 
 @has_conda
 def test_condaenv_create_interpreter(
-    make_conda: Callable[..., tuple[CondaEnv, Any]],
+    make_conda: Callable[..., tuple[CondaEnv, Path]],
 ) -> None:
     venv, dir_ = make_conda(interpreter="3.8")
     venv.create()
     if IS_WINDOWS:
-        assert dir_.join("python.exe").check()
-        assert dir_.join("python38.dll").check()
-        assert dir_.join("python38.pdb").check()
-        assert not dir_.join("python38.exe").check()
+        assert dir_.joinpath("python.exe").exists()
+        assert dir_.joinpath("python38.dll").exists()
+        assert dir_.joinpath("python38.pdb").exists()
+        assert not dir_.joinpath("python38.exe").exists()
     else:
-        assert dir_.join("bin", "python").check()
-        assert dir_.join("bin", "python3.8").check()
+        assert dir_.joinpath("bin", "python").exists()
+        assert dir_.joinpath("bin", "python3.8").exists()
 
 
 @has_conda
 def test_conda_env_create_verbose(
-    make_conda: Callable[..., tuple[CondaEnv, Any]],
+    make_conda: Callable[..., tuple[CondaEnv, Path]],
 ) -> None:
     venv, _dir = make_conda()
     with mock.patch("nox.virtualenv.nox.command.run") as mock_run:
@@ -254,26 +250,26 @@ def test_conda_env_create_verbose(
 
 
 @mock.patch("nox.virtualenv._SYSTEM", new="Windows")
-def test_condaenv_bin_windows(make_conda: Callable[..., tuple[CondaEnv, Any]]) -> None:
+def test_condaenv_bin_windows(make_conda: Callable[..., tuple[CondaEnv, Path]]) -> None:
     venv, dir_ = make_conda()
     assert [
-        dir_.strpath,
-        dir_.join("Library", "mingw-w64", "bin").strpath,
-        dir_.join("Library", "usr", "bin").strpath,
-        dir_.join("Library", "bin").strpath,
-        dir_.join("Scripts").strpath,
-        dir_.join("bin").strpath,
+        str(dir_),
+        str(dir_.joinpath("Library", "mingw-w64", "bin")),
+        str(dir_.joinpath("Library", "usr", "bin")),
+        str(dir_.joinpath("Library", "bin")),
+        str(dir_.joinpath("Scripts")),
+        str(dir_.joinpath("bin")),
     ] == venv.bin_paths
 
 
 @has_conda
-def test_condaenv_(make_conda: Callable[..., tuple[CondaEnv, Any]]) -> None:
+def test_condaenv_(make_conda: Callable[..., tuple[CondaEnv, Path]]) -> None:
     venv, _dir = make_conda()
     assert not venv.is_offline()
 
 
 @has_conda
-def test_condaenv_detection(make_conda: Callable[..., tuple[CondaEnv, Any]]) -> None:
+def test_condaenv_detection(make_conda: Callable[..., tuple[CondaEnv, Path]]) -> None:
     venv, dir_ = make_conda()
     venv.create()
     conda = shutil.which("conda")
@@ -290,12 +286,12 @@ def test_condaenv_detection(make_conda: Callable[..., tuple[CondaEnv, Any]]) ->
 
     output_match = path_regex.search(output)
     assert output_match
-    assert output_match.group("env_dir") == dir_.strpath
+    assert dir_.samefile(output_match.group("env_dir"))
 
 
 @has_uv
 def test_uv_creation(
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
 ) -> None:
     venv, _ = make_one(venv_backend="uv")
     assert venv.location
@@ -309,13 +305,13 @@ def test_uv_creation(
 
 @has_uv
 def test_uv_managed_python(
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
 ) -> None:
     make_one(interpreter="cpython3.12", venv_backend="uv")
 
 
 def test_constructor_defaults(
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
 ) -> None:
     venv, _ = make_one()
     assert venv.location
@@ -326,7 +322,7 @@ def test_constructor_defaults(
 
 @pytest.mark.skipif(IS_WINDOWS, reason="Not testing multiple interpreters on Windows.")
 def test_constructor_explicit(
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
 ) -> None:
     venv, _ = make_one(interpreter="python3.5", reuse_existing=True)
     assert venv.location
@@ -336,7 +332,7 @@ def test_constructor_explicit(
 
 def test_env(
     monkeypatch: pytest.MonkeyPatch,
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
 ) -> None:
     monkeypatch.setenv("SIGIL", "123")
     venv, _ = make_one()
@@ -348,7 +344,7 @@ def test_env(
 
 def test_blacklisted_env(
     monkeypatch: pytest.MonkeyPatch,
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
 ) -> None:
     monkeypatch.setenv("__PYVENV_LAUNCHER__", "meep")
     venv, _ = make_one()
@@ -359,7 +355,7 @@ def test_blacklisted_env(
 
 def test__clean_location(
     monkeypatch: pytest.MonkeyPatch,
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
 ) -> None:
     venv, dir_ = make_one()
 
@@ -374,23 +370,23 @@ def test__clean_location(
         mock.MagicMock(),
     )
     monkeypatch.delattr(nox.virtualenv.shutil, "rmtree")  # type: ignore[attr-defined]
-    assert not dir_.check()
+    assert not dir_.exists()
     assert venv._clean_location()
 
     # Reuse existing, and currently exists.
     # Should return False indicating that the venv doesn't need to be created.
     dir_.mkdir()
-    assert dir_.check()
+    assert dir_.exists()
     venv.reuse_existing = True
     assert not venv._clean_location()
 
     # Don't reuse existing, and currently exists.
     # Should return True indicating the venv needs to be created.
     monkeypatch.undo()
-    assert dir_.check()
+    assert dir_.exists()
     venv.reuse_existing = False
     assert venv._clean_location()
-    assert not dir_.check()
+    assert not dir_.exists()
 
     # Reuse existing, but doesn't exist.
     # Should return True indicating the venv needs to be created.
@@ -399,7 +395,7 @@ def test__clean_location(
 
 
 def test_bin_paths(
-    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Path]],
 ) -> None:
     venv, dir_ = make_one()
 
@@ -407,26 +403,23 @@ def test_bin_paths(
     assert len(venv.bin_paths) == 1
     assert venv.bin_paths[0] == venv.bin
 
-    if IS_WINDOWS:
-        assert dir_.join("Scripts").strpath == venv.bin
-    else:
-        assert dir_.join("bin").strpath == venv.bin
+    assert str(dir_.joinpath("Scripts" if IS_WINDOWS else "bin")) == venv.bin
 
 
 @mock.patch("nox.virtualenv._SYSTEM", new="Windows")
 def test_bin_windows(
-    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Path]],
 ) -> None:
     venv, dir_ = make_one()
     assert venv.bin_paths
     assert len(venv.bin_paths) == 1
     assert venv.bin_paths[0] == venv.bin
-    assert dir_.join("Scripts").strpath == venv.bin
+    assert str(dir_.joinpath("Scripts")) == venv.bin
 
 
 def test_create(
     monkeypatch: pytest.MonkeyPatch,
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
 ) -> None:
     monkeypatch.setenv("CONDA_PREFIX", "no-prefix-allowed")
     monkeypatch.setenv("NOT_CONDA_PREFIX", "something-else")
@@ -438,33 +431,33 @@ def test_create(
     assert "NOT_CONDA_PREFIX" in venv.env
 
     if IS_WINDOWS:
-        assert dir_.join("Scripts", "python.exe").check()
-        assert dir_.join("Scripts", "pip.exe").check()
-        assert dir_.join("Lib").check()
+        assert dir_.joinpath("Scripts", "python.exe").exists()
+        assert dir_.joinpath("Scripts", "pip.exe").exists()
+        assert dir_.joinpath("Lib").exists()
     else:
-        assert dir_.join("bin", "python").check()
-        assert dir_.join("bin", "pip").check()
-        assert dir_.join("lib").check()
+        assert dir_.joinpath("bin", "python").exists()
+        assert dir_.joinpath("bin", "pip").exists()
+        assert dir_.joinpath("lib").exists()
 
     # Test running create on an existing environment. It should be deleted.
-    dir_.ensure("test.txt")
+    dir_.joinpath("test.txt").touch()
     venv.create()
-    assert not dir_.join("test.txt").check()
+    assert not dir_.joinpath("test.txt").exists()
 
     # Test running create on an existing environment with reuse_existing
     # enabled, it should not be deleted.
-    dir_.ensure("test.txt")
-    assert dir_.join("test.txt").check()
+    dir_.joinpath("test.txt").touch()
+    assert dir_.joinpath("test.txt").exists()
     venv.reuse_existing = True
 
     venv.create()
 
     assert venv._reused
-    assert dir_.join("test.txt").check()
+    assert dir_.joinpath("test.txt").exists()
 
 
 def test_create_reuse_environment(
-    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Path]],
 ) -> None:
     venv, _location = make_one(reuse_existing=True)
     venv.create()
@@ -475,7 +468,7 @@ def test_create_reuse_environment(
 
 
 def test_create_reuse_environment_with_different_interpreter(
-    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Path]],
     monkeypatch: pytest.MonkeyPatch,
 ) -> None:
     # Making the reuse requirement more strict
@@ -488,17 +481,17 @@ def test_create_reuse_environment_with_different_interpreter(
     monkeypatch.setattr(venv, "_check_reused_environment_interpreter", lambda: False)
 
     # Create a marker file. It should be gone after the environment is re-created.
-    location.join("marker").ensure()
+    location.joinpath("marker").touch()
 
     reused = not venv.create()
 
     assert not reused
-    assert not location.join("marker").check()
+    assert not location.joinpath("marker").exists()
 
 
 @has_uv
 def test_create_reuse_stale_venv_environment(
-    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Path]],
 ) -> None:
     venv, location = make_one(reuse_existing=True)
     venv.create()
@@ -510,7 +503,7 @@ def test_create_reuse_stale_venv_environment(
     version = 3.9.6
     uv = 0.1.9
     """
-    location.join("pyvenv.cfg").write_text(dedent(pyvenv_cfg), encoding="utf-8")
+    location.joinpath("pyvenv.cfg").write_text(dedent(pyvenv_cfg), encoding="utf-8")
 
     reused = not venv.create()
 
@@ -519,7 +512,7 @@ def test_create_reuse_stale_venv_environment(
 
 def test_not_stale_virtualenv_environment(
     make_one: Callable[
-        ..., tuple[nox.virtualenv.VirtualEnv | nox.virtualenv.ProcessEnv, Any]
+        ..., tuple[nox.virtualenv.VirtualEnv | nox.virtualenv.ProcessEnv, Path]
     ],
     monkeypatch: pytest.MonkeyPatch,
 ) -> None:
@@ -537,7 +530,7 @@ def test_not_stale_virtualenv_environment(
 
 @has_conda
 def test_stale_virtualenv_to_conda_environment(
-    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Path]],
 ) -> None:
     venv, _location = make_one(reuse_existing=True, venv_backend="virtualenv")
     venv.create()
@@ -552,7 +545,7 @@ def test_stale_virtualenv_to_conda_environment(
 
 @has_conda
 def test_reuse_conda_environment(
-    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Path]],
 ) -> None:
     venv, _ = make_one(reuse_existing=True, venv_backend="conda")
     venv.create()
@@ -566,7 +559,7 @@ def test_reuse_conda_environment(
 # This mocks micromamba so that it doesn't need to be installed.
 @has_conda
 def test_micromamba_environment(
-    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Path]],
     monkeypatch: pytest.MonkeyPatch,
 ) -> None:
     conda_path = shutil.which("conda")
@@ -591,7 +584,7 @@ def test_micromamba_environment(
 )
 @has_conda
 def test_micromamba_channel_environment(
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
     monkeypatch: pytest.MonkeyPatch,
     params: list[str],
 ) -> None:
@@ -624,7 +617,7 @@ def test_micromamba_channel_environment(
     ],
 )
 def test_stale_environment(
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
     frm: str,
     to: str,
     result: bool,
@@ -643,7 +636,7 @@ def test_stale_environment(
 
 
 def test_passthrough_environment_venv_backend(
-    make_one: Callable[..., tuple[ProcessEnv, Any]],
+    make_one: Callable[..., tuple[ProcessEnv, Path]],
 ) -> None:
     venv, _ = make_one(venv_backend="none")
     venv.create()
@@ -652,7 +645,7 @@ def test_passthrough_environment_venv_backend(
 
 @has_uv
 def test_create_reuse_stale_virtualenv_environment(
-    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Path]],
     monkeypatch: pytest.MonkeyPatch,
 ) -> None:
     monkeypatch.setenv("NOX_ENABLE_STALENESS_CHECK", "1")
@@ -670,7 +663,7 @@ def test_create_reuse_stale_virtualenv_environment(
     base-exec-prefix = /usr
     base-executable = /usr/bin/python3.9
     """
-    location.join("pyvenv.cfg").write_text(dedent(pyvenv_cfg), encoding="utf-8")
+    location.joinpath("pyvenv.cfg").write_text(dedent(pyvenv_cfg), encoding="utf-8")
 
     reused = not venv.create()
 
@@ -681,13 +674,13 @@ def test_create_reuse_stale_virtualenv_environment(
 
 @has_uv
 def test_create_reuse_uv_environment(
-    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Path]],
 ) -> None:
     venv, location = make_one(reuse_existing=True, venv_backend="uv")
     venv.create()
 
     # Place a spurious occurrence of "uv" in the pyvenv.cfg.
-    pyvenv_cfg = location.join("pyvenv.cfg")
+    pyvenv_cfg = location.joinpath("pyvenv.cfg")
     pyvenv_cfg.write_text(
         pyvenv_cfg.read_text(encoding="utf-8") + "bogus = uv\n", encoding="utf-8"
     )
@@ -781,7 +774,7 @@ def test_uv_install(requested_python: str, expected_result: bool) -> None:
 
 
 def test_create_reuse_venv_environment(
-    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Path]],
     monkeypatch: pytest.MonkeyPatch,
 ) -> None:
     # Making the reuse requirement more strict
@@ -791,7 +784,7 @@ def test_create_reuse_venv_environment(
     venv.create()
 
     # Place a spurious occurrence of "virtualenv" in the pyvenv.cfg.
-    pyvenv_cfg = location.join("pyvenv.cfg")
+    pyvenv_cfg = location.joinpath("pyvenv.cfg")
     pyvenv_cfg.write_text(
         pyvenv_cfg.read_text(encoding="utf-8") + "bogus = virtualenv\n",
         encoding="utf-8",
@@ -805,17 +798,17 @@ def test_create_reuse_venv_environment(
 
 @pytest.mark.skipif(IS_WINDOWS, reason="Avoid 'No pyvenv.cfg file' error on Windows.")
 def test_create_reuse_oldstyle_virtualenv_environment(
-    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv | ProcessEnv, Path]],
 ) -> None:
     venv, location = make_one(reuse_existing=True)
     venv.create()
 
-    pyvenv_cfg = location.join("pyvenv.cfg")
-    if not pyvenv_cfg.check():
+    pyvenv_cfg = location.joinpath("pyvenv.cfg")
+    if not pyvenv_cfg.exists():
         pytest.skip("Requires virtualenv >= 20.0.0.")
 
     # virtualenv < 20.0.0 does not create a pyvenv.cfg file.
-    pyvenv_cfg.remove()
+    pyvenv_cfg.unlink()
 
     reused = not venv.create()
 
@@ -825,7 +818,7 @@ def test_create_reuse_oldstyle_virtualenv_environment(
 
 @pytest.mark.skipif(IS_WINDOWS, reason="Avoid 'No pyvenv.cfg file' error on Windows.")
 def test_inner_functions_reusing_venv(
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
     monkeypatch: pytest.MonkeyPatch,
 ) -> None:
     monkeypatch.setenv("NOX_ENABLE_STALENESS_CHECK", "1")
@@ -839,7 +832,7 @@ def test_inner_functions_reusing_venv(
     version = 3.10
     base-prefix = foo
     """
-    location.join("pyvenv.cfg").write_text(dedent(pyvenv_cfg), encoding="utf-8")
+    location.joinpath("pyvenv.cfg").write_text(dedent(pyvenv_cfg), encoding="utf-8")
 
     config = venv._read_pyvenv_cfg()
     assert config
@@ -856,7 +849,7 @@ def test_inner_functions_reusing_venv(
     reason="Python 2.7 unsupported for virtualenv>=20.22.0",
 )
 def test_create_reuse_python2_environment(
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
 ) -> None:
     venv, _location = make_one(reuse_existing=True, interpreter="2.7")
 
@@ -871,7 +864,7 @@ def test_create_reuse_python2_environment(
 
 
 def test_create_venv_backend(
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
 ) -> None:
     venv, _dir = make_one(venv_backend="venv")
     venv.create()
@@ -879,16 +872,16 @@ def test_create_venv_backend(
 
 @pytest.mark.skipif(IS_WINDOWS, reason="Not testing multiple interpreters on Windows.")
 def test_create_interpreter(
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
 ) -> None:
     venv, dir_ = make_one(interpreter="python3")
     venv.create()
-    assert dir_.join("bin", "python").check()
-    assert dir_.join("bin", "python3").check()
+    assert dir_.joinpath("bin", "python").exists()
+    assert dir_.joinpath("bin", "python3").exists()
 
 
 def test__resolved_interpreter_none(
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
 ) -> None:
     # Establish that the _resolved_interpreter method is a no-op if the
     # interpreter is not set.
@@ -910,7 +903,7 @@ def test__resolved_interpreter_none(
 @mock.patch.object(shutil, "which", return_value=True)
 def test__resolved_interpreter_numerical_non_windows(
     which: mock.Mock,
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
     input_: str,
     expected: str,
 ) -> None:
@@ -925,7 +918,7 @@ def test__resolved_interpreter_numerical_non_windows(
 @mock.patch.object(shutil, "which", return_value=False)
 def test__resolved_interpreter_invalid_numerical_id(
     which: mock.Mock,
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
     input_: str,
 ) -> None:
     venv, _ = make_one(interpreter=input_)
@@ -939,7 +932,7 @@ def test__resolved_interpreter_invalid_numerical_id(
 @mock.patch("nox.virtualenv._SYSTEM", new="Linux")
 @mock.patch.object(shutil, "which", return_value=False)
 def test__resolved_interpreter_32_bit_non_windows(
-    which: mock.Mock, make_one: Callable[..., tuple[VirtualEnv, Any]]
+    which: mock.Mock, make_one: Callable[..., tuple[VirtualEnv, Path]]
 ) -> None:
     venv, _ = make_one(interpreter="3.6-32")
 
@@ -951,7 +944,7 @@ def test__resolved_interpreter_32_bit_non_windows(
 @mock.patch("nox.virtualenv._SYSTEM", new="Linux")
 @mock.patch.object(shutil, "which", return_value=True)
 def test__resolved_interpreter_non_windows(
-    which: mock.Mock, make_one: Callable[..., tuple[VirtualEnv, Any]]
+    which: mock.Mock, make_one: Callable[..., tuple[VirtualEnv, Path]]
 ) -> None:
     # Establish that the interpreter is simply passed through resolution
     # on non-Windows.
@@ -964,7 +957,7 @@ def test__resolved_interpreter_non_windows(
 @mock.patch("nox.virtualenv._SYSTEM", new="Windows")
 @mock.patch.object(shutil, "which")
 def test__resolved_interpreter_windows_full_path(
-    which: mock.Mock, make_one: Callable[..., tuple[VirtualEnv, Any]]
+    which: mock.Mock, make_one: Callable[..., tuple[VirtualEnv, Path]]
 ) -> None:
     # Establish that if we get a fully-qualified system path (on Windows
     # or otherwise) and the path exists, that we accept it.
@@ -989,7 +982,7 @@ def test__resolved_interpreter_windows_full_path(
 def test__resolved_interpreter_windows_pyexe(
     which: mock.Mock,
     run: mock.Mock,
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
     input_: str,
     expected: str,
 ) -> None:
@@ -1022,7 +1015,7 @@ def test__resolved_interpreter_windows_pyexe(
 @mock.patch.object(subprocess, "run")
 @mock.patch.object(shutil, "which")
 def test__resolved_interpreter_windows_pyexe_fails(
-    which: mock.Mock, run: mock.Mock, make_one: Callable[..., tuple[VirtualEnv, Any]]
+    which: mock.Mock, run: mock.Mock, make_one: Callable[..., tuple[VirtualEnv, Path]]
 ) -> None:
     # Establish that if the py launcher fails, we give the right error.
     venv, _ = make_one(interpreter="python3.6")
@@ -1046,7 +1039,7 @@ def test__resolved_interpreter_windows_pyexe_fails(
 @mock.patch("nox.virtualenv._SYSTEM", new="Windows")
 @mock.patch("nox.virtualenv.UV_PYTHON_SUPPORT", new=False)
 def test__resolved_interpreter_windows_path_and_version(
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
     patch_sysfind: Callable[..., None],
 ) -> None:
     # Establish that if we get a standard pythonX.Y path, we look it
@@ -1078,7 +1071,7 @@ def test__resolved_interpreter_windows_path_and_version_fails(
     input_: str,
     sysfind_result: None | str,
     sysexec_result: str,
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
     patch_sysfind: Callable[..., None],
 ) -> None:
     # Establish that if we get a standard pythonX.Y path, we look it
@@ -1099,7 +1092,7 @@ def test__resolved_interpreter_windows_path_and_version_fails(
 @mock.patch("nox.virtualenv._SYSTEM", new="Windows")
 @mock.patch.object(shutil, "which")
 def test__resolved_interpreter_not_found(
-    which: mock.Mock, make_one: Callable[..., tuple[VirtualEnv, Any]]
+    which: mock.Mock, make_one: Callable[..., tuple[VirtualEnv, Path]]
 ) -> None:
     # Establish that if an interpreter cannot be found at a standard
     # location on Windows, we raise a useful error.
@@ -1116,7 +1109,7 @@ def test__resolved_interpreter_not_found(
 @mock.patch("nox.virtualenv._SYSTEM", new="Windows")
 @mock.patch("nox.virtualenv.locate_via_py", new=lambda _: None)  # type: ignore[misc]  # noqa: PT008
 def test__resolved_interpreter_nonstandard(
-    make_one: Callable[..., tuple[VirtualEnv, Any]],
+    make_one: Callable[..., tuple[VirtualEnv, Path]],
 ) -> None:
     # Establish that we do not try to resolve non-standard locations
     # on Windows.
@@ -1129,7 +1122,7 @@ def test__resolved_interpreter_nonstandard(
 @mock.patch("nox.virtualenv._SYSTEM", new="Linux")
 @mock.patch.object(shutil, "which", return_value=True)
 def test__resolved_interpreter_cache_result(
-    which: mock.Mock, make_one: Callable[..., tuple[VirtualEnv, Any]]
+    which: mock.Mock, make_one: Callable[..., tuple[VirtualEnv, Path]]
 ) -> None:
     venv, _ = make_one(interpreter="3.6")
 
@@ -1145,7 +1138,7 @@ def test__resolved_interpreter_cache_result(
 @mock.patch("nox.virtualenv._SYSTEM", new="Linux")
 @mock.patch.object(shutil, "which", return_value=None)
 def test__resolved_interpreter_cache_failure(
-    which: mock.Mock, make_one: Callable[..., tuple[VirtualEnv, Any]]
+    which: mock.Mock, make_one: Callable[..., tuple[VirtualEnv, Path]]
 ) -> None:
     venv, _ = make_one(interpreter="3.7-32")