From 7ef8d66c94878c54e47eccdeb8fe12efa74e65e8 Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Tue, 17 Feb 2026 09:24:15 -0600 Subject: [PATCH] Clean up legacy workspace root concept (#17864) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Prompted by https://github.com/astral-sh/uv/issues/17855 — I think this branch is just dead code? --- crates/uv-resolver/src/lock/export/mod.rs | 2 +- crates/uv-resolver/src/lock/installable.rs | 2 +- crates/uv-workspace/src/workspace.rs | 32 ++++++------------- .../uv/src/commands/project/install_target.rs | 2 +- crates/uv/tests/it/edit.rs | 2 +- crates/uv/tests/it/lock.rs | 14 ++++---- crates/uv/tests/it/sync.rs | 22 ++++++------- 7 files changed, 32 insertions(+), 44 deletions(-) diff --git a/crates/uv-resolver/src/lock/export/mod.rs b/crates/uv-resolver/src/lock/export/mod.rs index 08779add2..23f372413 100644 --- a/crates/uv-resolver/src/lock/export/mod.rs +++ b/crates/uv-resolver/src/lock/export/mod.rs @@ -158,7 +158,7 @@ impl<'lock> ExportableRequirements<'lock> { } // Add requirements that are exclusive to the workspace root (e.g., dependency groups in - // (legacy) non-project workspace roots). + // non-project workspace roots). let root_requirements = target .lock() .requirements() diff --git a/crates/uv-resolver/src/lock/installable.rs b/crates/uv-resolver/src/lock/installable.rs index 9c112a38b..83ac7f48a 100644 --- a/crates/uv-resolver/src/lock/installable.rs +++ b/crates/uv-resolver/src/lock/installable.rs @@ -249,7 +249,7 @@ pub trait Installable<'lock> { } // Add any dependency groups that are exclusive to the workspace root (e.g., dev - // dependencies in (legacy) non-project workspace roots). + // dependencies in non-project workspace roots). for (group, dependency) in self .lock() .dependency_groups() diff --git a/crates/uv-workspace/src/workspace.rs b/crates/uv-workspace/src/workspace.rs index 4d4559e44..26b1aa73b 100644 --- a/crates/uv-workspace/src/workspace.rs +++ b/crates/uv-workspace/src/workspace.rs @@ -97,14 +97,10 @@ pub enum MemberDiscovery { /// Whether a "project" must be defined via a `[project]` table. #[derive(Debug, Default, Clone, Hash, PartialEq, Eq)] pub enum ProjectDiscovery { - /// The `[project]` table is optional; when missing, the target is treated as virtual. + /// The `[project]` table is optional; when missing, the target is treated as a virtual + /// project with only dependency groups. #[default] Optional, - /// A `[project]` table must be defined, unless `[tool.uv.workspace]` is present indicating a - /// legacy non-project workspace root. - /// - /// If neither is defined, discovery will fail. - Legacy, /// A `[project]` table must be defined. /// /// If not defined, discovery will fail. @@ -114,20 +110,12 @@ pub enum ProjectDiscovery { impl ProjectDiscovery { /// Whether a `[project]` table is required. pub fn allows_implicit_workspace(&self) -> bool { - match self { - Self::Optional => true, - Self::Legacy => false, - Self::Required => false, - } + matches!(self, Self::Optional) } - /// Whether a legacy workspace root is allowed. - pub fn allows_legacy_workspace(&self) -> bool { - match self { - Self::Optional => true, - Self::Legacy => true, - Self::Required => false, - } + /// Whether a non-project workspace root is allowed. + pub fn allows_non_project_workspace(&self) -> bool { + matches!(self, Self::Optional) } } @@ -184,7 +172,7 @@ impl Workspace { /// * If an explicit workspace root exists: Collect workspace from this root, we're done. /// * If there is no explicit workspace: We have a single project workspace, we're done. /// - /// Note that there are two kinds of workspace roots: projects, and (legacy) non-project roots. + /// Note that there are two kinds of workspace roots: projects, and non-project roots. /// The non-project roots lack a `[project]` table, and so are not themselves projects, as in: /// ```toml /// [tool.uv.workspace] @@ -270,7 +258,7 @@ impl Workspace { workspace_root.simplified_display() ); - // Unlike in `ProjectWorkspace` discovery, we might be in a legacy non-project root without + // Unlike in `ProjectWorkspace` discovery, we might be in a non-project root without // being in any specific project. let current_project = pyproject_toml .project @@ -365,7 +353,7 @@ impl Workspace { } } - /// Returns `true` if the workspace has a (legacy) non-project root. + /// Returns `true` if the workspace has a non-project root. pub fn is_non_project(&self) -> bool { !self .packages @@ -1745,7 +1733,7 @@ impl VirtualProject { .as_ref() .and_then(|tool| tool.uv.as_ref()) .and_then(|uv| uv.workspace.as_ref()) - .filter(|_| options.project.allows_legacy_workspace()) + .filter(|_| options.project.allows_non_project_workspace()) { // Otherwise, if it contains a `tool.uv.workspace` table, it's a non-project workspace // root. diff --git a/crates/uv/src/commands/project/install_target.rs b/crates/uv/src/commands/project/install_target.rs index ad5b990a0..6619a2ce2 100644 --- a/crates/uv/src/commands/project/install_target.rs +++ b/crates/uv/src/commands/project/install_target.rs @@ -37,7 +37,7 @@ pub(crate) enum InstallTarget<'lock> { workspace: &'lock Workspace, lock: &'lock Lock, }, - /// An entire workspace with a (legacy) non-project root. + /// An entire workspace with a non-project root. NonProjectWorkspace { workspace: &'lock Workspace, lock: &'lock Lock, diff --git a/crates/uv/tests/it/edit.rs b/crates/uv/tests/it/edit.rs index 8e9e62fb3..d5527ce5f 100644 --- a/crates/uv/tests/it/edit.rs +++ b/crates/uv/tests/it/edit.rs @@ -4928,7 +4928,7 @@ fn add_lower_bound_local() -> Result<()> { Ok(()) } -/// Add dependencies to a (legacy) non-project workspace root. +/// Add dependencies to a non-project workspace root. #[test] fn add_non_project() -> Result<()> { let context = uv_test::test_context!("3.12"); diff --git a/crates/uv/tests/it/lock.rs b/crates/uv/tests/it/lock.rs index f353ffe16..59f683b9f 100644 --- a/crates/uv/tests/it/lock.rs +++ b/crates/uv/tests/it/lock.rs @@ -17191,10 +17191,10 @@ fn lock_constrained_environment() -> Result<()> { Ok(()) } -/// Lock with a user-provided constraint on the space of supported environments, using a legacy -/// virtual workspace root. +/// Lock with a user-provided constraint on the space of supported environments, using a +/// non-project workspace root. #[test] -fn lock_constrained_environment_legacy() -> Result<()> { +fn lock_constrained_environment_non_project() -> Result<()> { let context = uv_test::test_context!("3.12"); let pyproject_toml = context.temp_dir.child("pyproject.toml"); @@ -17389,7 +17389,7 @@ fn lock_overlapping_environment() -> Result<()> { Ok(()) } -/// Lock a (legacy) non-project workspace root with forked dev dependencies. +/// Lock a non-project workspace root with forked dev dependencies. #[test] fn lock_non_project_fork() -> Result<()> { let context = uv_test::test_context!("3.10"); @@ -17585,7 +17585,7 @@ fn lock_non_project_fork() -> Result<()> { Ok(()) } -/// Lock a (legacy) non-project workspace root with a conditional dependency. +/// Lock a non-project workspace root with a conditional dependency. #[test] fn lock_non_project_conditional() -> Result<()> { let context = uv_test::test_context!("3.12"); @@ -17690,7 +17690,7 @@ fn lock_non_project_conditional() -> Result<()> { Ok(()) } -/// Lock a (legacy) non-project workspace root with `dependency-groups`. +/// Lock a non-project workspace root with `dependency-groups`. #[test] fn lock_non_project_group() -> Result<()> { let context = uv_test::test_context!("3.10"); @@ -17832,7 +17832,7 @@ fn lock_non_project_group() -> Result<()> { Ok(()) } -/// Lock a (legacy) non-project workspace root with `tool.uv.sources`. +/// Lock a non-project workspace root with `tool.uv.sources`. #[test] fn lock_non_project_sources() -> Result<()> { let context = uv_test::test_context!("3.12"); diff --git a/crates/uv/tests/it/sync.rs b/crates/uv/tests/it/sync.rs index 93d6b3924..f60f7f7b4 100644 --- a/crates/uv/tests/it/sync.rs +++ b/crates/uv/tests/it/sync.rs @@ -1104,9 +1104,9 @@ fn check() -> Result<()> { Ok(()) } -/// Sync development dependencies in a (legacy) non-project workspace root. +/// Sync development dependencies in a non-project workspace root. #[test] -fn sync_legacy_non_project_dev_dependencies() -> Result<()> { +fn sync_non_project_dev_dependencies() -> Result<()> { let context = uv_test::test_context!("3.12"); let pyproject_toml = context.temp_dir.child("pyproject.toml"); @@ -1185,9 +1185,9 @@ fn sync_legacy_non_project_dev_dependencies() -> Result<()> { Ok(()) } -/// Sync development dependencies in a (legacy) non-project workspace root with `--frozen`. +/// Sync development dependencies in a non-project workspace root with `--frozen`. #[test] -fn sync_legacy_non_project_frozen() -> Result<()> { +fn sync_non_project_frozen() -> Result<()> { let context = uv_test::test_context!("3.12"); let pyproject_toml = context.temp_dir.child("pyproject.toml"); @@ -1253,9 +1253,9 @@ fn sync_legacy_non_project_frozen() -> Result<()> { Ok(()) } -/// Sync development dependencies in a (legacy) non-project workspace root. +/// Sync dependency groups in a non-project workspace root. #[test] -fn sync_legacy_non_project_group() -> Result<()> { +fn sync_non_project_group() -> Result<()> { let context = uv_test::test_context!("3.12"); let pyproject_toml = context.temp_dir.child("pyproject.toml"); @@ -1371,11 +1371,11 @@ fn sync_legacy_non_project_group() -> Result<()> { Ok(()) } -/// Sync development dependencies in a (legacy) non-project workspace root with `--frozen`. +/// Sync development dependencies in a non-project workspace root with `--frozen`. /// /// Modify the `pyproject.toml` after locking. #[test] -fn sync_legacy_non_project_frozen_modification() -> Result<()> { +fn sync_non_project_frozen_modification() -> Result<()> { let context = uv_test::test_context!("3.12"); let pyproject_toml = context.temp_dir.child("pyproject.toml"); @@ -4661,9 +4661,9 @@ fn sync_group_member() -> Result<()> { Ok(()) } -/// Sync with `--only-group`, where the group includes a legacy non-`[project]` workspace member. +/// Sync with `--only-group`, where the group includes a non-`[project]` workspace member. #[test] -fn sync_group_legacy_non_project_member() -> Result<()> { +fn sync_group_non_project_member() -> Result<()> { let context = uv_test::test_context!("3.12"); // Create a workspace. @@ -7203,7 +7203,7 @@ fn sync_empty_virtual_environment() -> Result<()> { /// Test for warnings when `VIRTUAL_ENV` is set but will not be respected. #[test] -fn sync_legacy_non_project_warning() -> Result<()> { +fn sync_virtual_env_warning() -> Result<()> { let context = uv_test::test_context!("3.12"); let pyproject_toml = context.temp_dir.child("pyproject.toml");