Clean up legacy workspace root concept (#17864)

Prompted by https://github.com/astral-sh/uv/issues/17855 — I think this
branch is just dead code?
This commit is contained in:
Zanie Blue
2026-02-17 09:24:15 -06:00
committed by GitHub
parent ae6e62ad6f
commit 7ef8d66c94
7 changed files with 32 additions and 44 deletions
+1 -1
View File
@@ -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()
+1 -1
View File
@@ -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()
+10 -22
View File
@@ -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.
@@ -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,
+1 -1
View File
@@ -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");
+7 -7
View File
@@ -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");
+11 -11
View File
@@ -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");