*: update "conflicting groups" terminology everywhere else

This commit is contained in:
Andrew Gallant 2024-11-13 10:15:47 -05:00 committed by Andrew Gallant
parent 19a044d4db
commit bb78e00a87
28 changed files with 134 additions and 142 deletions

View file

@ -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,

View file

@ -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<ConflictSet>);
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::<ConflictItem>::deserialize(deserializer)?;
Self::try_from(groups).map_err(serde::de::Error::custom)
let set = Vec::<ConflictItem>::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![];

View file

@ -82,7 +82,7 @@ pub struct Lock {
/// forks in the lockfile so we can recreate them in subsequent resolutions.
fork_markers: Vec<MarkerTree>,
/// 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<MarkerTree>,
/// 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<MarkerTree>,
fork_markers: Vec<MarkerTree>,
) -> Result<Self, LockError> {
@ -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<SimplifiedMarkerTree>,
#[serde(rename = "supported-markers", default)]
supported_environments: Vec<SimplifiedMarkerTree>,
#[serde(rename = "conflicting-groups", default)]
conflicting_groups: Option<Conflicts>,
#[serde(rename = "conflicts", default)]
conflicts: Option<Conflicts>,
/// We discard the lockfile if these options match.
#[serde(default)]
options: ResolverOptions,
@ -1436,7 +1436,7 @@ impl TryFrom<LockWire> 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,
)?;

View file

@ -6,7 +6,7 @@ Ok(
Lock {
version: 1,
fork_markers: [],
conflicting_groups: ConflictingGroupList(
conflicts: Conflicts(
[],
),
supported_environments: [],

View file

@ -6,7 +6,7 @@ Ok(
Lock {
version: 1,
fork_markers: [],
conflicting_groups: ConflictingGroupList(
conflicts: Conflicts(
[],
),
supported_environments: [],

View file

@ -6,7 +6,7 @@ Ok(
Lock {
version: 1,
fork_markers: [],
conflicting_groups: ConflictingGroupList(
conflicts: Conflicts(
[],
),
supported_environments: [],

View file

@ -6,7 +6,7 @@ Ok(
Lock {
version: 1,
fork_markers: [],
conflicting_groups: ConflictingGroupList(
conflicts: Conflicts(
[],
),
supported_environments: [],

View file

@ -6,7 +6,7 @@ Ok(
Lock {
version: 1,
fork_markers: [],
conflicting_groups: ConflictingGroupList(
conflicts: Conflicts(
[],
),
supported_environments: [],

View file

@ -6,7 +6,7 @@ Ok(
Lock {
version: 1,
fork_markers: [],
conflicting_groups: ConflictingGroupList(
conflicts: Conflicts(
[],
),
supported_environments: [],

View file

@ -6,7 +6,7 @@ Ok(
Lock {
version: 1,
fork_markers: [],
conflicting_groups: ConflictingGroupList(
conflicts: Conflicts(
[],
),
supported_environments: [],

View file

@ -6,7 +6,7 @@ Ok(
Lock {
version: 1,
fork_markers: [],
conflicting_groups: ConflictingGroupList(
conflicts: Conflicts(
[],
),
supported_environments: [],

View file

@ -6,7 +6,7 @@ Ok(
Lock {
version: 1,
fork_markers: [],
conflicting_groups: ConflictingGroupList(
conflicts: Conflicts(
[],
),
supported_environments: [],

View file

@ -6,7 +6,7 @@ Ok(
Lock {
version: 1,
fork_markers: [],
conflicting_groups: ConflictingGroupList(
conflicts: Conflicts(
[],
),
supported_environments: [],

View file

@ -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<ConflictItemRef<'_>> {
pub(crate) fn conflicting_item(&self) -> Option<ConflictItemRef<'_>> {
let package = self.name_no_root()?;
let extra = self.extra()?;
Some(ConflictItemRef::from((package, extra)))

View file

@ -103,7 +103,7 @@ impl ResolutionGraph {
index: &InMemoryIndex,
git: &GitResolver,
python: &PythonRequirement,
conflicting_groups: &Conflicts,
conflicts: &Conflicts,
resolution_strategy: &ResolutionStrategy,
options: Options,
) -> Result<Self, ResolveError> {
@ -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() {

View file

@ -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<ResolverEnvironment>)> {
if !env.included_by_marker(&self.marker) {
return None;

View file

@ -109,7 +109,7 @@ struct ResolverState<InstalledPackages: InstalledPackagesProvider> {
hasher: HashStrategy,
env: ResolverEnvironment,
python_requirement: PythonRequirement,
conflicting_groups: Conflicts,
conflicts: Conflicts,
workspace_members: BTreeSet<PackageName>,
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<Provider: ResolverProvider, InstalledPackages: InstalledPackagesProvider>
hasher: &HashStrategy,
env: ResolverEnvironment,
python_requirement: &PythonRequirement,
conflicting_groups: Conflicts,
conflicts: Conflicts,
index: &InMemoryIndex,
git: &GitResolver,
capabilities: &IndexCapabilities,
@ -226,7 +226,7 @@ impl<Provider: ResolverProvider, InstalledPackages: InstalledPackagesProvider>
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<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
&self.index,
&self.git,
&self.python_requirement,
&self.conflicting_groups,
&self.conflicts,
self.selector.resolution_strategy(),
self.options,
)
@ -1207,7 +1207,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
Dependencies::Unavailable(err) => 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<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
}
};
if let Some(err) =
find_conflicting_extra(&self.conflicting_groups, &metadata.requires_dist)
if let Some(err) = find_conflicting_extra(&self.conflicts, &metadata.requires_dist)
{
return Err(err);
}
for dependencies in metadata.dependency_groups.values() {
if let Some(err) =
find_conflicting_extra(&self.conflicting_groups, dependencies)
{
if let Some(err) = find_conflicting_extra(&self.conflicts, dependencies) {
return Err(err);
}
}
@ -2694,7 +2691,7 @@ impl Dependencies {
self,
env: &ResolverEnvironment,
python_requirement: &PythonRequirement,
conflicting_groups: &Conflicts,
conflicts: &Conflicts,
) -> 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<PackageName, Vec<PubGrubDependency>>,
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<PackageName, FxHashSet<ExtraName>>,
conflicts: FxHashMap<PackageName, FxHashSet<ExtraName>>,
/// 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<Item = ConflictItem>) -> 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

View file

@ -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<serde::de::IgnoredAny>,
pub conflicts: Option<serde::de::IgnoredAny>,
#[cfg_attr(feature = "schemars", schemars(skip))]
pub workspace: Option<serde::de::IgnoredAny>,
@ -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<serde::de::IgnoredAny>,
conflicts: Option<serde::de::IgnoredAny>,
workspace: Option<serde::de::IgnoredAny>,
sources: Option<serde::de::IgnoredAny>,
managed: Option<serde::de::IgnoredAny>,
@ -1681,7 +1681,7 @@ impl From<OptionsWire> for Options {
override_dependencies,
constraint_dependencies,
environments,
conflicting_groups,
conflicts,
publish_url,
trusted_publishing,
workspace,
@ -1743,7 +1743,7 @@ impl From<OptionsWire> for Options {
python_install_mirror,
pypy_install_mirror,
),
conflicting_groups,
conflicts,
publish: PublishOptions {
publish_url,
trusted_publishing,

View file

@ -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<SchemaConflicts>,
pub conflicts: Option<SchemaConflicts>,
}
#[derive(Default, Debug, Clone, PartialEq, Eq)]

View file

@ -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
}

View file

@ -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

View file

@ -54,7 +54,7 @@ pub(crate) async fn pip_compile(
constraints_from_workspace: Vec<Requirement>,
overrides_from_workspace: Vec<Requirement>,
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) =

View file

@ -104,7 +104,7 @@ pub(crate) async fn resolve<InstalledPackages: InstalledPackagesProvider>(
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<InstalledPackages: InstalledPackagesProvider>(
options,
&python_requirement,
resolver_env,
conflicting_groups,
conflicts,
tags,
flat_index,
index,

View file

@ -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));
}

View file

@ -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::<Vec<ExtraName>>();
if conflicting.len() >= 2 {
return Err(ProjectError::ExtraIncompatibility(
groups.clone(),
conflicting,
));
return Err(ProjectError::ExtraIncompatibility(set.clone(), conflicting));
}
}

View file

@ -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" },

View file

@ -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::<Vec<_>>();
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?
"#
"###
);
}

View file

@ -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 = [
7 | conflicts = [
| ^
Each set of conflicting groups must have at least two entries, but found only one
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 = [[]]
7 | conflicts = [[]]
| ^^^^
Each set of conflicting groups must have at least two entries, but found none
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`
"###
);