From bb78e00a8716b9ffb644960d78533409ce3ca619 Mon Sep 17 00:00:00 2001 From: Andrew Gallant Date: Wed, 13 Nov 2024 10:15:47 -0500 Subject: [PATCH] *: update "conflicting groups" terminology everywhere else --- crates/uv-bench/benches/uv.rs | 4 +- crates/uv-pypi-types/src/conflicts.rs | 18 ++--- crates/uv-resolver/src/lock/mod.rs | 26 ++++---- ...r__lock__tests__hash_optional_missing.snap | 2 +- ...r__lock__tests__hash_optional_present.snap | 2 +- ...r__lock__tests__hash_required_present.snap | 2 +- ...missing_dependency_source_unambiguous.snap | 2 +- ...dependency_source_version_unambiguous.snap | 2 +- ...issing_dependency_version_unambiguous.snap | 2 +- ...lock__tests__source_direct_has_subdir.snap | 2 +- ..._lock__tests__source_direct_no_subdir.snap | 2 +- ...solver__lock__tests__source_directory.snap | 2 +- ...esolver__lock__tests__source_editable.snap | 2 +- crates/uv-resolver/src/pubgrub/package.rs | 2 +- crates/uv-resolver/src/resolution/graph.rs | 4 +- .../uv-resolver/src/resolver/environment.rs | 3 +- crates/uv-resolver/src/resolver/mod.rs | 66 +++++++++---------- crates/uv-settings/src/settings.rs | 8 +-- crates/uv-workspace/src/pyproject.rs | 10 +-- crates/uv-workspace/src/workspace.rs | 4 +- crates/uv-workspace/src/workspace/tests.rs | 12 ++-- crates/uv/src/commands/pip/compile.rs | 4 +- crates/uv/src/commands/pip/operations.rs | 4 +- crates/uv/src/commands/project/lock.rs | 10 +-- crates/uv/src/commands/project/sync.rs | 15 ++--- crates/uv/tests/it/lock.rs | 28 ++++---- crates/uv/tests/it/pip_install.rs | 6 +- crates/uv/tests/it/show_settings.rs | 32 ++++----- 28 files changed, 134 insertions(+), 142 deletions(-) diff --git a/crates/uv-bench/benches/uv.rs b/crates/uv-bench/benches/uv.rs index ba52d2c90..c900837e5 100644 --- a/crates/uv-bench/benches/uv.rs +++ b/crates/uv-bench/benches/uv.rs @@ -163,7 +163,7 @@ mod resolver { let options = OptionsBuilder::new().exclude_newer(exclude_newer).build(); let sources = SourceStrategy::default(); let dependency_metadata = DependencyMetadata::default(); - let conflicting_groups = Conflicts::empty(); + let conflicts = Conflicts::empty(); let python_requirement = if universal { PythonRequirement::from_requires_python( @@ -209,7 +209,7 @@ mod resolver { options, &python_requirement, markers, - conflicting_groups, + conflicts, Some(&TAGS), &flat_index, &index, diff --git a/crates/uv-pypi-types/src/conflicts.rs b/crates/uv-pypi-types/src/conflicts.rs index f735a8cdf..2fdd9e41c 100644 --- a/crates/uv-pypi-types/src/conflicts.rs +++ b/crates/uv-pypi-types/src/conflicts.rs @@ -1,6 +1,6 @@ use uv_normalize::{ExtraName, PackageName}; -/// A list of conflicting groups pre-defined by an end user. +/// A list of conflicting sets of extras/groups pre-defined by an end user. /// /// This is useful to force the resolver to fork according to extras that have /// unavoidable conflicts with each other. (The alternative is that resolution @@ -11,7 +11,7 @@ use uv_normalize::{ExtraName, PackageName}; pub struct Conflicts(Vec); impl Conflicts { - /// Returns no conflicting groups. + /// Returns no conflicts. /// /// This results in no effect on resolution. pub fn empty() -> Conflicts { @@ -31,7 +31,7 @@ impl Conflicts { /// Returns true if these conflicts contain any set that contains the given /// package and extra name pair. pub fn contains(&self, package: &PackageName, extra: &ExtraName) -> bool { - self.iter().any(|groups| groups.contains(package, extra)) + self.iter().any(|set| set.contains(package, extra)) } /// Returns true if there are no conflicts. @@ -78,7 +78,7 @@ impl ConflictSet { /// extra name pair. pub fn contains(&self, package: &PackageName, extra: &ExtraName) -> bool { self.iter() - .any(|group| group.package() == package && group.extra() == extra) + .any(|set| set.package() == package && set.extra() == extra) } } @@ -87,8 +87,8 @@ impl<'de> serde::Deserialize<'de> for ConflictSet { where D: serde::Deserializer<'de>, { - let groups = Vec::::deserialize(deserializer)?; - Self::try_from(groups).map_err(serde::de::Error::custom) + let set = Vec::::deserialize(deserializer)?; + Self::try_from(set).map_err(serde::de::Error::custom) } } @@ -193,10 +193,10 @@ impl<'a> From<(&'a PackageName, &'a ExtraName)> for ConflictItemRef<'a> { #[derive(Debug, thiserror::Error)] pub enum ConflictError { /// An error for when there are zero conflicting items. - #[error("Each set of conflicting groups must have at least two entries, but found none")] + #[error("Each set of conflicts must have at least two entries, but found none")] ZeroItems, /// An error for when there is one conflicting items. - #[error("Each set of conflicting groups must have at least two entries, but found only one")] + #[error("Each set of conflicts must have at least two entries, but found only one")] OneItem, } @@ -222,7 +222,7 @@ impl SchemaConflicts { /// If a conflict has an explicit package name (written by the end user), /// then that takes precedence over the given package name, which is only /// used when there is no explicit package name written. - pub fn to_conflicting_with_package_name(&self, package: &PackageName) -> Conflicts { + pub fn to_conflicts_with_package_name(&self, package: &PackageName) -> Conflicts { let mut conflicting = Conflicts::empty(); for tool_uv_set in &self.0 { let mut set = vec![]; diff --git a/crates/uv-resolver/src/lock/mod.rs b/crates/uv-resolver/src/lock/mod.rs index db6b9002d..9bd33d96a 100644 --- a/crates/uv-resolver/src/lock/mod.rs +++ b/crates/uv-resolver/src/lock/mod.rs @@ -82,7 +82,7 @@ pub struct Lock { /// forks in the lockfile so we can recreate them in subsequent resolutions. fork_markers: Vec, /// The conflicting groups/extras specified by the user. - conflicting_groups: Conflicts, + conflicts: Conflicts, /// The list of supported environments specified by the user. supported_environments: Vec, /// The range of supported Python versions. @@ -315,7 +315,7 @@ impl Lock { requires_python: RequiresPython, options: ResolverOptions, manifest: ResolverManifest, - conflicting_groups: Conflicts, + conflicts: Conflicts, supported_environments: Vec, fork_markers: Vec, ) -> Result { @@ -465,7 +465,7 @@ impl Lock { let lock = Self { version, fork_markers, - conflicting_groups, + conflicts, supported_environments, requires_python, options, @@ -485,8 +485,8 @@ impl Lock { /// Record the conflicting groups that were used to generate this lock. #[must_use] - pub fn with_conflicting_groups(mut self, conflicting_groups: Conflicts) -> Self { - self.conflicting_groups = conflicting_groups; + pub fn with_conflicts(mut self, conflicts: Conflicts) -> Self { + self.conflicts = conflicts; self } @@ -550,8 +550,8 @@ impl Lock { } /// Returns the conflicting groups that were used to generate this lock. - pub fn conflicting_groups(&self) -> &Conflicts { - &self.conflicting_groups + pub fn conflicts(&self) -> &Conflicts { + &self.conflicts } /// Returns the supported environments that were used to generate this lock. @@ -632,9 +632,9 @@ impl Lock { doc.insert("supported-markers", value(supported_environments)); } - if !self.conflicting_groups.is_empty() { + if !self.conflicts.is_empty() { let mut list = Array::new(); - for groups in self.conflicting_groups.iter() { + for groups in self.conflicts.iter() { list.push(each_element_on_its_line_array(groups.iter().map(|group| { let mut table = InlineTable::new(); table.insert("package", Value::from(group.package().to_string())); @@ -642,7 +642,7 @@ impl Lock { table }))); } - doc.insert("conflicting-groups", value(list)); + doc.insert("conflicts", value(list)); } // Write the settings that were used to generate the resolution. @@ -1383,8 +1383,8 @@ struct LockWire { fork_markers: Vec, #[serde(rename = "supported-markers", default)] supported_environments: Vec, - #[serde(rename = "conflicting-groups", default)] - conflicting_groups: Option, + #[serde(rename = "conflicts", default)] + conflicts: Option, /// We discard the lockfile if these options match. #[serde(default)] options: ResolverOptions, @@ -1436,7 +1436,7 @@ impl TryFrom for Lock { wire.requires_python, wire.options, wire.manifest, - wire.conflicting_groups.unwrap_or_else(Conflicts::empty), + wire.conflicts.unwrap_or_else(Conflicts::empty), supported_environments, fork_markers, )?; diff --git a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__hash_optional_missing.snap b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__hash_optional_missing.snap index 13f9c1b0a..40ded19b4 100644 --- a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__hash_optional_missing.snap +++ b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__hash_optional_missing.snap @@ -6,7 +6,7 @@ Ok( Lock { version: 1, fork_markers: [], - conflicting_groups: ConflictingGroupList( + conflicts: Conflicts( [], ), supported_environments: [], diff --git a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__hash_optional_present.snap b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__hash_optional_present.snap index 5f276e881..fede0baf5 100644 --- a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__hash_optional_present.snap +++ b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__hash_optional_present.snap @@ -6,7 +6,7 @@ Ok( Lock { version: 1, fork_markers: [], - conflicting_groups: ConflictingGroupList( + conflicts: Conflicts( [], ), supported_environments: [], diff --git a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__hash_required_present.snap b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__hash_required_present.snap index 194fc5ab7..172e1b902 100644 --- a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__hash_required_present.snap +++ b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__hash_required_present.snap @@ -6,7 +6,7 @@ Ok( Lock { version: 1, fork_markers: [], - conflicting_groups: ConflictingGroupList( + conflicts: Conflicts( [], ), supported_environments: [], diff --git a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__missing_dependency_source_unambiguous.snap b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__missing_dependency_source_unambiguous.snap index f8cae3434..066df5328 100644 --- a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__missing_dependency_source_unambiguous.snap +++ b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__missing_dependency_source_unambiguous.snap @@ -6,7 +6,7 @@ Ok( Lock { version: 1, fork_markers: [], - conflicting_groups: ConflictingGroupList( + conflicts: Conflicts( [], ), supported_environments: [], diff --git a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__missing_dependency_source_version_unambiguous.snap b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__missing_dependency_source_version_unambiguous.snap index f8cae3434..066df5328 100644 --- a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__missing_dependency_source_version_unambiguous.snap +++ b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__missing_dependency_source_version_unambiguous.snap @@ -6,7 +6,7 @@ Ok( Lock { version: 1, fork_markers: [], - conflicting_groups: ConflictingGroupList( + conflicts: Conflicts( [], ), supported_environments: [], diff --git a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__missing_dependency_version_unambiguous.snap b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__missing_dependency_version_unambiguous.snap index f8cae3434..066df5328 100644 --- a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__missing_dependency_version_unambiguous.snap +++ b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__missing_dependency_version_unambiguous.snap @@ -6,7 +6,7 @@ Ok( Lock { version: 1, fork_markers: [], - conflicting_groups: ConflictingGroupList( + conflicts: Conflicts( [], ), supported_environments: [], diff --git a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_direct_has_subdir.snap b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_direct_has_subdir.snap index 7c0b43c63..388c6214a 100644 --- a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_direct_has_subdir.snap +++ b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_direct_has_subdir.snap @@ -6,7 +6,7 @@ Ok( Lock { version: 1, fork_markers: [], - conflicting_groups: ConflictingGroupList( + conflicts: Conflicts( [], ), supported_environments: [], diff --git a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_direct_no_subdir.snap b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_direct_no_subdir.snap index 894d52e40..55115287a 100644 --- a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_direct_no_subdir.snap +++ b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_direct_no_subdir.snap @@ -6,7 +6,7 @@ Ok( Lock { version: 1, fork_markers: [], - conflicting_groups: ConflictingGroupList( + conflicts: Conflicts( [], ), supported_environments: [], diff --git a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_directory.snap b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_directory.snap index 2a7316ed1..336e6f52f 100644 --- a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_directory.snap +++ b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_directory.snap @@ -6,7 +6,7 @@ Ok( Lock { version: 1, fork_markers: [], - conflicting_groups: ConflictingGroupList( + conflicts: Conflicts( [], ), supported_environments: [], diff --git a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_editable.snap b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_editable.snap index bb65d03ad..465eefcc1 100644 --- a/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_editable.snap +++ b/crates/uv-resolver/src/lock/snapshots/uv_resolver__lock__tests__source_editable.snap @@ -6,7 +6,7 @@ Ok( Lock { version: 1, fork_markers: [], - conflicting_groups: ConflictingGroupList( + conflicts: Conflicts( [], ), supported_environments: [], diff --git a/crates/uv-resolver/src/pubgrub/package.rs b/crates/uv-resolver/src/pubgrub/package.rs index ec8b4e026..17f72da77 100644 --- a/crates/uv-resolver/src/pubgrub/package.rs +++ b/crates/uv-resolver/src/pubgrub/package.rs @@ -190,7 +190,7 @@ impl PubGrubPackage { /// /// If this package can't possibly be classified as a conflicting group, /// then this returns `None`. - pub(crate) fn conflicting_group(&self) -> Option> { + pub(crate) fn conflicting_item(&self) -> Option> { let package = self.name_no_root()?; let extra = self.extra()?; Some(ConflictItemRef::from((package, extra))) diff --git a/crates/uv-resolver/src/resolution/graph.rs b/crates/uv-resolver/src/resolution/graph.rs index a37a7756e..6696bc998 100644 --- a/crates/uv-resolver/src/resolution/graph.rs +++ b/crates/uv-resolver/src/resolution/graph.rs @@ -103,7 +103,7 @@ impl ResolutionGraph { index: &InMemoryIndex, git: &GitResolver, python: &PythonRequirement, - conflicting_groups: &Conflicts, + conflicts: &Conflicts, resolution_strategy: &ResolutionStrategy, options: Options, ) -> Result { @@ -251,7 +251,7 @@ impl ResolutionGraph { // the same time. At which point, uv will report an error, // thereby sidestepping the possibility of installing different // versions of the same package into the same virtualenv. ---AG - if conflicting_groups.is_empty() { + if conflicts.is_empty() { #[allow(unused_mut, reason = "Used in debug_assertions below")] let mut conflicting = graph.find_conflicting_distributions(); if !conflicting.is_empty() { diff --git a/crates/uv-resolver/src/resolver/environment.rs b/crates/uv-resolver/src/resolver/environment.rs index 60f693b30..0c6fb0f71 100644 --- a/crates/uv-resolver/src/resolver/environment.rs +++ b/crates/uv-resolver/src/resolver/environment.rs @@ -3,7 +3,7 @@ use std::sync::Arc; use rustc_hash::{FxHashMap, FxHashSet}; use uv_normalize::{ExtraName, PackageName}; use uv_pep508::{MarkerEnvironment, MarkerTree}; -use uv_pypi_types::{ConflictItem, ConflictItemRef, Conflicts, ResolverMarkerEnvironment}; +use uv_pypi_types::{ConflictItem, ConflictItemRef, ResolverMarkerEnvironment}; use crate::pubgrub::{PubGrubDependency, PubGrubPackage}; use crate::requires_python::RequiresPythonRange; @@ -425,7 +425,6 @@ impl<'d> Forker<'d> { pub(crate) fn fork( &self, env: &ResolverEnvironment, - _conflicting_groups: &Conflicts, ) -> Option<(Forker<'d>, Vec)> { if !env.included_by_marker(&self.marker) { return None; diff --git a/crates/uv-resolver/src/resolver/mod.rs b/crates/uv-resolver/src/resolver/mod.rs index 3db5a37d8..392983712 100644 --- a/crates/uv-resolver/src/resolver/mod.rs +++ b/crates/uv-resolver/src/resolver/mod.rs @@ -109,7 +109,7 @@ struct ResolverState { hasher: HashStrategy, env: ResolverEnvironment, python_requirement: PythonRequirement, - conflicting_groups: Conflicts, + conflicts: Conflicts, workspace_members: BTreeSet, selector: CandidateSelector, index: InMemoryIndex, @@ -150,7 +150,7 @@ impl<'a, Context: BuildContext, InstalledPackages: InstalledPackagesProvider> options: Options, python_requirement: &'a PythonRequirement, env: ResolverEnvironment, - conflicting_groups: Conflicts, + conflicts: Conflicts, tags: Option<&'a Tags>, flat_index: &'a FlatIndex, index: &'a InMemoryIndex, @@ -177,7 +177,7 @@ impl<'a, Context: BuildContext, InstalledPackages: InstalledPackagesProvider> hasher, env, python_requirement, - conflicting_groups, + conflicts, index, build_context.git(), build_context.capabilities(), @@ -198,7 +198,7 @@ impl hasher: &HashStrategy, env: ResolverEnvironment, python_requirement: &PythonRequirement, - conflicting_groups: Conflicts, + conflicts: Conflicts, index: &InMemoryIndex, git: &GitResolver, capabilities: &IndexCapabilities, @@ -226,7 +226,7 @@ impl locations: locations.clone(), env, python_requirement: python_requirement.clone(), - conflicting_groups, + conflicts, installed_packages, unavailable_packages: DashMap::default(), incomplete_packages: DashMap::default(), @@ -607,7 +607,7 @@ impl ResolverState ResolverState ForkedDependencies::Unavailable(err), }) } else { - Ok(result?.fork(env, python_requirement, &self.conflicting_groups)) + Ok(result?.fork(env, python_requirement, &self.conflicts)) } } @@ -1387,15 +1387,12 @@ impl ResolverState ForkedDependencies { let deps = match self { Dependencies::Available(deps) => deps, @@ -2713,7 +2710,7 @@ impl Dependencies { let Forks { mut forks, diverging_packages, - } = Forks::new(name_to_deps, env, python_requirement, conflicting_groups); + } = Forks::new(name_to_deps, env, python_requirement, conflicts); if forks.is_empty() { ForkedDependencies::Unforked(vec![]) } else if forks.len() == 1 { @@ -2775,7 +2772,7 @@ impl Forks { name_to_deps: BTreeMap>, env: &ResolverEnvironment, python_requirement: &PythonRequirement, - conflicting_groups: &Conflicts, + conflicts: &Conflicts, ) -> Forks { let python_marker = python_requirement.to_marker_tree(); @@ -2839,8 +2836,7 @@ impl Forks { let mut new = vec![]; for fork in std::mem::take(&mut forks) { - let Some((remaining_forker, envs)) = forker.fork(&fork.env, conflicting_groups) - else { + let Some((remaining_forker, envs)) = forker.fork(&fork.env) else { new.push(fork); continue; }; @@ -2880,12 +2876,12 @@ impl Forks { // For example, if we have conflicting groups {x1, x2} and {x3, // x4}, we need to make sure the forks generated from one set // also account for the other set. - for groups in conflicting_groups.iter() { + for groups in conflicts.iter() { let mut new = vec![]; for fork in std::mem::take(&mut forks) { let mut has_conflicting_dependency = false; for group in groups.iter() { - if fork.contains_conflicting_group(group.as_ref()) { + if fork.contains_conflicting_item(group.as_ref()) { has_conflicting_dependency = true; break; } @@ -2954,7 +2950,7 @@ struct Fork { /// This exists to make some access patterns more efficient. Namely, /// it makes it easy to check whether there's a dependency with a /// particular conflicting group in this fork. - conflicting_groups: FxHashMap>, + conflicts: FxHashMap>, /// The resolver environment for this fork. /// /// Principally, this corresponds to the markers in this for. So in the @@ -2975,18 +2971,18 @@ impl Fork { fn new(env: ResolverEnvironment) -> Fork { Fork { dependencies: vec![], - conflicting_groups: FxHashMap::default(), + conflicts: FxHashMap::default(), env, } } /// Add a dependency to this fork. fn add_dependency(&mut self, dep: PubGrubDependency) { - if let Some(conflicting_group) = dep.package.conflicting_group() { - self.conflicting_groups - .entry(conflicting_group.package().clone()) + if let Some(conflicting_item) = dep.package.conflicting_item() { + self.conflicts + .entry(conflicting_item.package().clone()) .or_default() - .insert(conflicting_group.extra().clone()); + .insert(conflicting_item.extra().clone()); } self.dependencies.push(dep); } @@ -3004,9 +3000,9 @@ impl Fork { if self.env.included_by_marker(markers) { return true; } - if let Some(conflicting_group) = dep.package.conflicting_group() { - if let Some(set) = self.conflicting_groups.get_mut(conflicting_group.package()) { - set.remove(conflicting_group.extra()); + if let Some(conflicting_item) = dep.package.conflicting_item() { + if let Some(set) = self.conflicts.get_mut(conflicting_item.package()) { + set.remove(conflicting_item.extra()); } } false @@ -3015,8 +3011,8 @@ impl Fork { /// Returns true if any of the dependencies in this fork contain a /// dependency with the given package and extra values. - fn contains_conflicting_group(&self, group: ConflictItemRef<'_>) -> bool { - self.conflicting_groups + fn contains_conflicting_item(&self, group: ConflictItemRef<'_>) -> bool { + self.conflicts .get(group.package()) .map(|set| set.contains(group.extra())) .unwrap_or(false) @@ -3028,15 +3024,15 @@ impl Fork { fn exclude(mut self, groups: impl IntoIterator) -> Fork { self.env = self.env.exclude_by_group(groups); self.dependencies.retain(|dep| { - let Some(conflicting_group) = dep.package.conflicting_group() else { + let Some(conflicting_item) = dep.package.conflicting_item() else { return true; }; - if self.env.included_by_group(conflicting_group) { + if self.env.included_by_group(conflicting_item) { return true; } - if let Some(conflicting_group) = dep.package.conflicting_group() { - if let Some(set) = self.conflicting_groups.get_mut(conflicting_group.package()) { - set.remove(conflicting_group.extra()); + if let Some(conflicting_item) = dep.package.conflicting_item() { + if let Some(set) = self.conflicts.get_mut(conflicting_item.package()) { + set.remove(conflicting_item.extra()); } } false diff --git a/crates/uv-settings/src/settings.rs b/crates/uv-settings/src/settings.rs index 375a89b7e..9b2d261da 100644 --- a/crates/uv-settings/src/settings.rs +++ b/crates/uv-settings/src/settings.rs @@ -105,7 +105,7 @@ pub struct Options { // `crates/uv-workspace/src/pyproject.rs`. The documentation lives on that struct. // They're only respected in `pyproject.toml` files, and should be rejected in `uv.toml` files. #[cfg_attr(feature = "schemars", schemars(skip))] - pub conflicting_groups: Option, + pub conflicts: Option, #[cfg_attr(feature = "schemars", schemars(skip))] pub workspace: Option, @@ -1626,7 +1626,7 @@ pub struct OptionsWire { // NOTE(charlie): These fields should be kept in-sync with `ToolUv` in // `crates/uv-workspace/src/pyproject.rs`. The documentation lives on that struct. // They're only respected in `pyproject.toml` files, and should be rejected in `uv.toml` files. - conflicting_groups: Option, + conflicts: Option, workspace: Option, sources: Option, managed: Option, @@ -1681,7 +1681,7 @@ impl From for Options { override_dependencies, constraint_dependencies, environments, - conflicting_groups, + conflicts, publish_url, trusted_publishing, workspace, @@ -1743,7 +1743,7 @@ impl From for Options { python_install_mirror, pypy_install_mirror, ), - conflicting_groups, + conflicts, publish: PublishOptions { publish_url, trusted_publishing, diff --git a/crates/uv-workspace/src/pyproject.rs b/crates/uv-workspace/src/pyproject.rs index 7b31ac251..99c2eb1b8 100644 --- a/crates/uv-workspace/src/pyproject.rs +++ b/crates/uv-workspace/src/pyproject.rs @@ -102,7 +102,7 @@ impl PyProjectToml { } /// Returns the set of conflicts for the project. - pub fn conflicting_groups(&self) -> Conflicts { + pub fn conflicts(&self) -> Conflicts { let empty = Conflicts::empty(); let Some(project) = self.project.as_ref() else { return empty; @@ -113,10 +113,10 @@ impl PyProjectToml { let Some(tooluv) = tool.uv.as_ref() else { return empty; }; - let Some(conflicting) = tooluv.conflicting_groups.as_ref() else { + let Some(conflicting) = tooluv.conflicts.as_ref() else { return empty; }; - conflicting.to_conflicting_with_package_name(&project.name) + conflicting.to_conflicts_with_package_name(&project.name) } } @@ -494,7 +494,7 @@ pub struct ToolUv { # Require that `package[test1]` and `package[test2]` # requirements are resolved in different forks so that they # cannot conflict with one another. - conflicting-groups = [ + conflicts = [ [ { extra = "test1" }, { extra = "test2" }, @@ -503,7 +503,7 @@ pub struct ToolUv { "# )] */ - pub conflicting_groups: Option, + pub conflicts: Option, } #[derive(Default, Debug, Clone, PartialEq, Eq)] diff --git a/crates/uv-workspace/src/workspace.rs b/crates/uv-workspace/src/workspace.rs index 62c251750..668c42042 100644 --- a/crates/uv-workspace/src/workspace.rs +++ b/crates/uv-workspace/src/workspace.rs @@ -393,10 +393,10 @@ impl Workspace { } /// Returns the set of conflicts for the workspace. - pub fn conflicting_groups(&self) -> Conflicts { + pub fn conflicts(&self) -> Conflicts { let mut conflicting = Conflicts::empty(); for member in self.packages.values() { - conflicting.append(&mut member.pyproject_toml.conflicting_groups()); + conflicting.append(&mut member.pyproject_toml.conflicts()); } conflicting } diff --git a/crates/uv-workspace/src/workspace/tests.rs b/crates/uv-workspace/src/workspace/tests.rs index 822b9757c..a2a0b66d0 100644 --- a/crates/uv-workspace/src/workspace/tests.rs +++ b/crates/uv-workspace/src/workspace/tests.rs @@ -242,7 +242,7 @@ async fn albatross_root_workspace() { "override-dependencies": null, "constraint-dependencies": null, "environments": null, - "conflicting-groups": null + "conflicts": null } }, "dependency-groups": null @@ -334,7 +334,7 @@ async fn albatross_virtual_workspace() { "override-dependencies": null, "constraint-dependencies": null, "environments": null, - "conflicting-groups": null + "conflicts": null } }, "dependency-groups": null @@ -540,7 +540,7 @@ async fn exclude_package() -> Result<()> { "override-dependencies": null, "constraint-dependencies": null, "environments": null, - "conflicting-groups": null + "conflicts": null } }, "dependency-groups": null @@ -644,7 +644,7 @@ async fn exclude_package() -> Result<()> { "override-dependencies": null, "constraint-dependencies": null, "environments": null, - "conflicting-groups": null + "conflicts": null } }, "dependency-groups": null @@ -761,7 +761,7 @@ async fn exclude_package() -> Result<()> { "override-dependencies": null, "constraint-dependencies": null, "environments": null, - "conflicting-groups": null + "conflicts": null } }, "dependency-groups": null @@ -852,7 +852,7 @@ async fn exclude_package() -> Result<()> { "override-dependencies": null, "constraint-dependencies": null, "environments": null, - "conflicting-groups": null + "conflicts": null } }, "dependency-groups": null diff --git a/crates/uv/src/commands/pip/compile.rs b/crates/uv/src/commands/pip/compile.rs index a96d92d5b..5503ea7ed 100644 --- a/crates/uv/src/commands/pip/compile.rs +++ b/crates/uv/src/commands/pip/compile.rs @@ -54,7 +54,7 @@ pub(crate) async fn pip_compile( constraints_from_workspace: Vec, overrides_from_workspace: Vec, environments: SupportedEnvironments, - conflicting_groups: Conflicts, + conflicts: Conflicts, extras: ExtrasSpecification, output_file: Option<&Path>, resolution_mode: ResolutionMode, @@ -256,7 +256,7 @@ pub(crate) async fn pip_compile( ( None, ResolverEnvironment::universal(environments.into_markers()), - conflicting_groups, + conflicts, ) } else { let (tags, marker_env) = diff --git a/crates/uv/src/commands/pip/operations.rs b/crates/uv/src/commands/pip/operations.rs index d33e36876..ea64f110c 100644 --- a/crates/uv/src/commands/pip/operations.rs +++ b/crates/uv/src/commands/pip/operations.rs @@ -104,7 +104,7 @@ pub(crate) async fn resolve( tags: Option<&Tags>, resolver_env: ResolverEnvironment, python_requirement: PythonRequirement, - conflicting_groups: Conflicts, + conflicts: Conflicts, client: &RegistryClient, flat_index: &FlatIndex, index: &InMemoryIndex, @@ -291,7 +291,7 @@ pub(crate) async fn resolve( options, &python_requirement, resolver_env, - conflicting_groups, + conflicts, tags, flat_index, index, diff --git a/crates/uv/src/commands/project/lock.rs b/crates/uv/src/commands/project/lock.rs index 8ed05f2d7..40ee4817a 100644 --- a/crates/uv/src/commands/project/lock.rs +++ b/crates/uv/src/commands/project/lock.rs @@ -631,7 +631,7 @@ async fn do_lock( None, resolver_env, python_requirement, - workspace.conflicting_groups(), + workspace.conflicts(), &client, &flat_index, &state.index, @@ -661,7 +661,7 @@ async fn do_lock( let previous = existing_lock.map(ValidatedLock::into_lock); let lock = Lock::from_resolution_graph(&resolution, workspace.install_path())? .with_manifest(manifest) - .with_conflicting_groups(workspace.conflicting_groups()) + .with_conflicts(workspace.conflicts()) .with_supported_environments( environments .cloned() @@ -806,11 +806,11 @@ impl ValidatedLock { } // If the conflicting group config has changed, we have to perform a clean resolution. - if &workspace.conflicting_groups() != lock.conflicting_groups() { + if &workspace.conflicts() != lock.conflicts() { debug!( "Ignoring existing lockfile due to change in conflicting groups: `{:?}` vs. `{:?}`", - workspace.conflicting_groups(), - lock.conflicting_groups(), + workspace.conflicts(), + lock.conflicts(), ); return Ok(Self::Versions(lock)); } diff --git a/crates/uv/src/commands/project/sync.rs b/crates/uv/src/commands/project/sync.rs index 90b4f2717..4eaa15e34 100644 --- a/crates/uv/src/commands/project/sync.rs +++ b/crates/uv/src/commands/project/sync.rs @@ -283,18 +283,15 @@ pub(super) async fn do_sync( // Validate that we aren't trying to install extras that are // declared as conflicting. - let conflicting_groups = target.lock().conflicting_groups(); - for groups in conflicting_groups.iter() { - let conflicting = groups + let conflicts = target.lock().conflicts(); + for set in conflicts.iter() { + let conflicting = set .iter() - .filter(|group| extras.contains(group.extra())) - .map(|group| group.extra().clone()) + .filter(|item| extras.contains(item.extra())) + .map(|item| item.extra().clone()) .collect::>(); if conflicting.len() >= 2 { - return Err(ProjectError::ExtraIncompatibility( - groups.clone(), - conflicting, - )); + return Err(ProjectError::ExtraIncompatibility(set.clone(), conflicting)); } } diff --git a/crates/uv/tests/it/lock.rs b/crates/uv/tests/it/lock.rs index 84ede5ce5..872c35884 100644 --- a/crates/uv/tests/it/lock.rs +++ b/crates/uv/tests/it/lock.rs @@ -2220,7 +2220,7 @@ fn lock_conflicting_extra_basic() -> Result<()> { requires-python = ">=3.12" [tool.uv] - conflicting-groups = [ + conflicts = [ [ { extra = "project1" }, { extra = "project2" }, @@ -2257,7 +2257,7 @@ fn lock_conflicting_extra_basic() -> Result<()> { requires-python = ">=3.12" resolution-markers = [ ] - conflicting-groups = [[ + conflicts = [[ { package = "project", extra = "project1" }, { package = "project", extra = "project2" }, ]] @@ -2417,7 +2417,7 @@ fn lock_conflicting_extra_basic_three_extras() -> Result<()> { requires-python = ">=3.12" [tool.uv] - conflicting-groups = [ + conflicts = [ [ { extra = "project1" }, { extra = "project2" }, @@ -2456,7 +2456,7 @@ fn lock_conflicting_extra_basic_three_extras() -> Result<()> { requires-python = ">=3.12" resolution-markers = [ ] - conflicting-groups = [[ + conflicts = [[ { package = "project", extra = "project1" }, { package = "project", extra = "project2" }, { package = "project", extra = "project3" }, @@ -2542,7 +2542,7 @@ fn lock_conflicting_extra_multiple_not_conflicting1() -> Result<()> { requires-python = ">=3.12" [tool.uv] - conflicting-groups = [ + conflicts = [ [ { extra = "project1" }, { extra = "project2" }, @@ -2712,7 +2712,7 @@ fn lock_conflicting_extra_multiple_not_conflicting2() -> Result<()> { requires-python = ">=3.12" [tool.uv] - conflicting-groups = [ + conflicts = [ [ { extra = "project1" }, { extra = "project2" }, @@ -2758,7 +2758,7 @@ fn lock_conflicting_extra_multiple_not_conflicting2() -> Result<()> { requires-python = ">=3.12" [tool.uv] - conflicting-groups = [ + conflicts = [ [ { extra = "project1" }, { extra = "project2" }, @@ -2808,7 +2808,7 @@ fn lock_conflicting_extra_multiple_not_conflicting2() -> Result<()> { requires-python = ">=3.12" [tool.uv] - conflicting-groups = [ + conflicts = [ [ { extra = "project1" }, { extra = "project2" }, @@ -2889,7 +2889,7 @@ fn lock_conflicting_extra_multiple_independent() -> Result<()> { requires-python = ">=3.12" [tool.uv] - conflicting-groups = [ + conflicts = [ [ { extra = "project3" }, { extra = "project4" }, @@ -2928,7 +2928,7 @@ fn lock_conflicting_extra_multiple_independent() -> Result<()> { requires-python = ">=3.12" [tool.uv] - conflicting-groups = [ + conflicts = [ [ { extra = "project1" }, { extra = "project2" }, @@ -2971,7 +2971,7 @@ fn lock_conflicting_extra_multiple_independent() -> Result<()> { requires-python = ">=3.12" resolution-markers = [ ] - conflicting-groups = [[ + conflicts = [[ { package = "project", extra = "project1" }, { package = "project", extra = "project2" }, ], [ @@ -3098,7 +3098,7 @@ fn lock_conflicting_extra_config_change_ignore_lockfile() -> Result<()> { requires-python = ">=3.12" [tool.uv] - conflicting-groups = [ + conflicts = [ [ { extra = "project1" }, { extra = "project2" }, @@ -3133,7 +3133,7 @@ fn lock_conflicting_extra_config_change_ignore_lockfile() -> Result<()> { requires-python = ">=3.12" resolution-markers = [ ] - conflicting-groups = [[ + conflicts = [[ { package = "project", extra = "project1" }, { package = "project", extra = "project2" }, ]] @@ -3272,7 +3272,7 @@ fn lock_conflicting_extra_unconditional() -> Result<()> { project2 = ["anyio==4.2.0"] [tool.uv] - conflicting-groups = [ + conflicts = [ [ { extra = "project1" }, { extra = "project2" }, diff --git a/crates/uv/tests/it/pip_install.rs b/crates/uv/tests/it/pip_install.rs index 01fecac90..be6ef7a62 100644 --- a/crates/uv/tests/it/pip_install.rs +++ b/crates/uv/tests/it/pip_install.rs @@ -191,7 +191,7 @@ fn invalid_pyproject_toml_option_unknown_field() -> Result<()> { | 2 | unknown = "field" | ^^^^^^^ - unknown field `unknown`, expected one of `native-tls`, `offline`, `no-cache`, `cache-dir`, `preview`, `python-preference`, `python-downloads`, `concurrent-downloads`, `concurrent-builds`, `concurrent-installs`, `index`, `index-url`, `extra-index-url`, `no-index`, `find-links`, `index-strategy`, `keyring-provider`, `allow-insecure-host`, `resolution`, `prerelease`, `dependency-metadata`, `config-settings`, `no-build-isolation`, `no-build-isolation-package`, `exclude-newer`, `link-mode`, `compile-bytecode`, `no-sources`, `upgrade`, `upgrade-package`, `reinstall`, `reinstall-package`, `no-build`, `no-build-package`, `no-binary`, `no-binary-package`, `python-install-mirror`, `pypy-install-mirror`, `publish-url`, `trusted-publishing`, `pip`, `cache-keys`, `override-dependencies`, `constraint-dependencies`, `environments`, `conflicting-groups`, `workspace`, `sources`, `managed`, `package`, `default-groups`, `dev-dependencies` + unknown field `unknown`, expected one of `native-tls`, `offline`, `no-cache`, `cache-dir`, `preview`, `python-preference`, `python-downloads`, `concurrent-downloads`, `concurrent-builds`, `concurrent-installs`, `index`, `index-url`, `extra-index-url`, `no-index`, `find-links`, `index-strategy`, `keyring-provider`, `allow-insecure-host`, `resolution`, `prerelease`, `dependency-metadata`, `config-settings`, `no-build-isolation`, `no-build-isolation-package`, `exclude-newer`, `link-mode`, `compile-bytecode`, `no-sources`, `upgrade`, `upgrade-package`, `reinstall`, `reinstall-package`, `no-build`, `no-build-package`, `no-binary`, `no-binary-package`, `python-install-mirror`, `pypy-install-mirror`, `publish-url`, `trusted-publishing`, `pip`, `cache-keys`, `override-dependencies`, `constraint-dependencies`, `environments`, `conflicts`, `workspace`, `sources`, `managed`, `package`, `default-groups`, `dev-dependencies` Resolved in [TIME] Audited in [TIME] @@ -7289,7 +7289,7 @@ fn sklearn() { let filters = std::iter::once((r"exit code: 1", "exit status: 1")) .chain(context.filters()) .collect::>(); - uv_snapshot!(filters, context.pip_install().arg("sklearn"), @r#" + uv_snapshot!(filters, context.pip_install().arg("sklearn"), @r###" success: false exit_code: 1 ----- stdout ----- @@ -7316,6 +7316,6 @@ fn sklearn() { https://github.com/scikit-learn/sklearn-pypi-package help: `sklearn` is often confused for `scikit-learn` Did you mean to install `scikit-learn` instead? - "# + "### ); } diff --git a/crates/uv/tests/it/show_settings.rs b/crates/uv/tests/it/show_settings.rs index 49a889198..8083e3639 100644 --- a/crates/uv/tests/it/show_settings.rs +++ b/crates/uv/tests/it/show_settings.rs @@ -3107,9 +3107,9 @@ fn resolve_both() -> anyhow::Result<()> { Ok(()) } -/// Tests that errors when parsing `conflicting-groups` are reported. +/// Tests that errors when parsing `conflicts` are reported. #[test] -fn invalid_conflicting_groups() -> anyhow::Result<()> { +fn invalid_conflicts() -> anyhow::Result<()> { let context = TestContext::new("3.12"); let pyproject = context.temp_dir.child("pyproject.toml"); @@ -3121,7 +3121,7 @@ fn invalid_conflicting_groups() -> anyhow::Result<()> { requires-python = ">=3.12" [tool.uv] - conflicting-groups = [ + conflicts = [ [{extra = "dev"}], ] "#})?; @@ -3134,11 +3134,11 @@ fn invalid_conflicting_groups() -> anyhow::Result<()> { ----- stderr ----- error: Failed to parse: `pyproject.toml` - Caused by: TOML parse error at line 7, column 22 + Caused by: TOML parse error at line 7, column 13 | - 7 | conflicting-groups = [ - | ^ - Each set of conflicting groups must have at least two entries, but found only one + 7 | conflicts = [ + | ^ + Each set of conflicts must have at least two entries, but found only one "### ); @@ -3150,7 +3150,7 @@ fn invalid_conflicting_groups() -> anyhow::Result<()> { requires-python = ">=3.12" [tool.uv] - conflicting-groups = [[]] + conflicts = [[]] "#})?; // The file should be rejected for violating the schema. @@ -3161,20 +3161,20 @@ fn invalid_conflicting_groups() -> anyhow::Result<()> { ----- stderr ----- error: Failed to parse: `pyproject.toml` - Caused by: TOML parse error at line 7, column 22 + Caused by: TOML parse error at line 7, column 13 | - 7 | conflicting-groups = [[]] - | ^^^^ - Each set of conflicting groups must have at least two entries, but found none + 7 | conflicts = [[]] + | ^^^^ + Each set of conflicts must have at least two entries, but found none "### ); Ok(()) } -/// Tests that valid `conflicting-groups` are parsed okay. +/// Tests that valid `conflicts` are parsed okay. #[test] -fn valid_conflicting_groups() -> anyhow::Result<()> { +fn valid_conflicts() -> anyhow::Result<()> { let context = TestContext::new("3.12"); let pyproject = context.temp_dir.child("pyproject.toml"); @@ -3186,7 +3186,7 @@ fn valid_conflicting_groups() -> anyhow::Result<()> { requires-python = ">=3.12" [tool.uv] - conflicting-groups = [ + conflicts = [ [{extra = "x1"}, {extra = "x2"}], ] "#})?; @@ -3405,7 +3405,7 @@ fn resolve_config_file() -> anyhow::Result<()> { | 1 | [project] | ^^^^^^^ - unknown field `project`, expected one of `native-tls`, `offline`, `no-cache`, `cache-dir`, `preview`, `python-preference`, `python-downloads`, `concurrent-downloads`, `concurrent-builds`, `concurrent-installs`, `index`, `index-url`, `extra-index-url`, `no-index`, `find-links`, `index-strategy`, `keyring-provider`, `allow-insecure-host`, `resolution`, `prerelease`, `dependency-metadata`, `config-settings`, `no-build-isolation`, `no-build-isolation-package`, `exclude-newer`, `link-mode`, `compile-bytecode`, `no-sources`, `upgrade`, `upgrade-package`, `reinstall`, `reinstall-package`, `no-build`, `no-build-package`, `no-binary`, `no-binary-package`, `python-install-mirror`, `pypy-install-mirror`, `publish-url`, `trusted-publishing`, `pip`, `cache-keys`, `override-dependencies`, `constraint-dependencies`, `environments`, `conflicting-groups`, `workspace`, `sources`, `managed`, `package`, `default-groups`, `dev-dependencies` + unknown field `project`, expected one of `native-tls`, `offline`, `no-cache`, `cache-dir`, `preview`, `python-preference`, `python-downloads`, `concurrent-downloads`, `concurrent-builds`, `concurrent-installs`, `index`, `index-url`, `extra-index-url`, `no-index`, `find-links`, `index-strategy`, `keyring-provider`, `allow-insecure-host`, `resolution`, `prerelease`, `dependency-metadata`, `config-settings`, `no-build-isolation`, `no-build-isolation-package`, `exclude-newer`, `link-mode`, `compile-bytecode`, `no-sources`, `upgrade`, `upgrade-package`, `reinstall`, `reinstall-package`, `no-build`, `no-build-package`, `no-binary`, `no-binary-package`, `python-install-mirror`, `pypy-install-mirror`, `publish-url`, `trusted-publishing`, `pip`, `cache-keys`, `override-dependencies`, `constraint-dependencies`, `environments`, `conflicts`, `workspace`, `sources`, `managed`, `package`, `default-groups`, `dev-dependencies` "### );