Skip to content

Commit a27d817

Browse files
committed
docs: refactor/enhance group dependencies
- Add example of dependency group includes - Refactor section to to show pyproject.toml config & explanation of dependency resolution first and move CLI implementation and options into it's own section
1 parent 4bab1cd commit a27d817

File tree

1 file changed

+36
-16
lines changed

1 file changed

+36
-16
lines changed

docs/concepts/projects/dependencies.md

+36-16
Original file line numberDiff line numberDiff line change
@@ -613,20 +613,48 @@ instead. Additionally, the `dev` group is [synced by default](#default-groups).
613613

614614
### Dependency groups
615615

616+
uv supports
617+
[PyPA spec Dependency Groups](https://packaging.python.org/en/latest/specifications/dependency-groups/):
618+
619+
```toml title="pyproject.toml"
620+
[dependency-groups]
621+
dev = [
622+
{include-group = "lint"},
623+
"pytest",
624+
]
625+
lint = [
626+
"ruff"
627+
]
628+
```
629+
630+
uv requires that all dependency groups are compatible with each other and resolves all groups
631+
together when creating the lockfile.
632+
633+
If dependencies declared in one group are not compatible with those in another group, uv will fail
634+
to resolve the requirements of the project with an error unless you explicitly
635+
[declare them as conflicting](./config.md#conflicting-dependencies).
636+
637+
#### CLI Options
638+
616639
Development dependencies can be divided into multiple groups, using the `--group` flag.
617640

618-
For example, to add a development dependency in the `lint` group:
641+
For example, to add a dependency in the `ci` group:
619642

620643
```console
621-
$ uv add --group lint ruff
644+
$ uv add --group ci tox pip-audit
622645
```
623646

624-
Which results in the following `[dependency-groups]` definition:
647+
Which results in the updated definition:
625648

626649
```toml title="pyproject.toml"
627650
[dependency-groups]
651+
ci = [
652+
"pip-audit",
653+
"tox",
654+
]
628655
dev = [
629-
"pytest"
656+
{include-group = "lint"},
657+
"pytest",
630658
]
631659
lint = [
632660
"ruff"
@@ -636,21 +664,13 @@ lint = [
636664
Once groups are defined, the `--all-groups`, `--no-default-groups`, `--group`, `--only-group`, and
637665
`--no-group` options can be used to include or exclude their dependencies.
638666

639-
!!! tip
640-
641-
The `--dev`, `--only-dev`, and `--no-dev` flags are equivalent to `--group dev`,
642-
`--only-group dev`, and `--no-group dev` respectively.
643-
644-
uv requires that all dependency groups are compatible with each other and resolves all groups
645-
together when creating the lockfile.
646-
647-
If dependencies declared in one group are not compatible with those in another group, uv will fail
648-
to resolve the requirements of the project with an error.
667+
The `--dev`, `--only-dev`, and `--no-dev` flags are equivalent to `--group dev`, `--only-group dev`,
668+
and `--no-group dev` respectively.
649669

650670
!!! note
651671

652-
If you have dependency groups that conflict with one another, resolution will fail
653-
unless you explicitly [declare them as conflicting](./config.md#conflicting-dependencies).
672+
`include-group` is not supported from the CLI ([#9054](https://github.com/astral-sh/uv/issues/9054)).
673+
Those edits must be made manually.
654674

655675
### Default groups
656676

0 commit comments

Comments
 (0)