Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 13 additions & 8 deletions crates/uv/src/commands/project/remove.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ pub(crate) async fn remove(
if deps.is_empty() {
warn_if_present(&package, &toml);
anyhow::bail!(
"The dependency `{package}` could not be found in `dependencies`"
"The dependency `{package}` could not be found in `project.dependencies`"
);
}
}
Expand All @@ -123,7 +123,7 @@ pub(crate) async fn remove(
if dev_deps.is_empty() && group_deps.is_empty() {
warn_if_present(&package, &toml);
anyhow::bail!(
"The dependency `{package}` could not be found in `dev-dependencies` or `dependency-groups.dev`"
"The dependency `{package}` could not be found in `tool.uv.dev-dependencies` or `tool.uv.dependency-groups.dev`"
);
}
}
Expand All @@ -132,7 +132,7 @@ pub(crate) async fn remove(
if deps.is_empty() {
warn_if_present(&package, &toml);
anyhow::bail!(
"The dependency `{package}` could not be found in `optional-dependencies`"
"The dependency `{package}` could not be found in `project.optional-dependencies.{extra}`"
);
}
}
Expand All @@ -144,15 +144,15 @@ pub(crate) async fn remove(
if dev_deps.is_empty() && group_deps.is_empty() {
warn_if_present(&package, &toml);
anyhow::bail!(
"The dependency `{package}` could not be found in `dev-dependencies` or `dependency-groups.dev`"
"The dependency `{package}` could not be found in `tool.uv.dev-dependencies` or `tool.uv.dependency-groups.dev`"
);
}
} else {
let deps = toml.remove_dependency_group_requirement(&package, group)?;
if deps.is_empty() {
warn_if_present(&package, &toml);
anyhow::bail!(
"The dependency `{package}` could not be found in `dependency-groups`"
"The dependency `{package}` could not be found in `dependency-groups.{group}`"
);
}
}
Expand Down Expand Up @@ -323,16 +323,21 @@ fn warn_if_present(name: &PackageName, pyproject: &PyProjectTomlMut) {
warn_user!("`{name}` is a production dependency");
}
DependencyType::Dev => {
warn_user!("`{name}` is a development dependency; try calling `uv remove --dev`");
warn_user!(
"`{name}` is a development dependency (try: `{}`)",
format!("uv remove {name} --dev`").bold()
);
}
DependencyType::Optional(group) => {
warn_user!(
"`{name}` is an optional dependency; try calling `uv remove --optional {group}`",
"`{name}` is an optional dependency (try: `{}`)",
format!("uv remove {name} --optional {group}").bold()
);
}
DependencyType::Group(group) => {
warn_user!(
"`{name}` is in the `{group}` group; try calling `uv remove --group {group}`",
"`{name}` is in the `{group}` group (try: `{}`)",
format!("uv remove {name} --group {group}").bold()
);
}
}
Expand Down
14 changes: 7 additions & 7 deletions crates/uv/tests/it/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1113,8 +1113,8 @@ fn add_remove_dev() -> Result<()> {
----- stdout -----

----- stderr -----
warning: `anyio` is in the `dev` group; try calling `uv remove --group dev`
error: The dependency `anyio` could not be found in `dependencies`
warning: `anyio` is in the `dev` group (try: `uv remove anyio --group dev`)
error: The dependency `anyio` could not be found in `project.dependencies`
"###);

// Remove the dependency.
Expand Down Expand Up @@ -1336,8 +1336,8 @@ fn add_remove_optional() -> Result<()> {
----- stdout -----

----- stderr -----
warning: `anyio` is an optional dependency; try calling `uv remove --optional io`
error: The dependency `anyio` could not be found in `dependencies`
warning: `anyio` is an optional dependency (try: `uv remove anyio --optional io`)
error: The dependency `anyio` could not be found in `project.dependencies`
"###);

// Remove the dependency.
Expand Down Expand Up @@ -4817,7 +4817,7 @@ fn remove_group() -> Result<()> {
----- stdout -----

----- stderr -----
error: The dependency `anyio` could not be found in `dependency-groups`
error: The dependency `anyio` could not be found in `dependency-groups.test`
"###);

let pyproject_toml = context.read("pyproject.toml");
Expand Down Expand Up @@ -4845,7 +4845,7 @@ fn remove_group() -> Result<()> {
----- stdout -----

----- stderr -----
error: The dependency `anyio` could not be found in `dependency-groups`
error: The dependency `anyio` could not be found in `dependency-groups.test`
"###);

let pyproject_toml = context.temp_dir.child("pyproject.toml");
Expand All @@ -4864,7 +4864,7 @@ fn remove_group() -> Result<()> {

----- stderr -----
warning: `anyio` is a production dependency
error: The dependency `anyio` could not be found in `dependency-groups`
error: The dependency `anyio` could not be found in `dependency-groups.test`
"###);

Ok(())
Expand Down