From 8917b00fd97d0fc54c0f8c6bc5fb5062f84ecba5 Mon Sep 17 00:00:00 2001 From: Aria Desires Date: Fri, 12 Sep 2025 09:15:27 -0400 Subject: [PATCH] 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 --- docs/concepts/projects/dependencies.md | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/docs/concepts/projects/dependencies.md b/docs/concepts/projects/dependencies.md index d518deee7..a38bcc325 100644 --- a/docs/concepts/projects/dependencies.md +++ b/docs/concepts/projects/dependencies.md @@ -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 `. +### 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