From 54838914be6c4038d11c03ad7f6768030070c668 Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Mon, 8 Jan 2024 03:54:57 -0500 Subject: [PATCH 01/26] Migrate back to `owo-colors` (#824) In the past, I moved us to `owo-colors` (https://github.com/astral-sh/puffin/pull/121); then, we moved back, because we ran into issues with overriding the settings to force-disable colors. But `anstream` solved those problems, so I'm moving us _back_ to `owo-colors`, since it's what `anstream` recommends, and it's already used by many of our dependencies (`miette`, `configparser`). --------- Co-authored-by: konstin --- Cargo.lock | 19 +++----- Cargo.toml | 2 +- crates/puffin-cli/Cargo.toml | 2 +- crates/puffin-cli/src/commands/clean.rs | 20 +++------ crates/puffin-cli/src/commands/freeze.rs | 2 +- crates/puffin-cli/src/commands/pip_compile.rs | 2 +- crates/puffin-cli/src/commands/pip_install.rs | 3 +- crates/puffin-cli/src/commands/pip_sync.rs | 2 +- .../puffin-cli/src/commands/pip_uninstall.rs | 2 +- crates/puffin-cli/src/commands/reporters.rs | 2 +- crates/puffin-cli/src/commands/venv.rs | 6 +-- crates/puffin-cli/src/main.rs | 2 +- crates/puffin-dev/Cargo.toml | 8 ++-- crates/puffin-dev/src/main.rs | 2 +- crates/puffin-resolver/Cargo.toml | 3 +- crates/puffin-resolver/src/pubgrub/report.rs | 14 +++--- crates/puffin-resolver/src/resolution.rs | 2 +- crates/puffin-resolver/tests/resolver.rs | 43 +++++++++++-------- crates/puffin-warnings/Cargo.toml | 2 +- crates/puffin-warnings/src/lib.rs | 15 +++---- 20 files changed, 72 insertions(+), 81 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index da13d5e4c..875690f2a 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -563,16 +563,6 @@ version = "1.0.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "acbf1af155f9b9ef647e42cdc158db4b64a1b61f743629225fde6f3e0be2a7c7" -[[package]] -name = "colored" -version = "2.1.0" -source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cbf2150cce219b664a8a70df7a1f933836724b503f8a413af9365b4dcc4d90b8" -dependencies = [ - "lazy_static", - "windows-sys 0.48.0", -] - [[package]] name = "configparser" version = "3.0.4" @@ -2325,7 +2315,6 @@ dependencies = [ "bitflags 2.4.1", "chrono", "clap", - "colored", "distribution-filename", "distribution-types", "fs-err", @@ -2339,6 +2328,7 @@ dependencies = [ "itertools 0.12.0", "miette", "mimalloc", + "owo-colors", "pep440_rs 0.3.12", "pep508_rs", "platform-host", @@ -2423,7 +2413,6 @@ dependencies = [ "anyhow", "chrono", "clap", - "colored", "distribution-filename", "distribution-types", "fs-err", @@ -2433,6 +2422,7 @@ dependencies = [ "install-wheel-rs", "itertools 0.12.0", "mimalloc", + "owo-colors", "pep440_rs 0.3.12", "pep508_rs", "petgraph", @@ -2635,12 +2625,12 @@ dependencies = [ name = "puffin-resolver" version = "0.0.1" dependencies = [ + "anstream", "anyhow", "bitflags 2.4.1", "cache-key", "chrono", "clap", - "colored", "derivative", "distribution-filename", "distribution-types", @@ -2652,6 +2642,7 @@ dependencies = [ "install-wheel-rs", "itertools 0.12.0", "once_cell", + "owo-colors", "pep440_rs 0.3.12", "pep508_rs", "petgraph", @@ -2701,8 +2692,8 @@ name = "puffin-warnings" version = "0.0.1" dependencies = [ "anstream", - "colored", "once_cell", + "owo-colors", "rustc-hash", ] diff --git a/Cargo.toml b/Cargo.toml index cf840ad22..4e13fd341 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -24,7 +24,6 @@ camino = { version = "1.1.6", features = ["serde1"] } cargo-util = { version = "0.2.8" } chrono = { version = "0.4.31" } clap = { version = "4.4.13" } -colored = { version = "2.1.0" } configparser = { version = "3.0.4" } csv = { version = "1.3.0" } data-encoding = { version = "2.5.0" } @@ -49,6 +48,7 @@ mailparse = { version = "0.14.0" } # For additional textwrap options: https://github.com/zkat/miette/pull/321, https://github.com/zkat/miette/pull/328 miette = { git = "https://github.com/zkat/miette.git", rev = "b0744462adbbfbb6d845f382db36be883c7f3c45" } once_cell = { version = "1.19.0" } +owo-colors = { version = "3.5.0" } petgraph = { version = "0.6.4" } platform-info = { version = "2.0.2" } plist = { version = "1.6.0" } diff --git a/crates/puffin-cli/Cargo.toml b/crates/puffin-cli/Cargo.toml index bc90f1638..2297c7e2d 100644 --- a/crates/puffin-cli/Cargo.toml +++ b/crates/puffin-cli/Cargo.toml @@ -45,12 +45,12 @@ anyhow = { workspace = true } bitflags = { workspace = true } chrono = { workspace = true } clap = { workspace = true, features = ["derive"] } -colored = { workspace = true } fs-err = { workspace = true, features = ["tokio"] } futures = { workspace = true } indicatif = { workspace = true } itertools = { workspace = true } miette = { workspace = true, features = ["fancy"] } +owo-colors = { workspace = true } pubgrub = { workspace = true } pyproject-toml = { workspace = true } rustc-hash = { workspace = true } diff --git a/crates/puffin-cli/src/commands/clean.rs b/crates/puffin-cli/src/commands/clean.rs index 2ebbf6226..173d1090d 100644 --- a/crates/puffin-cli/src/commands/clean.rs +++ b/crates/puffin-cli/src/commands/clean.rs @@ -1,8 +1,8 @@ use std::fmt::Write; use anyhow::{Context, Result}; -use colored::Colorize; use fs_err as fs; +use owo_colors::OwoColorize; use puffin_cache::Cache; use puffin_normalize::PackageName; @@ -20,7 +20,7 @@ pub(crate) fn clean( writeln!( printer, "No cache found at: {}", - format!("{}", cache.root().display()).cyan() + cache.root().display().cyan() )?; return Ok(ExitStatus::Success); } @@ -29,7 +29,7 @@ pub(crate) fn clean( writeln!( printer, "Clearing cache at: {}", - format!("{}", cache.root().display()).cyan() + cache.root().display().cyan() )?; fs::remove_dir_all(cache.root()) .with_context(|| format!("Failed to clear cache at: {}", cache.root().display()))?; @@ -37,20 +37,12 @@ pub(crate) fn clean( for package in packages { let count = cache.purge(package)?; match count { - 0 => writeln!( - printer, - "No entries found for package: {}", - format!("{package}").cyan() - )?, - 1 => writeln!( - printer, - "Cleared 1 entry for package: {}", - format!("{package}").cyan() - )?, + 0 => writeln!(printer, "No entries found for package: {}", package.cyan())?, + 1 => writeln!(printer, "Cleared 1 entry for package: {}", package.cyan())?, count => writeln!( printer, "Cleared {count} entries for package: {}", - format!("{package}").cyan() + package.cyan() )?, } } diff --git a/crates/puffin-cli/src/commands/freeze.rs b/crates/puffin-cli/src/commands/freeze.rs index 01de6e9ab..7a9d0896f 100644 --- a/crates/puffin-cli/src/commands/freeze.rs +++ b/crates/puffin-cli/src/commands/freeze.rs @@ -1,8 +1,8 @@ use std::fmt::Write; use anyhow::Result; -use colored::Colorize; use itertools::Itertools; +use owo_colors::OwoColorize; use tracing::debug; use distribution_types::Name; diff --git a/crates/puffin-cli/src/commands/pip_compile.rs b/crates/puffin-cli/src/commands/pip_compile.rs index 336eb0267..c6c544ccb 100644 --- a/crates/puffin-cli/src/commands/pip_compile.rs +++ b/crates/puffin-cli/src/commands/pip_compile.rs @@ -8,8 +8,8 @@ use std::str::FromStr; use anstream::AutoStream; use anyhow::{anyhow, Context, Result}; use chrono::{DateTime, Utc}; -use colored::Colorize; use itertools::Itertools; +use owo_colors::OwoColorize; use tempfile::tempdir_in; use tracing::debug; diff --git a/crates/puffin-cli/src/commands/pip_install.rs b/crates/puffin-cli/src/commands/pip_install.rs index 77fe01572..7f308d40d 100644 --- a/crates/puffin-cli/src/commands/pip_install.rs +++ b/crates/puffin-cli/src/commands/pip_install.rs @@ -2,10 +2,11 @@ use std::env; use std::fmt::Write; use std::path::Path; +use anstream::eprint; use anyhow::{anyhow, Context, Result}; use chrono::{DateTime, Utc}; -use colored::Colorize; use itertools::Itertools; +use owo_colors::OwoColorize; use tempfile::tempdir_in; use tracing::debug; diff --git a/crates/puffin-cli/src/commands/pip_sync.rs b/crates/puffin-cli/src/commands/pip_sync.rs index b87d558fd..ad7e1b2a1 100644 --- a/crates/puffin-cli/src/commands/pip_sync.rs +++ b/crates/puffin-cli/src/commands/pip_sync.rs @@ -1,8 +1,8 @@ use std::fmt::Write; use anyhow::{Context, Result}; -use colored::Colorize; use itertools::Itertools; +use owo_colors::OwoColorize; use tracing::debug; use distribution_types::{IndexUrls, InstalledMetadata, LocalDist, LocalEditable, Name}; diff --git a/crates/puffin-cli/src/commands/pip_uninstall.rs b/crates/puffin-cli/src/commands/pip_uninstall.rs index e3736a629..c1856055f 100644 --- a/crates/puffin-cli/src/commands/pip_uninstall.rs +++ b/crates/puffin-cli/src/commands/pip_uninstall.rs @@ -1,7 +1,7 @@ use std::fmt::Write; use anyhow::Result; -use colored::Colorize; +use owo_colors::OwoColorize; use tracing::debug; use distribution_types::{InstalledMetadata, Name}; diff --git a/crates/puffin-cli/src/commands/reporters.rs b/crates/puffin-cli/src/commands/reporters.rs index 2f293d45b..69ad97fda 100644 --- a/crates/puffin-cli/src/commands/reporters.rs +++ b/crates/puffin-cli/src/commands/reporters.rs @@ -1,8 +1,8 @@ use std::sync::{Arc, Mutex}; use std::time::Duration; -use colored::Colorize; use indicatif::{MultiProgress, ProgressBar, ProgressStyle}; +use owo_colors::OwoColorize; use url::Url; use distribution_types::{ diff --git a/crates/puffin-cli/src/commands/venv.rs b/crates/puffin-cli/src/commands/venv.rs index 4c2418d93..e3d18ecde 100644 --- a/crates/puffin-cli/src/commands/venv.rs +++ b/crates/puffin-cli/src/commands/venv.rs @@ -2,9 +2,9 @@ use std::fmt::Write; use std::path::{Path, PathBuf}; use anyhow::Result; -use colored::Colorize; use fs_err as fs; use miette::{Diagnostic, IntoDiagnostic}; +use owo_colors::OwoColorize; use thiserror::Error; use platform_host::Platform; @@ -84,14 +84,14 @@ fn venv_impl( printer, "Using Python {} at {}", interpreter.version(), - format!("{}", interpreter.sys_executable().display()).cyan() + interpreter.sys_executable().display().cyan() ) .into_diagnostic()?; writeln!( printer, "Creating virtual environment at: {}", - format!("{}", path.display()).cyan() + path.display().cyan() ) .into_diagnostic()?; diff --git a/crates/puffin-cli/src/main.rs b/crates/puffin-cli/src/main.rs index 5520e3efe..bcf456ae7 100644 --- a/crates/puffin-cli/src/main.rs +++ b/crates/puffin-cli/src/main.rs @@ -6,7 +6,7 @@ use anstream::eprintln; use anyhow::Result; use chrono::{DateTime, Days, NaiveDate, NaiveTime, Utc}; use clap::{Args, Parser, Subcommand}; -use colored::Colorize; +use owo_colors::OwoColorize; use distribution_types::{IndexUrl, IndexUrls}; use puffin_cache::{Cache, CacheArgs}; diff --git a/crates/puffin-dev/Cargo.toml b/crates/puffin-dev/Cargo.toml index 175202e66..f016533e0 100644 --- a/crates/puffin-dev/Cargo.toml +++ b/crates/puffin-dev/Cargo.toml @@ -38,11 +38,11 @@ anstream = { workspace = true } anyhow = { workspace = true } chrono = { workspace = true } clap = { workspace = true, features = ["derive"] } -colored = { workspace = true } fs-err = { workspace = true } futures = { workspace = true } indicatif = { workspace = true } itertools = { workspace = true } +owo-colors = { workspace = true } petgraph = { workspace = true } rustc-hash = { workspace = true } tempfile = { workspace = true } @@ -50,11 +50,11 @@ tokio = { workspace = true } tracing = { workspace = true } tracing-indicatif = { workspace = true } tracing-subscriber = { workspace = true } -which = { workspace = true } url = { workspace = true } +which = { workspace = true } [target.'cfg(target_os = "windows")'.dependencies] -mimalloc = "0.1.39" +mimalloc = { version = "0.1.39" } [target.'cfg(all(not(target_os = "windows"), not(target_os = "openbsd"), any(target_arch = "x86_64", target_arch = "aarch64", target_arch = "powerpc64")))'.dependencies] -tikv-jemallocator = "0.5.4" +tikv-jemallocator = { version = "0.5.4" } diff --git a/crates/puffin-dev/src/main.rs b/crates/puffin-dev/src/main.rs index 433587d05..c32c9e052 100644 --- a/crates/puffin-dev/src/main.rs +++ b/crates/puffin-dev/src/main.rs @@ -7,7 +7,7 @@ use std::time::Instant; use anstream::eprintln; use anyhow::Result; use clap::Parser; -use colored::Colorize; +use owo_colors::OwoColorize; use tracing::debug; use tracing_indicatif::IndicatifLayer; use tracing_subscriber::layer::SubscriberExt; diff --git a/crates/puffin-resolver/Cargo.toml b/crates/puffin-resolver/Cargo.toml index 8a1fdf9a2..7f0705503 100644 --- a/crates/puffin-resolver/Cargo.toml +++ b/crates/puffin-resolver/Cargo.toml @@ -32,17 +32,18 @@ puffin-traits = { path = "../puffin-traits" } pypi-types = { path = "../pypi-types" } requirements-txt = { path = "../requirements-txt" } +anstream = { workspace = true } anyhow = { workspace = true } bitflags = { workspace = true } chrono = { workspace = true } clap = { workspace = true, features = ["derive"], optional = true } -colored = { workspace = true } derivative = { workspace = true } fs-err = { workspace = true, features = ["tokio"] } futures = { workspace = true } http-cache-semantics = { workspace = true } itertools = { workspace = true } once_cell = { workspace = true } +owo-colors = { workspace = true } petgraph = { workspace = true } pubgrub = { workspace = true } reqwest = { workspace = true } diff --git a/crates/puffin-resolver/src/pubgrub/report.rs b/crates/puffin-resolver/src/pubgrub/report.rs index e736f1058..237a39c6c 100644 --- a/crates/puffin-resolver/src/pubgrub/report.rs +++ b/crates/puffin-resolver/src/pubgrub/report.rs @@ -1,13 +1,15 @@ -use crate::candidate_selector::CandidateSelector; -use crate::prerelease_mode::PreReleaseStrategy; -use colored::Colorize; +use std::borrow::Cow; + use derivative::Derivative; +use owo_colors::OwoColorize; use pubgrub::range::Range; use pubgrub::report::{DerivationTree, External, ReportFormatter}; use pubgrub::term::Term; use pubgrub::type_aliases::Map; use rustc_hash::{FxHashMap, FxHashSet}; -use std::borrow::Cow; + +use crate::candidate_selector::CandidateSelector; +use crate::prerelease_mode::PreReleaseStrategy; use super::{PubGrubPackage, PubGrubVersion}; @@ -223,8 +225,8 @@ impl std::fmt::Display for PubGrubHint { "{}{} {} was requested with a pre-release marker (e.g., {}), but pre-releases weren't enabled (try: `--prerelease=allow`)", "hint".bold().cyan(), ":".bold(), - format!("{package}").bold(), - format!("{range}").bold(), + package.bold(), + range.bold() ) } } diff --git a/crates/puffin-resolver/src/resolution.rs b/crates/puffin-resolver/src/resolution.rs index e9c4fb3a8..d9ffa0eb4 100644 --- a/crates/puffin-resolver/src/resolution.rs +++ b/crates/puffin-resolver/src/resolution.rs @@ -1,7 +1,7 @@ use std::hash::BuildHasherDefault; use anyhow::Result; -use colored::Colorize; +use owo_colors::OwoColorize; use petgraph::visit::EdgeRef; use petgraph::Direction; use pubgrub::range::Range; diff --git a/crates/puffin-resolver/tests/resolver.rs b/crates/puffin-resolver/tests/resolver.rs index 5272694c0..8e15cfcb2 100644 --- a/crates/puffin-resolver/tests/resolver.rs +++ b/crates/puffin-resolver/tests/resolver.rs @@ -114,6 +114,13 @@ async fn resolve( Ok(resolver.resolve().await?) } +macro_rules! assert_snapshot { + ($value:expr, @$snapshot:literal) => { + let snapshot = anstream::adapter::strip_str(&format!("{}", $value)).to_string(); + insta::assert_snapshot!(&snapshot, @$snapshot) + }; +} + #[tokio::test] async fn black() -> Result<()> { let manifest = Manifest::simple(vec![Requirement::from_str("black<=23.9.1").unwrap()]); @@ -125,7 +132,7 @@ async fn black() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_311, &TAGS_311).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" black==23.9.1 click==8.1.7 # via black @@ -155,7 +162,7 @@ async fn black_colorama() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_311, &TAGS_311).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" black==23.9.1 click==8.1.7 # via black @@ -187,7 +194,7 @@ async fn black_tensorboard() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_311, &TAGS_311).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" black==23.9.1 click==8.1.7 # via black @@ -215,7 +222,7 @@ async fn black_python_310() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_310, &TAGS_310).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" black==23.9.1 click==8.1.7 # via black @@ -256,7 +263,7 @@ async fn black_mypy_extensions() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_311, &TAGS_311).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" black==23.9.1 click==8.1.7 # via black @@ -293,7 +300,7 @@ async fn black_mypy_extensions_extra() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_311, &TAGS_311).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" black==23.9.1 click==8.1.7 # via black @@ -330,7 +337,7 @@ async fn black_flake8() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_311, &TAGS_311).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" black==23.9.1 click==8.1.7 # via black @@ -358,7 +365,7 @@ async fn black_lowest() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_311, &TAGS_311).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" black==22.1.0 click==8.0.0 # via black @@ -386,7 +393,7 @@ async fn black_lowest_direct() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_311, &TAGS_311).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" black==22.1.0 click==8.1.7 # via black @@ -421,7 +428,7 @@ async fn black_respect_preference() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_311, &TAGS_311).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" black==23.9.0 click==8.1.7 # via black @@ -456,7 +463,7 @@ async fn black_ignore_preference() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_311, &TAGS_311).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" black==23.9.1 click==8.1.7 # via black @@ -486,7 +493,7 @@ async fn black_disallow_prerelease() -> Result<()> { .await .unwrap_err(); - insta::assert_display_snapshot!(err, @"Because there is no version of black available matching <=20.0 and root depends on black<=20.0, version solving failed."); + assert_snapshot!(err, @"Because there is no version of black available matching <=20.0 and root depends on black<=20.0, version solving failed."); Ok(()) } @@ -504,7 +511,7 @@ async fn black_allow_prerelease_if_necessary() -> Result<()> { .await .unwrap_err(); - insta::assert_display_snapshot!(err, @"Because there is no version of black available matching <=20.0 and root depends on black<=20.0, version solving failed."); + assert_snapshot!(err, @"Because there is no version of black available matching <=20.0 and root depends on black<=20.0, version solving failed."); Ok(()) } @@ -520,7 +527,7 @@ async fn pylint_disallow_prerelease() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_311, &TAGS_311).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" astroid==3.0.1 # via pylint isort==5.12.0 @@ -544,7 +551,7 @@ async fn pylint_allow_prerelease() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_311, &TAGS_311).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" astroid==3.0.1 # via pylint isort==6.0.0b2 @@ -571,7 +578,7 @@ async fn pylint_allow_explicit_prerelease_without_marker() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_311, &TAGS_311).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" astroid==3.0.1 # via pylint isort==5.12.0 @@ -598,7 +605,7 @@ async fn pylint_allow_explicit_prerelease_with_marker() -> Result<()> { let resolution = resolve(manifest, options, &MARKERS_311, &TAGS_311).await?; - insta::assert_display_snapshot!(resolution, @r###" + assert_snapshot!(resolution, @r###" astroid==3.0.1 # via pylint isort==6.0.0b2 @@ -626,7 +633,7 @@ async fn msgraph_sdk() -> Result<()> { .await .unwrap_err(); - insta::assert_display_snapshot!(err, @r###" + assert_snapshot!(err, @r###" Because there is no version of msgraph-core available matching >=1.0.0a2 and msgraph-sdk==1.0.0 depends on msgraph-core>=1.0.0a2, msgraph-sdk==1.0.0 is forbidden. And because root depends on msgraph-sdk==1.0.0, version solving failed. diff --git a/crates/puffin-warnings/Cargo.toml b/crates/puffin-warnings/Cargo.toml index aec343681..0d84af01d 100644 --- a/crates/puffin-warnings/Cargo.toml +++ b/crates/puffin-warnings/Cargo.toml @@ -14,6 +14,6 @@ workspace = true [dependencies] anstream = { workspace = true } -colored = { workspace = true } once_cell = { workspace = true } +owo-colors = { workspace = true } rustc-hash = { workspace = true } diff --git a/crates/puffin-warnings/src/lib.rs b/crates/puffin-warnings/src/lib.rs index 116c61dd9..437149c41 100644 --- a/crates/puffin-warnings/src/lib.rs +++ b/crates/puffin-warnings/src/lib.rs @@ -4,11 +4,9 @@ use std::sync::Mutex; // macro hygiene: The user might not have direct dependencies on those crates #[doc(hidden)] pub use anstream; - -#[doc(hidden)] -pub use colored; - use once_cell::sync::Lazy; +#[doc(hidden)] +pub use owo_colors; use rustc_hash::FxHashSet; /// Whether user-facing warnings are enabled. @@ -24,7 +22,7 @@ pub fn enable() { macro_rules! warn_user { ($($arg:tt)*) => { use $crate::anstream::eprintln; - use $crate::colored::Colorize; + use $crate::owo_colors::OwoColorize; if $crate::ENABLED.load(std::sync::atomic::Ordering::SeqCst) { let message = format!("{}", format_args!($($arg)*)); @@ -42,14 +40,13 @@ pub static WARNINGS: Lazy>> = Lazy::new(Mutex::default); macro_rules! warn_user_once { ($($arg:tt)*) => { use $crate::anstream::eprintln; - use $crate::colored::Colorize; + use $crate::owo_colors::OwoColorize; if $crate::ENABLED.load(std::sync::atomic::Ordering::SeqCst) { if let Ok(mut states) = $crate::WARNINGS.lock() { let message = format!("{}", format_args!($($arg)*)); - let formatted = message.bold(); - if states.insert(message) { - eprintln!("{}{} {formatted}", "warning".yellow().bold(), ":".bold()); + if states.insert(message.clone()) { + eprintln!("{}{} {}", "warning".yellow().bold(), ":".bold(), message.bold()); } } } From 60ba7dd14f4c61e7e615fb374d8353f8a4f0220b Mon Sep 17 00:00:00 2001 From: konsti Date: Mon, 8 Jan 2024 10:15:38 +0100 Subject: [PATCH 02/26] Use `std::io::read_to_string` (#826) The `std::io::read_to_string` shorthand was stabilized in 1.65. --- crates/install-wheel-rs/src/wheel.rs | 12 +++++------- crates/puffin-cli/tests/pip_sync.rs | 2 ++ 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/crates/install-wheel-rs/src/wheel.rs b/crates/install-wheel-rs/src/wheel.rs index d5e0c009c..98ca6e599 100644 --- a/crates/install-wheel-rs/src/wheel.rs +++ b/crates/install-wheel-rs/src/wheel.rs @@ -87,9 +87,8 @@ fn parse_scripts( ) -> Result<(Vec