From 80c9e3b4da4ed08ac80058eaf3ff7fd9a01efeb7 Mon Sep 17 00:00:00 2001 From: Erik Montnemery Date: Tue, 1 Dec 2026 19:40:41 +0100 Subject: [PATCH] Make agents give each git worktree its own venv (#195846) Co-authored-by: Martin Hjelmare --- AGENTS.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/AGENTS.md b/AGENTS.md index 1524e00da7ef..620212b02d41 100644 --- a/AGENTS.md +++ b/AGENTS.md @@ -26,7 +26,7 @@ This repository contains the core of Home Assistant, a Python 3 based home autom ## Development Commands - Run "python3" in current virtual environment to ensure the correct Python version is used for testing. -- When entering a new environment or worktree, run `script/setup` to set up the virtual environment with all development dependencies (pylint, pre-commit hooks, etc.). This is required before committing. If uv reports that no download was found for the required Python version, the environment is running an outdated version of uv; upgrade it with `curl -LsSf https://astral.sh/uv/install.sh | sh` and run `script/setup` again. +- When entering a new environment or worktree, run `script/setup` to set up the virtual environment with all development dependencies (pylint, pre-commit hooks, etc.). This is required before committing. `script/setup` installs into the active virtual environment when `VIRTUAL_ENV` is set. In a git worktree, run it as `env -u VIRTUAL_ENV script/setup` so it creates the worktree's own `.venv`; otherwise it installs into the main checkout's environment and points that environment's editable installs at the worktree. If uv reports that no download was found for the required Python version, the environment is running an outdated version of uv; upgrade it with `curl -LsSf https://astral.sh/uv/install.sh | sh` and run `script/setup` again. - .vscode/tasks.json contains useful commands used for development. - After finishing a code session, run `base=$(git merge-base HEAD dev) && uv run --no-sync prek run --files $(git diff --name-only --diff-filter=d "$base"; git ls-files --others --exclude-standard)` to check the files changed on the branch (committed, uncommitted and untracked) for linting and formatting issues.