From 236166480c835e0bc3866ab680f9722b4e1b07f4 Mon Sep 17 00:00:00 2001 From: "Jens H. Nielsen" Date: Thu, 1 Oct 2026 21:53:15 +0200 Subject: [PATCH] Update agent instructions to prefer prek and uv run Use prek instead of pre-commit when it is available on the PATH, and run commands that need the Python environment via uv run (with --extra test for pytest and pyright) when the environment is managed with uv. --- .github/copilot-instructions.md | 25 +++++++++++++++++++------ 1 file changed, 19 insertions(+), 6 deletions(-) diff --git a/.github/copilot-instructions.md b/.github/copilot-instructions.md index 3f3ca7f5991b..535e46df83a9 100644 --- a/.github/copilot-instructions.md +++ b/.github/copilot-instructions.md @@ -8,17 +8,30 @@ be deployed at https://microsoft.github.io/Qcodes/. The documentation includes Contributor's guide, so please follow that closely. -Before committing anything, run pre-commit hooks with ```pre-commit run --all``` -and make sure they pass, and fix anything that is failing. The pre-commit hooks will ensure -correct formatting of the code and linting as well. The pre-commit hooks are automatically installed -so there is no need to manually install them. +If the user manages the Python environment with ``uv``, always run commands that need that +environment (``pytest``, ``pyright``, ``python`` etc.) via ``uv run``. Both ``pytest`` and +``pyright`` need the test dependencies, so always run them with ``--extra test``, e.g. +``uv run --extra test pytest tests`` and ``uv run --extra test pyright``. Without it ``uv run`` +only ensures that the core dependencies are installed, so the test dependencies may be missing. +On Windows, where ``pyright`` is typically installed as an npm shim, use +``uv run --extra test pyright.cmd``. +Do not activate the virtual environment, call executables inside it directly, or point tools at +an interpreter with options such as ``--pythonpath``; let ``uv run`` select the environment. + +Before committing anything, run pre-commit hooks and make sure they pass, and fix anything that +is failing. If ``prek`` is available on the ``PATH``, use it via ``prek run --all-files``; otherwise +use ``pre-commit run --all``. The hooks will ensure correct formatting of the code and linting as +well. The hooks are automatically installed so there is no need to manually install them. QCoDeS is a typed package, hence all new code should include clear and correct type annotations. We use ``pyright`` to statically check the correctness of the code with type annotations. -Run it via ``pyright``. The code that should be typecheked is configured in ``pyproject.toml``. +Run it via ``pyright`` (or ``uv run --extra test pyright`` / ``uv run --extra test pyright.cmd`` +as described above). +The code that should be typechecked is configured in ``pyproject.toml``. -For running tests, we use ``pytest``. They can be run with ``pytest tests``. +For running tests, we use ``pytest``. They can be run with ``pytest tests`` +(or ``uv run --extra test pytest tests`` as described above). See pytest markers for additional options of running tests. We use Dependabot from GitHub to keep our dependencies up to date, we use ``requirements.txt``