TIL: Dependency groups and uv run

AI-generated summary of reporting by Simon Willison’s Weblog. Read the original for the full story.

Why it matters

Python developers can now clone a project and run its tests with a single 'uv run pytest' command, removing manual virtualenv and dependency setup steps.

Read this as

Simon Willison published a short guide (a 'TIL' post) explaining a trick for Python projects using uv, a tool that manages Python packages. By declaring a 'dev' dependency group containing pytest in pyproject.toml, anyone who clones a project can run 'uv run pytest' and the test tool installs and runs automatically. He demonstrated it on his datasette-extract project, and also used Claude Code to build a redirects plugin for his TIL site.

Willison documents a project setup pattern using uv and PEP 735 dependency groups that cuts onboarding to three commands: clone, cd, and 'uv run pytest'. This reduces friction for contributors to his open-source projects like datasette-extract. He also shipped a small plugin, datasette-redirects, built with Claude Code, to handle URL redirects after reorganising his TIL site. The cost is minimal; the benefit is faster developer onboarding.

The pattern declares a dev dependency group under PEP 735 in pyproject.toml, [dependency-groups] dev = ["pytest"], so 'uv run pytest' auto-creates a virtual environment, installs the group, and executes tests. No manual 'uv sync' or activation is needed. Willison also reorganised his uv TILs into a subfolder, requiring a datasette-redirects plugin for old-path redirects and a build-script change to preserve file creation dates.

Read the original

This summary exists to save you time, not to replace the source.

Key terms

uv pytest PEP 735 pyproject.toml datasette-extract datasette-redirects Claude Code

Was this summary useful?

One click, anonymous. It tells us which summaries to re-run.

Related reading