You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add to dependency-groups.dev in uv add --dev (#8570)
## Summary
`uv add --dev` now updates the `dependency-groups.dev` section, rather
than `tool.uv.dev-dependencies` -- unless the dependency is already
present in `tool.uv.dev-dependencies`.
`uv remove --dev` now removes from both `dependency-groups.dev` and
`tool.uv.dev-dependencies`.
`--dev` and `--group dev` are now treated equivalently in `uv add` and
`uv remove`.
Copy file name to clipboardExpand all lines: crates/uv/src/commands/project/add.rs
+61-8Lines changed: 61 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -21,7 +21,7 @@ use uv_distribution::DistributionDatabase;
21
21
use uv_distribution_types::{Index,IndexName,UnresolvedRequirement,VersionId};
22
22
use uv_fs::Simplified;
23
23
use uv_git::{GitReference,GIT_STORE};
24
-
use uv_normalize::PackageName;
24
+
use uv_normalize::{PackageName,DEV_DEPENDENCIES};
25
25
use uv_pep508::{ExtraName,Requirement,UnnamedRequirement,VersionOrUrl};
26
26
use uv_pypi_types::{redact_credentials,ParsedUrl,RequirementSource,VerbatimParsedUrl};
27
27
use uv_python::{
@@ -203,8 +203,12 @@ pub(crate) async fn add(
203
203
DependencyType::Optional(_) => {
204
204
bail!("Project is missing a `[project]` table; add a `[project]` table to use optional dependencies, or run `{}` instead","uv add --dev".green())
205
205
}
206
+
DependencyType::Group(_) => {
207
+
// TODO(charlie): Allow adding to `dependency-groups` in non-`[project]`
208
+
// targets, per PEP 735.
209
+
bail!("Project is missing a `[project]` table; add a `[project]` table to use `dependency-groups` dependencies, or run `{}` instead","uv add --dev".green())
210
+
}
206
211
DependencyType::Dev => (),
207
-
DependencyType::Group(_) => (),
208
212
}
209
213
}
210
214
@@ -463,8 +467,49 @@ pub(crate) async fn add(
463
467
_ => source,
464
468
};
465
469
470
+
// Determine the dependency type.
471
+
let dependency_type = match&dependency_type {
472
+
DependencyType::Dev => {
473
+
let existing = toml.find_dependency(&requirement.name,None);
474
+
if existing.iter().any(|dependency_type| matches!(dependency_type,DependencyType::Group(group)if group == &*DEV_DEPENDENCIES)){
475
+
// If the dependency already exists in `dependency-groups.dev`, use that.
0 commit comments