Make warnings user-facing (#628)

## Summary

Now, `puffin_warnings::warn_once` and `puffin_warnings::warn` will go to
`stderr`, as long as the user isn't running under `--quiet`. Previously,
these went through `tracing`, and so were only visible when running
under `--verbose`.
This commit is contained in:
Charlie Marsh 2023-12-12 21:24:38 -05:00 committed by GitHub
parent 490fb55ac5
commit a24eb57e93
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 95 additions and 66 deletions

View file

@ -16,7 +16,7 @@ workspace = true
pep440_rs = { path = "../pep440-rs", features = ["serde"] }
pep508_rs = { path = "../pep508-rs", features = ["serde"] }
puffin-normalize = { path = "../puffin-normalize" }
puffin-macros = { path = "../puffin-macros" }
puffin-warnings = { path = "../puffin-warnings" }
chrono = { workspace = true, features = ["serde"] }
mailparse = { workspace = true }

View file

@ -6,7 +6,7 @@ use serde::{de, Deserialize, Deserializer, Serialize};
use pep440_rs::{Pep440Error, VersionSpecifiers};
use pep508_rs::{Pep508Error, Requirement};
use puffin_macros::warn_once;
use puffin_warnings::warn_once;
/// Ex) `>=7.2.0<8.0.0`
static MISSING_COMMA: Lazy<Regex> = Lazy::new(|| Regex::new(r"(\d)([<>=~^!])").unwrap());
@ -63,8 +63,8 @@ fn parse_with_fixups<Err, T: FromStr<Err = Err>>(input: &str, type_name: &str) -
if let Ok(requirement) = T::from_str(&patched_input) {
warn_once!(
"{} to fix invalid {type_name} (before: `{input}`; after: `{patched_input}`)",
messages.join(" and ")
"Fixing invalid {type_name} by {} (before: `{input}`; after: `{patched_input}`)",
messages.join(", ")
);
return Ok(requirement);
}