Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve messages for empty solves and installs #6588

Merged
merged 1 commit into from
Aug 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 36 additions & 20 deletions crates/uv/src/commands/pip/loggers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -43,17 +43,25 @@ pub(crate) struct DefaultInstallLogger;

impl InstallLogger for DefaultInstallLogger {
fn on_audit(&self, count: usize, start: std::time::Instant, printer: Printer) -> fmt::Result {
let s = if count == 1 { "" } else { "s" };
writeln!(
printer.stderr(),
"{}",
format!(
"Audited {} {}",
format!("{count} package{s}").bold(),
format!("in {}", elapsed(start.elapsed())).dimmed()
if count == 0 {
writeln!(
printer.stderr(),
"{}",
format!("Audited in {}", elapsed(start.elapsed())).dimmed()
)
.dimmed()
)
} else {
let s = if count == 1 { "" } else { "s" };
writeln!(
printer.stderr(),
"{}",
format!(
"Audited {} {}",
format!("{count} package{s}").bold(),
format!("in {}", elapsed(start.elapsed())).dimmed()
)
.dimmed()
)
}
}

fn on_prepare(&self, count: usize, start: std::time::Instant, printer: Printer) -> fmt::Result {
Expand Down Expand Up @@ -404,17 +412,25 @@ impl ResolveLogger for DefaultResolveLogger {
start: std::time::Instant,
printer: Printer,
) -> fmt::Result {
let s = if count == 1 { "" } else { "s" };
writeln!(
printer.stderr(),
"{}",
format!(
"Resolved {} {}",
format!("{count} package{s}").bold(),
format!("in {}", elapsed(start.elapsed())).dimmed()
if count == 0 {
writeln!(
printer.stderr(),
"{}",
format!("Resolved in {}", elapsed(start.elapsed())).dimmed()
)
.dimmed()
)
} else {
let s = if count == 1 { "" } else { "s" };
writeln!(
printer.stderr(),
"{}",
format!(
"Resolved {} {}",
format!("{count} package{s}").bold(),
format!("in {}", elapsed(start.elapsed())).dimmed()
)
.dimmed()
)
}
}
}

Expand Down
4 changes: 2 additions & 2 deletions crates/uv/tests/lock.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9209,7 +9209,7 @@ fn lock_remove_member_virtual() -> Result<()> {
----- stdout -----

----- stderr -----
Resolved 0 packages in [TIME]
Resolved in [TIME]
error: The lockfile at `uv.lock` needs to be updated, but `--locked` was provided. To update the lockfile, run `uv lock`.
"###);

Expand All @@ -9220,7 +9220,7 @@ fn lock_remove_member_virtual() -> Result<()> {
----- stdout -----

----- stderr -----
Resolved 0 packages in [TIME]
Resolved in [TIME]
Removed anyio v4.3.0
Removed idna v3.6
Removed leaf v0.1.0
Expand Down
10 changes: 5 additions & 5 deletions crates/uv/tests/pip_compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ fn missing_venv() -> Result<()> {

----- stderr -----
warning: Requirements file requirements.in does not contain any dependencies
Resolved 0 packages in [TIME]
Resolved in [TIME]
"###
);

Expand Down Expand Up @@ -320,7 +320,7 @@ fn compile_constraints_inline() -> Result<()> {
# uv pip compile --cache-dir [CACHE_DIR] requirements.in

----- stderr -----
Resolved 0 packages in [TIME]
Resolved in [TIME]
"###
);

Expand Down Expand Up @@ -5475,7 +5475,7 @@ fn matching_index_urls_requirements_txt() -> Result<()> {
# uv pip compile --cache-dir [CACHE_DIR] requirements.in --constraint constraints.in

----- stderr -----
Resolved 0 packages in [TIME]
Resolved in [TIME]
"###
);

Expand Down Expand Up @@ -10074,7 +10074,7 @@ fn emit_marker_expression_conditional() -> Result<()> {
# sys_platform == 'linux'

----- stderr -----
Resolved 0 packages in [TIME]
Resolved in [TIME]
"###);

Ok(())
Expand Down Expand Up @@ -11644,7 +11644,7 @@ fn dynamic_pyproject_toml() -> Result<()> {
# uv pip compile --cache-dir [CACHE_DIR] pyproject.toml

----- stderr -----
Resolved 0 packages in [TIME]
Resolved in [TIME]
"###);

Ok(())
Expand Down
2 changes: 1 addition & 1 deletion crates/uv/tests/pip_install.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ fn empty_requirements_txt() -> Result<()> {

----- stderr -----
warning: Requirements file requirements.txt does not contain any dependencies
Audited 0 packages in [TIME]
Audited in [TIME]
"###
);

Expand Down
6 changes: 3 additions & 3 deletions crates/uv/tests/pip_sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ fn pip_sync_empty() -> Result<()> {

----- stderr -----
warning: Requirements file requirements.txt does not contain any dependencies
Resolved 0 packages in [TIME]
Audited 0 packages in [TIME]
Resolved in [TIME]
Audited in [TIME]
"###
);

Expand All @@ -383,7 +383,7 @@ fn pip_sync_empty() -> Result<()> {

----- stderr -----
warning: Requirements file requirements.txt does not contain any dependencies
Resolved 0 packages in [TIME]
Resolved in [TIME]
Uninstalled 1 package in [TIME]
- iniconfig==2.0.0
"###
Expand Down
8 changes: 4 additions & 4 deletions crates/uv/tests/sync.rs
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ fn empty() -> Result<()> {
----- stdout -----

----- stderr -----
Resolved 0 packages in [TIME]
Audited 0 packages in [TIME]
Resolved in [TIME]
Audited in [TIME]
"###);

assert!(context.temp_dir.child("uv.lock").exists());
Expand All @@ -191,8 +191,8 @@ fn empty() -> Result<()> {
----- stdout -----

----- stderr -----
Resolved 0 packages in [TIME]
Audited 0 packages in [TIME]
Resolved in [TIME]
Audited in [TIME]
"###);

Ok(())
Expand Down
Loading