From 49a75fa7975f4a46e08684255ddcad9a992bf40c Mon Sep 17 00:00:00 2001 From: Zanie Blue Date: Thu, 24 Jul 2025 18:06:35 -0500 Subject: [PATCH] Add preview warning --- crates/uv/src/commands/project/lock.rs | 17 ++++++++++++++++- crates/uv/tests/it/lock.rs | 5 +++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/crates/uv/src/commands/project/lock.rs b/crates/uv/src/commands/project/lock.rs index 706c86593..bbc2a41ab 100644 --- a/crates/uv/src/commands/project/lock.rs +++ b/crates/uv/src/commands/project/lock.rs @@ -24,7 +24,7 @@ use uv_distribution_types::{ use uv_git::ResolvedRepositoryReference; use uv_normalize::{GroupName, PackageName}; use uv_pep440::Version; -use uv_pypi_types::{Conflicts, SupportedEnvironments}; +use uv_pypi_types::{ConflictKind, Conflicts, SupportedEnvironments}; use uv_python::{Interpreter, PythonDownloads, PythonEnvironment, PythonPreference, PythonRequest}; use uv_requirements::ExtrasResolver; use uv_requirements::upgrade::{LockedRequirements, read_lock_requirements}; @@ -476,6 +476,21 @@ async fn do_lock( } } + // Check if any conflicts contain project-level conflicts + if preview.is_disabled() { + for set in conflicts.iter() { + if set + .iter() + .any(|item| matches!(item.kind(), ConflictKind::Project)) + { + warn_user_once!( + "Declaring conflicts for packages (`package = ...`) is experimental and may change without warning. Pass `--preview` to disable this warning." + ); + break; + } + } + } + // Collect the list of supported environments. let environments = { let environments = target.environments(); diff --git a/crates/uv/tests/it/lock.rs b/crates/uv/tests/it/lock.rs index df7c13560..411e23e48 100644 --- a/crates/uv/tests/it/lock.rs +++ b/crates/uv/tests/it/lock.rs @@ -2947,6 +2947,7 @@ fn lock_conflicting_workspace_members() -> Result<()> { ----- stdout ----- ----- stderr ----- + warning: Declaring conflicts for packages (`package = ...`) is experimental and may change without warning. Pass `--preview` to disable this warning. Resolved 4 packages in [TIME] "); @@ -3123,6 +3124,7 @@ fn lock_conflicting_workspace_members_depends_direct() -> Result<()> { ----- stdout ----- ----- stderr ----- + warning: Declaring conflicts for packages (`package = ...`) is experimental and may change without warning. Pass `--preview` to disable this warning. × No solution found when resolving dependencies: ╰─▶ Because subexample depends on sortedcontainers==2.4.0 and example depends on sortedcontainers==2.3.0, we can conclude that example and subexample are incompatible. And because example depends on subexample and your workspace requires example, we can conclude that your workspace's requirements are unsatisfiable. @@ -3202,6 +3204,7 @@ fn lock_conflicting_workspace_members_depends_direct_extra() -> Result<()> { ----- stdout ----- ----- stderr ----- + warning: Declaring conflicts for packages (`package = ...`) is experimental and may change without warning. Pass `--preview` to disable this warning. Resolved 4 packages in [TIME] "); @@ -3418,6 +3421,7 @@ fn lock_conflicting_workspace_members_depends_transitive() -> Result<()> { ----- stdout ----- ----- stderr ----- + warning: Declaring conflicts for packages (`package = ...`) is experimental and may change without warning. Pass `--preview` to disable this warning. × No solution found when resolving dependencies: ╰─▶ Because subexample depends on sortedcontainers==2.4.0 and indirection depends on subexample, we can conclude that indirection depends on sortedcontainers==2.4.0. And because example depends on sortedcontainers==2.3.0, we can conclude that example and indirection are incompatible. @@ -3518,6 +3522,7 @@ fn lock_conflicting_workspace_members_depends_transitive_extra() -> Result<()> { ----- stdout ----- ----- stderr ----- + warning: Declaring conflicts for packages (`package = ...`) is experimental and may change without warning. Pass `--preview` to disable this warning. Resolved 5 packages in [TIME] ");