Skip to content

Commit

Permalink
Improve messages for empty solves and installs
Browse files Browse the repository at this point in the history
  • Loading branch information
charliermarsh committed Aug 27, 2024
1 parent 3f15f2d commit b30a6cd
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 30 deletions.
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
8 changes: 4 additions & 4 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 @@ -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

0 comments on commit b30a6cd

Please sign in to comment.