Skip to content

Commit

Permalink
Move yank warnings to end of messages (#1669)
Browse files Browse the repository at this point in the history
Resolves #1292.

## Summary

Move the yanked warnings for `uv pip sync` and `uv pip install` to the
end of the commands, as per #1292.

## Test Plan

I ran the unit tests: `cargo nextest run`
  • Loading branch information
dwreeves authored Feb 19, 2024
1 parent 4b92a51 commit e923dba
Show file tree
Hide file tree
Showing 4 changed files with 59 additions and 59 deletions.
56 changes: 28 additions & 28 deletions crates/uv/src/commands/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -547,33 +547,6 @@ async fn install(
})
.collect::<Vec<_>>();

// TODO(konstin): Also check the cache whether any cached or installed dist is already known to
// have been yanked, we currently don't show this message on the second run anymore
for dist in &remote {
let Some(file) = dist.file() else {
continue;
};
match &file.yanked {
None | Some(Yanked::Bool(false)) => {}
Some(Yanked::Bool(true)) => {
writeln!(
printer,
"{}{} {dist} is yanked.",
"warning".yellow().bold(),
":".bold(),
)?;
}
Some(Yanked::Reason(reason)) => {
writeln!(
printer,
"{}{} {dist} is yanked (reason: \"{reason}\").",
"warning".yellow().bold(),
":".bold(),
)?;
}
}
}

// Download, build, and unzip any missing distributions.
let wheels = if remote.is_empty() {
vec![]
Expand All @@ -584,7 +557,7 @@ async fn install(
.with_reporter(DownloadReporter::from(printer).with_length(remote.len() as u64));

let wheels = downloader
.download(remote, in_flight)
.download(remote.clone(), in_flight)
.await
.context("Failed to download distributions")?;

Expand Down Expand Up @@ -679,6 +652,33 @@ async fn install(
}
}

// TODO(konstin): Also check the cache whether any cached or installed dist is already known to
// have been yanked, we currently don't show this message on the second run anymore
for dist in &remote {
let Some(file) = dist.file() else {
continue;
};
match &file.yanked {
None | Some(Yanked::Bool(false)) => {}
Some(Yanked::Bool(true)) => {
writeln!(
printer,
"{}{} {dist} is yanked.",
"warning".yellow().bold(),
":".bold(),
)?;
}
Some(Yanked::Reason(reason)) => {
writeln!(
printer,
"{}{} {dist} is yanked (reason: \"{reason}\").",
"warning".yellow().bold(),
":".bold(),
)?;
}
}
}

Ok(())
}

Expand Down
56 changes: 28 additions & 28 deletions crates/uv/src/commands/pip_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,33 +197,6 @@ pub(crate) async fn pip_sync(
resolution.into_distributions().collect::<Vec<_>>()
};

// TODO(konstin): Also check the cache whether any cached or installed dist is already known to
// have been yanked, we currently don't show this message on the second run anymore
for dist in &remote {
let Some(file) = dist.file() else {
continue;
};
match &file.yanked {
None | Some(Yanked::Bool(false)) => {}
Some(Yanked::Bool(true)) => {
writeln!(
printer,
"{}{} {dist} is yanked. Refresh your lockfile to pin an un-yanked version.",
"warning".yellow().bold(),
":".bold(),
)?;
}
Some(Yanked::Reason(reason)) => {
writeln!(
printer,
"{}{} {dist} is yanked (reason: \"{reason}\"). Refresh your lockfile to pin an un-yanked version.",
"warning".yellow().bold(),
":".bold(),
)?;
}
}
}

// Download, build, and unzip any missing distributions.
let wheels = if remote.is_empty() {
Vec::new()
Expand All @@ -234,7 +207,7 @@ pub(crate) async fn pip_sync(
.with_reporter(DownloadReporter::from(printer).with_length(remote.len() as u64));

let wheels = downloader
.download(remote, &in_flight)
.download(remote.clone(), &in_flight)
.await
.context("Failed to download distributions")?;

Expand Down Expand Up @@ -363,6 +336,33 @@ pub(crate) async fn pip_sync(
}
}

// TODO(konstin): Also check the cache whether any cached or installed dist is already known to
// have been yanked, we currently don't show this message on the second run anymore
for dist in &remote {
let Some(file) = dist.file() else {
continue;
};
match &file.yanked {
None | Some(Yanked::Bool(false)) => {}
Some(Yanked::Bool(true)) => {
writeln!(
printer,
"{}{} {dist} is yanked. Refresh your lockfile to pin an un-yanked version.",
"warning".yellow().bold(),
":".bold(),
)?;
}
Some(Yanked::Reason(reason)) => {
writeln!(
printer,
"{}{} {dist} is yanked (reason: \"{reason}\"). Refresh your lockfile to pin an un-yanked version.",
"warning".yellow().bold(),
":".bold(),
)?;
}
}
}

Ok(ExitStatus::Success)
}

Expand Down
4 changes: 2 additions & 2 deletions crates/uv/tests/pip_install_scenarios.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3132,11 +3132,11 @@ fn transitive_package_only_yanked_in_range_opt_in() {
----- stderr -----
Resolved 2 packages in [TIME]
warning: bluebird==1.0.0 is yanked.
Downloaded 2 packages in [TIME]
Installed 2 packages in [TIME]
+ albatross==0.1.0
+ bluebird==1.0.0
warning: bluebird==1.0.0 is yanked.
"###);

// Since the user included a dependency on `b` with an exact specifier, the yanked
Expand Down Expand Up @@ -3252,12 +3252,12 @@ fn transitive_yanked_and_unyanked_dependency_opt_in() {
----- stderr -----
Resolved 3 packages in [TIME]
warning: crow==2.0.0 is yanked.
Downloaded 3 packages in [TIME]
Installed 3 packages in [TIME]
+ albatross==1.0.0
+ bluebird==1.0.0
+ crow==2.0.0
warning: crow==2.0.0 is yanked.
"###);

// Since the user explicitly selected the yanked version of `c`, it can be
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/pip_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -904,10 +904,10 @@ fn warn_on_yanked_version() -> Result<()> {
----- stderr -----
Resolved 1 package in [TIME]
warning: colorama==0.4.2 is yanked (reason: "Bad build, missing files, will not install"). Refresh your lockfile to pin an un-yanked version.
Downloaded 1 package in [TIME]
Installed 1 package in [TIME]
+ colorama==0.4.2
warning: colorama==0.4.2 is yanked (reason: "Bad build, missing files, will not install"). Refresh your lockfile to pin an un-yanked version.
"###
);

Expand Down

0 comments on commit e923dba

Please sign in to comment.