From 5d7c2b7a2dbfea2fa4179f75e352892190d0a9e1 Mon Sep 17 00:00:00 2001 From: Di-Is Date: Mon, 3 Jun 2024 12:52:24 +0000 Subject: [PATCH 1/2] fix: output warning that workspace loading failed. --- crates/uv-warnings/src/lib.rs | 5 +++++ crates/uv/src/main.rs | 9 ++++++++- crates/uv/tests/pip_compile.rs | 9 ++++++++- 3 files changed, 21 insertions(+), 2 deletions(-) diff --git a/crates/uv-warnings/src/lib.rs b/crates/uv-warnings/src/lib.rs index 437149c41904..1c2a49edbec1 100644 --- a/crates/uv-warnings/src/lib.rs +++ b/crates/uv-warnings/src/lib.rs @@ -17,6 +17,11 @@ pub fn enable() { ENABLED.store(true, std::sync::atomic::Ordering::SeqCst); } +/// Disable user-facing warnings. +pub fn disable() { + ENABLED.store(false, std::sync::atomic::Ordering::SeqCst); +} + /// Warn a user, if warnings are enabled. #[macro_export] macro_rules! warn_user { diff --git a/crates/uv/src/main.rs b/crates/uv/src/main.rs index 2b6c34630a4d..50c38db69ce8 100644 --- a/crates/uv/src/main.rs +++ b/crates/uv/src/main.rs @@ -107,6 +107,11 @@ async fn run() -> Result { } }; + // enable flag to pick up warnings generated by workspace loading. + if !cli.global_args.quiet { + uv_warnings::enable(); + } + // Load the workspace settings, prioritizing (in order): // 1. The configuration file specified on the command-line. // 2. The configuration file in the current directory. @@ -148,7 +153,9 @@ async fn run() -> Result { }; // Configure the `warn!` macros, which control user-facing warnings in the CLI. - if !globals.quiet { + if globals.quiet { + uv_warnings::disable(); + } else { uv_warnings::enable(); } diff --git a/crates/uv/tests/pip_compile.rs b/crates/uv/tests/pip_compile.rs index 1e77798ccc61..1a4045eb2ddd 100644 --- a/crates/uv/tests/pip_compile.rs +++ b/crates/uv/tests/pip_compile.rs @@ -3048,7 +3048,6 @@ fn override_multi_dependency() -> Result<()> { } /// Check how invalid `tool.uv.override-dependencies` is handled in `pyproject.toml`. -// TODO(konsti): We should show a warnings here or better fail parsing. #[test] fn override_dependency_from_workspace_invalid_syntax() -> Result<()> { let context = TestContext::new("3.12"); @@ -3095,6 +3094,14 @@ fn override_dependency_from_workspace_invalid_syntax() -> Result<()> { # via flask ----- stderr ----- + warning: Failed to parse `pyproject.toml`: TOML parse error at line 9, column 29 + | + 9 | override-dependencies = [ + | ^ + no such comparison operator "=", must be one of ~= == != <= >= < > === + werkzeug=2.3.0 + ^^^^^^ + Resolved 7 packages in [TIME] "### ); From 22def7cd40cfecd7a3ad2deaf9f0f487cdf0463a Mon Sep 17 00:00:00 2001 From: Di-Is Date: Tue, 4 Jun 2024 13:02:20 +0000 Subject: [PATCH 2/2] fix: adjust pip_install test --- crates/uv/tests/pip_install.rs | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/crates/uv/tests/pip_install.rs b/crates/uv/tests/pip_install.rs index fcaa0f472b3f..eaa261c38d17 100644 --- a/crates/uv/tests/pip_install.rs +++ b/crates/uv/tests/pip_install.rs @@ -142,6 +142,12 @@ fn invalid_pyproject_toml_syntax() -> Result<()> { ----- stdout ----- ----- stderr ----- + warning: Failed to parse `pyproject.toml`: TOML parse error at line 1, column 5 + | + 1 | 123 - 456 + | ^ + expected `.`, `=` + error: Failed to parse: `pyproject.toml` Caused by: TOML parse error at line 1, column 5 |