Use a Box for Yanked on File (#11755)

## Summary

See: https://github.com/astral-sh/uv/pull/11715.
This commit is contained in:
Charlie Marsh 2025-02-24 09:46:14 -10:00 committed by GitHub
parent a6ecf463fc
commit d9adba1cf5
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
5 changed files with 14 additions and 10 deletions

View file

@ -184,7 +184,7 @@ impl SimpleHtml {
let yanked = if let Some(yanked) = link.attributes().get("data-yanked").flatten() {
let yanked = std::str::from_utf8(yanked.as_bytes())?;
let yanked = html_escape::decode_html_entities(yanked);
Some(Yanked::Reason(yanked.into()))
Some(Box::new(Yanked::Reason(yanked.into())))
} else {
None
};

View file

@ -33,7 +33,7 @@ pub struct File {
// milliseconds.
pub upload_time_utc_ms: Option<i64>,
pub url: FileLocation,
pub yanked: Option<Yanked>,
pub yanked: Option<Box<Yanked>>,
}
impl File {

View file

@ -75,8 +75,10 @@ impl ResolvedDist {
pub fn yanked(&self) -> Option<&Yanked> {
match self {
Self::Installable { dist, .. } => match dist.as_ref() {
Dist::Source(SourceDist::Registry(sdist)) => sdist.file.yanked.as_ref(),
Dist::Built(BuiltDist::Registry(wheel)) => wheel.best_wheel().file.yanked.as_ref(),
Dist::Source(SourceDist::Registry(sdist)) => sdist.file.yanked.as_deref(),
Dist::Built(BuiltDist::Registry(wheel)) => {
wheel.best_wheel().file.yanked.as_deref()
}
_ => None,
},
Self::Installed { .. } => None,

View file

@ -54,7 +54,7 @@ pub struct File {
pub size: Option<u64>,
pub upload_time: Option<Timestamp>,
pub url: String,
pub yanked: Option<Yanked>,
pub yanked: Option<Box<Yanked>>,
}
fn deserialize_version_specifiers_lenient<'de, D>(

View file

@ -417,7 +417,7 @@ impl VersionMapLazy {
};
// Prioritize amongst all available files.
let yanked = file.yanked.clone();
let yanked = file.yanked.as_deref();
let hashes = file.hashes.clone();
match filename {
DistFilename::WheelFilename(filename) => {
@ -472,7 +472,7 @@ impl VersionMapLazy {
name: &PackageName,
version: &Version,
hashes: &[HashDigest],
yanked: Option<Yanked>,
yanked: Option<&Yanked>,
excluded: bool,
upload_time: Option<i64>,
) -> SourceDistCompatibility {
@ -491,7 +491,9 @@ impl VersionMapLazy {
// Check if yanked
if let Some(yanked) = yanked {
if yanked.is_yanked() && !self.allowed_yanks.contains(name, version) {
return SourceDistCompatibility::Incompatible(IncompatibleSource::Yanked(yanked));
return SourceDistCompatibility::Incompatible(IncompatibleSource::Yanked(
yanked.clone(),
));
}
}
@ -519,7 +521,7 @@ impl VersionMapLazy {
name: &PackageName,
version: &Version,
hashes: &[HashDigest],
yanked: Option<Yanked>,
yanked: Option<&Yanked>,
excluded: bool,
upload_time: Option<i64>,
) -> WheelCompatibility {
@ -536,7 +538,7 @@ impl VersionMapLazy {
// Check if yanked
if let Some(yanked) = yanked {
if yanked.is_yanked() && !self.allowed_yanks.contains(name, version) {
return WheelCompatibility::Incompatible(IncompatibleWheel::Yanked(yanked));
return WheelCompatibility::Incompatible(IncompatibleWheel::Yanked(yanked.clone()));
}
}