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
5 changes: 5 additions & 0 deletions crates/uv-workspace/src/pyproject_mut.rs
Original file line number Diff line number Diff line change
Expand Up @@ -525,6 +525,11 @@ impl PyProjectTomlMut {

/// Remove a matching source from `tool.uv.sources`, if it exists.
fn remove_source(&mut self, name: &PackageName) -> Result<(), Error> {
// If the dependency is still in use, don't remove the source.
if !self.find_dependency(name, None).is_empty() {
return Ok(());
}

if let Some(sources) = self
.doc
.get_mut("tool")
Expand Down
26 changes: 14 additions & 12 deletions crates/uv/tests/it/edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4584,12 +4584,10 @@ fn remove_repeated() -> Result<()> {
----- stdout -----

----- stderr -----
Resolved 4 packages in [TIME]
Prepared 3 packages in [TIME]
Installed 3 packages in [TIME]
+ anyio==4.3.0
+ idna==3.6
+ sniffio==1.3.1
Resolved 2 packages in [TIME]
Prepared 1 package in [TIME]
Installed 1 package in [TIME]
+ anyio==4.3.0+foo (from file://[WORKSPACE]/scripts/packages/anyio_local)
"###);

let pyproject_toml = context.read("pyproject.toml");
Expand All @@ -4610,6 +4608,9 @@ fn remove_repeated() -> Result<()> {

[tool.uv]
dev-dependencies = ["anyio"]

[tool.uv.sources]
anyio = { path = "[WORKSPACE]/scripts/packages/anyio_local" }
"###
);
});
Expand All @@ -4620,8 +4621,8 @@ fn remove_repeated() -> Result<()> {
----- stdout -----

----- stderr -----
Resolved 4 packages in [TIME]
Audited 3 packages in [TIME]
Resolved 2 packages in [TIME]
Audited 1 package in [TIME]
"###);

let pyproject_toml = context.read("pyproject.toml");
Expand All @@ -4642,6 +4643,9 @@ fn remove_repeated() -> Result<()> {

[tool.uv]
dev-dependencies = ["anyio"]

[tool.uv.sources]
anyio = { path = "[WORKSPACE]/scripts/packages/anyio_local" }
"###
);
});
Expand All @@ -4653,10 +4657,8 @@ fn remove_repeated() -> Result<()> {

----- stderr -----
Resolved 1 package in [TIME]
Uninstalled 3 packages in [TIME]
- anyio==4.3.0
- idna==3.6
- sniffio==1.3.1
Uninstalled 1 package in [TIME]
- anyio==4.3.0+foo (from file://[WORKSPACE]/scripts/packages/anyio_local)
"###);

let pyproject_toml = context.read("pyproject.toml");
Expand Down
Loading