Skip to content

Commit 0fd676c

Browse files
authored
πŸ› fix(installer): align with tox 4.59 API changes (#366)
The scheduled check has been red since tox 4.59 landed (https://github.com/tox-dev/tox-uv/actions/runs/31787082911): tox-dev/tox@7be33b8 widened `Pip._install_list_of_deps` to `Sequence[Requirement | Package]`, so ty reports the narrower override in `_installer.py` as incompatible, and `ToxEnv.name` now reads `conf.get("env_name", str)`, so `test_get_python_abs_path_with_impl` priming only `conf.__getitem__` hands a MagicMock to `PythonSpec.from_string_spec`. Widen the override to `Package`, drop the `ty: ignore[no-matching-overload]` that ty now flags as unused, and patch `name` with a PropertyMock in the test the same way its neighbour does, so it stays independent of how tox resolves the env name.
1 parent 90b01d0 commit 0fd676c

3 files changed

Lines changed: 6 additions & 10 deletions

File tree

β€Žsrc/tox_uv/_installer.pyβ€Ž

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626

2727
if TYPE_CHECKING:
2828
from tox.config.main import Config
29-
from tox.tox_env.package import PathPackage
29+
from tox.tox_env.package import Package
3030

3131
from ._venv import UvVenv
3232

@@ -145,9 +145,7 @@ def _sourced_pkg_names(self) -> set[str]:
145145

146146
def _install_list_of_deps( # ruff:ignore[complex-structure, too-many-branches]
147147
self,
148-
arguments: Sequence[
149-
Requirement | WheelPackage | SdistPackage | EditableLegacyPackage | EditablePackage | PathPackage
150-
],
148+
arguments: Sequence[Requirement | Package],
151149
section: str,
152150
of_type: str,
153151
) -> None:

β€Žsrc/tox_uv/_venv.pyβ€Ž

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,7 @@ def uv_python_preference_post_process(value: str | None) -> str:
8181
return value.lower()
8282
return "system"
8383

84-
self.conf.add_config( # ty: ignore[no-matching-overload]
84+
self.conf.add_config(
8585
keys=["uv_python_preference"],
8686
of_type=cast("type[PythonPreference | None]", PythonPreference | None),
8787
# use os.environ here instead of self.environment_variables as this value is needed to create the virtual

β€Žtests/test_tox_uv_venv.pyβ€Ž

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -579,11 +579,9 @@ def test_get_python_free_threaded(base_python: str, is_free_threaded: int | None
579579

580580
@pytest.mark.parametrize("env_name", ["pypy", "cpython"])
581581
def test_get_python_abs_path_with_impl(env_name: str) -> None:
582-
create_args = mock.Mock()
583-
create_args.conf = mock.MagicMock()
584-
create_args.conf.__getitem__.return_value = env_name
585-
uv_venv = _TestUvVenv(create_args=create_args)
586-
python_info = uv_venv.get_python_info(sys.executable)
582+
uv_venv = _TestUvVenv(create_args=mock.Mock())
583+
with mock.patch.object(type(uv_venv), "name", new_callable=mock.PropertyMock, return_value=env_name):
584+
python_info = uv_venv.get_python_info(sys.executable)
587585
assert python_info is not None
588586
expected_impl = "CPython" if env_name == "cpython" else env_name
589587
assert python_info.implementation.lower() == expected_impl.lower()

0 commit comments

Comments
Β (0)