From 018149789972a417e4a4db48c1907248d7858785 Mon Sep 17 00:00:00 2001 From: Gary Yendell Date: Tue, 13 Jan 2026 10:14:47 +0000 Subject: [PATCH 1/2] fix: Pass correct python path to tox type-checking Use native tox environment variable expansion to pass $VIRTUAL_ENV Fix whitespace --- template/pyproject.toml.jinja | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/template/pyproject.toml.jinja b/template/pyproject.toml.jinja index 747c3eda..d8ab2b1c 100644 --- a/template/pyproject.toml.jinja +++ b/template/pyproject.toml.jinja @@ -104,7 +104,7 @@ commands = [ [ "{{ type_checker }}", {% if type_checker=="pyright" %}"--pythonpath", - ".venv/bin/python", + "{env:VIRTUAL_ENV}/bin/python", {% endif %}"src", "tests", { replace = "posargs", default = [ @@ -116,7 +116,7 @@ commands = [ description = "Run tests with coverage" commands = [ [ - "pytest", + "pytest", "--cov={{ package_name }}", "--cov-report", "term", From 331c0ab73e199b6151a6cc8544d79ccd374dfdc7 Mon Sep 17 00:00:00 2001 From: Gary Yendell Date: Tue, 13 Jan 2026 11:01:40 +0000 Subject: [PATCH 2/2] fix: Use .venv in tmp directory for create tests UV_PROJECT_ENVIRONMENT="" makes uv create .venv in project director VIRTUAL_VENV= is required so that pyright can find external dependencies for its checks --- tests/test_example.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/test_example.py b/tests/test_example.py index 4b149e6b..ea94347b 100644 --- a/tests/test_example.py +++ b/tests/test_example.py @@ -1,5 +1,6 @@ import functools import json +import os import shlex import subprocess import tomllib @@ -27,12 +28,13 @@ def copy_project(project_path: Path, **kwargs): run_pipe("git add .", cwd=str(project_path)) -def run_pipe(cmd: str, cwd=None) -> str: +def run_pipe(cmd: str, cwd=None, venv="") -> str: sp = subprocess.run( shlex.split(cmd), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, cwd=cwd, + env=dict(os.environ, UV_PROJECT_ENVIRONMENT="", VIRTUAL_ENV=venv), ) output = sp.stdout.decode() assert sp.returncode == 0, output @@ -41,7 +43,7 @@ def run_pipe(cmd: str, cwd=None) -> str: def make_venv(project_path: Path) -> Callable[[str], str]: venv_path = project_path / ".venv" - run = functools.partial(run_pipe, cwd=str(project_path)) + run = functools.partial(run_pipe, cwd=str(project_path), venv=venv_path) run("uv sync") # Create a lockfile and install packages for exe_path in [