add docs for dependency group `requires-python` (#14282)

I specifically show more details than necessary in the example to make
it more clear that this is *NOT* the normal dependency-groups table.

---------

Co-authored-by: Zanie Blue <contact@zanie.dev>
This commit is contained in:
Aria Desires 2025-09-12 09:15:27 -04:00 committed by GitHub
parent 0b8117a9f7
commit 8917b00fd9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 20 additions and 0 deletions

View File

@ -719,6 +719,26 @@ default-groups = "all"
To disable this behaviour during `uv run` or `uv sync`, use `--no-default-groups`.
To exclude a specific default group, use `--no-group <name>`.
### Group `requires-python`
By default, dependency groups must be compatible with your project's `requires-python` range.
If a dependency group requires a different range of Python versions than your project, you can
specify a `requires-python` for the group in `[tool.uv.dependency-groups]`, e.g.:
```toml title="pyproject.toml" hl_lines="9-10"
[project]
name = "example"
version = "0.0.0"
requires-python = ">=3.10"
[dependency-groups]
dev = ["pytest"]
[tool.uv.dependency-groups]
dev = {requires-python = ">=3.12"}
```
### Legacy `dev-dependencies`
Before `[dependency-groups]` was standardized, uv used the `tool.uv.dev-dependencies` field to