Add colors to statistics output (#2699)

This commit is contained in:
Charlie Marsh 2023-02-09 19:40:29 -05:00 committed by GitHub
parent a129181407
commit 417fe4355f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -400,18 +400,21 @@ impl<'a> Printer<'a> {
.unwrap();
let any_fixable = statistics.iter().any(|statistic| statistic.fixable);
let fixable = format!("[{}] ", "*".cyan());
let unfixable = "[ ] ";
// By default, we mimic Flake8's `--statistics` format.
for statistic in statistics {
writeln!(
stdout,
"{:>count_width$}\t{:<code_width$}\t{}{}",
statistic.count,
statistic.code,
statistic.count.to_string().bold(),
statistic.code.red().bold(),
if any_fixable {
if statistic.fixable {
"[*] "
&fixable
} else {
"[ ] "
unfixable
}
} else {
""