Skip to content

Commit

Permalink
Add immutable definition to Source struct
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Aug 15, 2024
1 parent 3187dc1 commit 7ef24b3
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions crates/uv-resolver/src/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -754,8 +754,8 @@ impl Lock {
}

while let Some(package) = queue.pop_front() {
// Assume that registry dependencies are immutable.
if matches!(package.id.source, Source::Registry(..)) {
// If the package is immutable, we don't need to validate it (or its dependencies).
if package.id.source.is_immutable() {
continue;
}

Expand Down Expand Up @@ -1009,12 +1009,12 @@ impl Package {
let id = PackageId::from_annotated_dist(annotated_dist);
let sdist = SourceDist::from_annotated_dist(&id, annotated_dist)?;
let wheels = Wheel::from_annotated_dist(annotated_dist)?;
let requires_dist = if matches!(id.source, Source::Registry(..)) {
let requires_dist = if id.source.is_immutable() {
vec![]
} else {
annotated_dist.metadata.requires_dist.clone()
};
let requires_dev = if matches!(id.source, Source::Registry(..)) {
let requires_dev = if id.source.is_immutable() {
BTreeMap::default()
} else {
annotated_dist.metadata.dev_dependencies.clone()
Expand Down Expand Up @@ -1795,6 +1795,11 @@ impl Source {
)
}

/// Returns `true` if the source should be considered immutable.
fn is_immutable(&self) -> bool {
matches!(self, Self::Registry(..))
}

fn to_toml(&self, table: &mut Table) {
let mut source_table = InlineTable::new();
match *self {
Expand Down

0 comments on commit 7ef24b3

Please sign in to comment.