mirror of
https://github.com/astral-sh/uv.git
synced 2025-11-02 04:48:18 +00:00
Add immutable definition to Source struct (#6108)
## Summary Centralizes the definition of an "immutable" source.
This commit is contained in:
parent
3187dc1a2f
commit
fd0daae969
1 changed files with 12 additions and 4 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
@ -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()
|
||||
|
|
@ -1795,6 +1795,14 @@ impl Source {
|
|||
)
|
||||
}
|
||||
|
||||
/// Returns `true` if the source should be considered immutable.
|
||||
///
|
||||
/// We assume that registry sources are immutable. In other words, we expect that once a
|
||||
/// package-version is published to a registry, its metadata will not change.
|
||||
fn is_immutable(&self) -> bool {
|
||||
matches!(self, Self::Registry(..))
|
||||
}
|
||||
|
||||
fn to_toml(&self, table: &mut Table) {
|
||||
let mut source_table = InlineTable::new();
|
||||
match *self {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue