mirror of
https://github.com/astral-sh/uv.git
synced 2025-09-26 12:09:12 +00:00
uv-pypi-types: rename "conflicting group" types to more generic "conflicts"
Since this is intended to support _both_ groups and extras, it doesn't make sense to just name it for groups. And since there isn't really a word that encapsulates both "extra" and "group," we just fall back to the super general "conflicts." We'll rename the variables and other things in the next commit.
This commit is contained in:
parent
84d50ce81a
commit
19a044d4db
17 changed files with 150 additions and 160 deletions
|
@ -40,8 +40,8 @@ use uv_pep440::Version;
|
|||
use uv_pep508::{split_scheme, MarkerEnvironment, MarkerTree, VerbatimUrl, VerbatimUrlError};
|
||||
use uv_platform_tags::{TagCompatibility, TagPriority, Tags};
|
||||
use uv_pypi_types::{
|
||||
redact_credentials, ConflictingGroupList, HashDigest, ParsedArchiveUrl, ParsedGitUrl,
|
||||
Requirement, RequirementSource,
|
||||
redact_credentials, Conflicts, HashDigest, ParsedArchiveUrl, ParsedGitUrl, Requirement,
|
||||
RequirementSource,
|
||||
};
|
||||
use uv_types::{BuildContext, HashStrategy};
|
||||
use uv_workspace::dependency_groups::DependencyGroupError;
|
||||
|
@ -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: ConflictingGroupList,
|
||||
conflicting_groups: Conflicts,
|
||||
/// The list of supported environments specified by the user.
|
||||
supported_environments: Vec<MarkerTree>,
|
||||
/// The range of supported Python versions.
|
||||
|
@ -239,7 +239,7 @@ impl Lock {
|
|||
requires_python,
|
||||
options,
|
||||
ResolverManifest::default(),
|
||||
ConflictingGroupList::empty(),
|
||||
Conflicts::empty(),
|
||||
vec![],
|
||||
graph.fork_markers.clone(),
|
||||
)?;
|
||||
|
@ -315,7 +315,7 @@ impl Lock {
|
|||
requires_python: RequiresPython,
|
||||
options: ResolverOptions,
|
||||
manifest: ResolverManifest,
|
||||
conflicting_groups: ConflictingGroupList,
|
||||
conflicting_groups: Conflicts,
|
||||
supported_environments: Vec<MarkerTree>,
|
||||
fork_markers: Vec<MarkerTree>,
|
||||
) -> Result<Self, LockError> {
|
||||
|
@ -485,7 +485,7 @@ impl Lock {
|
|||
|
||||
/// Record the conflicting groups that were used to generate this lock.
|
||||
#[must_use]
|
||||
pub fn with_conflicting_groups(mut self, conflicting_groups: ConflictingGroupList) -> Self {
|
||||
pub fn with_conflicting_groups(mut self, conflicting_groups: Conflicts) -> Self {
|
||||
self.conflicting_groups = conflicting_groups;
|
||||
self
|
||||
}
|
||||
|
@ -550,7 +550,7 @@ impl Lock {
|
|||
}
|
||||
|
||||
/// Returns the conflicting groups that were used to generate this lock.
|
||||
pub fn conflicting_groups(&self) -> &ConflictingGroupList {
|
||||
pub fn conflicting_groups(&self) -> &Conflicts {
|
||||
&self.conflicting_groups
|
||||
}
|
||||
|
||||
|
@ -1384,7 +1384,7 @@ struct LockWire {
|
|||
#[serde(rename = "supported-markers", default)]
|
||||
supported_environments: Vec<SimplifiedMarkerTree>,
|
||||
#[serde(rename = "conflicting-groups", default)]
|
||||
conflicting_groups: Option<ConflictingGroupList>,
|
||||
conflicting_groups: Option<Conflicts>,
|
||||
/// We discard the lockfile if these options match.
|
||||
#[serde(default)]
|
||||
options: ResolverOptions,
|
||||
|
@ -1436,8 +1436,7 @@ impl TryFrom<LockWire> for Lock {
|
|||
wire.requires_python,
|
||||
wire.options,
|
||||
wire.manifest,
|
||||
wire.conflicting_groups
|
||||
.unwrap_or_else(ConflictingGroupList::empty),
|
||||
wire.conflicting_groups.unwrap_or_else(Conflicts::empty),
|
||||
supported_environments,
|
||||
fork_markers,
|
||||
)?;
|
||||
|
|
|
@ -3,7 +3,7 @@ use std::sync::Arc;
|
|||
|
||||
use uv_normalize::{ExtraName, GroupName, PackageName};
|
||||
use uv_pep508::{MarkerTree, MarkerTreeContents};
|
||||
use uv_pypi_types::ConflictingGroupRef;
|
||||
use uv_pypi_types::ConflictItemRef;
|
||||
|
||||
use crate::python_requirement::PythonRequirement;
|
||||
|
||||
|
@ -190,10 +190,10 @@ 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<ConflictingGroupRef<'_>> {
|
||||
pub(crate) fn conflicting_group(&self) -> Option<ConflictItemRef<'_>> {
|
||||
let package = self.name_no_root()?;
|
||||
let extra = self.extra()?;
|
||||
Some(ConflictingGroupRef::from((package, extra)))
|
||||
Some(ConflictItemRef::from((package, extra)))
|
||||
}
|
||||
|
||||
/// Returns `true` if this PubGrub package is a proxy package.
|
||||
|
|
|
@ -18,7 +18,7 @@ use uv_normalize::{ExtraName, GroupName, PackageName};
|
|||
use uv_pep440::{Version, VersionSpecifier};
|
||||
use uv_pep508::{MarkerEnvironment, MarkerTree, MarkerTreeKind};
|
||||
use uv_pypi_types::{
|
||||
ConflictingGroupList, HashDigest, ParsedUrlError, Requirement, VerbatimParsedUrl, Yanked,
|
||||
Conflicts, HashDigest, ParsedUrlError, Requirement, VerbatimParsedUrl, Yanked,
|
||||
};
|
||||
|
||||
use crate::graph_ops::marker_reachability;
|
||||
|
@ -103,7 +103,7 @@ impl ResolutionGraph {
|
|||
index: &InMemoryIndex,
|
||||
git: &GitResolver,
|
||||
python: &PythonRequirement,
|
||||
conflicting_groups: &ConflictingGroupList,
|
||||
conflicting_groups: &Conflicts,
|
||||
resolution_strategy: &ResolutionStrategy,
|
||||
options: Options,
|
||||
) -> Result<Self, ResolveError> {
|
||||
|
|
|
@ -3,9 +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::{
|
||||
ConflictingGroup, ConflictingGroupList, ConflictingGroupRef, ResolverMarkerEnvironment,
|
||||
};
|
||||
use uv_pypi_types::{ConflictItem, ConflictItemRef, Conflicts, ResolverMarkerEnvironment};
|
||||
|
||||
use crate::pubgrub::{PubGrubDependency, PubGrubPackage};
|
||||
use crate::requires_python::RequiresPythonRange;
|
||||
|
@ -165,7 +163,7 @@ impl ResolverEnvironment {
|
|||
|
||||
/// Returns true if the dependency represented by this forker may be
|
||||
/// included in the given resolver environment.
|
||||
pub(crate) fn included_by_group(&self, group: ConflictingGroupRef<'_>) -> bool {
|
||||
pub(crate) fn included_by_group(&self, group: ConflictItemRef<'_>) -> bool {
|
||||
match self.kind {
|
||||
Kind::Specific { .. } => true,
|
||||
Kind::Universal { ref exclude, .. } => !exclude
|
||||
|
@ -229,7 +227,7 @@ impl ResolverEnvironment {
|
|||
/// specific marker environment. i.e., "pip"-style resolution.
|
||||
pub(crate) fn exclude_by_group(
|
||||
&self,
|
||||
groups: impl IntoIterator<Item = ConflictingGroup>,
|
||||
groups: impl IntoIterator<Item = ConflictItem>,
|
||||
) -> ResolverEnvironment {
|
||||
match self.kind {
|
||||
Kind::Specific { .. } => {
|
||||
|
@ -427,7 +425,7 @@ impl<'d> Forker<'d> {
|
|||
pub(crate) fn fork(
|
||||
&self,
|
||||
env: &ResolverEnvironment,
|
||||
_conflicting_groups: &ConflictingGroupList,
|
||||
_conflicting_groups: &Conflicts,
|
||||
) -> Option<(Forker<'d>, Vec<ResolverEnvironment>)> {
|
||||
if !env.included_by_marker(&self.marker) {
|
||||
return None;
|
||||
|
|
|
@ -38,8 +38,7 @@ use uv_pep440::{release_specifiers_to_ranges, Version, MIN_VERSION};
|
|||
use uv_pep508::MarkerTree;
|
||||
use uv_platform_tags::Tags;
|
||||
use uv_pypi_types::{
|
||||
ConflictingGroup, ConflictingGroupList, ConflictingGroupRef, Requirement, ResolutionMetadata,
|
||||
VerbatimParsedUrl,
|
||||
ConflictItem, ConflictItemRef, Conflicts, Requirement, ResolutionMetadata, VerbatimParsedUrl,
|
||||
};
|
||||
use uv_types::{BuildContext, HashStrategy, InstalledPackagesProvider};
|
||||
use uv_warnings::warn_user_once;
|
||||
|
@ -110,7 +109,7 @@ struct ResolverState<InstalledPackages: InstalledPackagesProvider> {
|
|||
hasher: HashStrategy,
|
||||
env: ResolverEnvironment,
|
||||
python_requirement: PythonRequirement,
|
||||
conflicting_groups: ConflictingGroupList,
|
||||
conflicting_groups: Conflicts,
|
||||
workspace_members: BTreeSet<PackageName>,
|
||||
selector: CandidateSelector,
|
||||
index: InMemoryIndex,
|
||||
|
@ -151,7 +150,7 @@ impl<'a, Context: BuildContext, InstalledPackages: InstalledPackagesProvider>
|
|||
options: Options,
|
||||
python_requirement: &'a PythonRequirement,
|
||||
env: ResolverEnvironment,
|
||||
conflicting_groups: ConflictingGroupList,
|
||||
conflicting_groups: Conflicts,
|
||||
tags: Option<&'a Tags>,
|
||||
flat_index: &'a FlatIndex,
|
||||
index: &'a InMemoryIndex,
|
||||
|
@ -199,7 +198,7 @@ impl<Provider: ResolverProvider, InstalledPackages: InstalledPackagesProvider>
|
|||
hasher: &HashStrategy,
|
||||
env: ResolverEnvironment,
|
||||
python_requirement: &PythonRequirement,
|
||||
conflicting_groups: ConflictingGroupList,
|
||||
conflicting_groups: Conflicts,
|
||||
index: &InMemoryIndex,
|
||||
git: &GitResolver,
|
||||
capabilities: &IndexCapabilities,
|
||||
|
@ -1631,7 +1630,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
return None;
|
||||
}
|
||||
if !env.included_by_group(
|
||||
ConflictingGroupRef::from((&requirement.name, source_extra)),
|
||||
ConflictItemRef::from((&requirement.name, source_extra)),
|
||||
) {
|
||||
return None;
|
||||
}
|
||||
|
@ -1724,7 +1723,7 @@ impl<InstalledPackages: InstalledPackagesProvider> ResolverState<InstalledPackag
|
|||
return None;
|
||||
}
|
||||
if !env.included_by_group(
|
||||
ConflictingGroupRef::from((&requirement.name, source_extra)),
|
||||
ConflictItemRef::from((&requirement.name, source_extra)),
|
||||
) {
|
||||
return None;
|
||||
}
|
||||
|
@ -2695,7 +2694,7 @@ impl Dependencies {
|
|||
self,
|
||||
env: &ResolverEnvironment,
|
||||
python_requirement: &PythonRequirement,
|
||||
conflicting_groups: &ConflictingGroupList,
|
||||
conflicting_groups: &Conflicts,
|
||||
) -> ForkedDependencies {
|
||||
let deps = match self {
|
||||
Dependencies::Available(deps) => deps,
|
||||
|
@ -2776,7 +2775,7 @@ impl Forks {
|
|||
name_to_deps: BTreeMap<PackageName, Vec<PubGrubDependency>>,
|
||||
env: &ResolverEnvironment,
|
||||
python_requirement: &PythonRequirement,
|
||||
conflicting_groups: &ConflictingGroupList,
|
||||
conflicting_groups: &Conflicts,
|
||||
) -> Forks {
|
||||
let python_marker = python_requirement.to_marker_tree();
|
||||
|
||||
|
@ -3016,7 +3015,7 @@ 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: ConflictingGroupRef<'_>) -> bool {
|
||||
fn contains_conflicting_group(&self, group: ConflictItemRef<'_>) -> bool {
|
||||
self.conflicting_groups
|
||||
.get(group.package())
|
||||
.map(|set| set.contains(group.extra()))
|
||||
|
@ -3026,7 +3025,7 @@ impl Fork {
|
|||
/// Exclude the given groups from this fork.
|
||||
///
|
||||
/// This removes all dependencies matching the given conflicting groups.
|
||||
fn exclude(mut self, groups: impl IntoIterator<Item = ConflictingGroup>) -> 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 {
|
||||
|
@ -3114,10 +3113,7 @@ impl PartialOrd for Fork {
|
|||
/// depends on `c[x2]`. That's a conflict, but not easily detectable unless
|
||||
/// you reject either `c[x1]` or `c[x2]` on the grounds that `x1` and `x2` are
|
||||
/// conflicting and thus cannot be enabled unconditionally.
|
||||
fn find_conflicting_extra(
|
||||
conflicting: &ConflictingGroupList,
|
||||
reqs: &[Requirement],
|
||||
) -> Option<ResolveError> {
|
||||
fn find_conflicting_extra(conflicting: &Conflicts, reqs: &[Requirement]) -> Option<ResolveError> {
|
||||
for req in reqs {
|
||||
for extra in &req.extras {
|
||||
if conflicting.contains(&req.name, extra) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue