Skip to content

Commit dea1700

Browse files
Avoid ANSI codes in debug! messages (#15843)
## Summary I spent time trying to figure out how to support this but came up empty. It _seems_ like maybe the `DefaultFields` implementation in `tracing-subscriber` uses debug formatting for fields...? So if you have a string with ANSI codes, they end up printing as unformatted values? I even reverted all our custom formatting in `logging.rs` and saw the same thing. Closes #15840.
1 parent 48f5076 commit dea1700

File tree

5 files changed

+29
-35
lines changed

5 files changed

+29
-35
lines changed

crates/uv-auth/src/middleware.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2235,7 +2235,7 @@ mod tests {
22352235
assert!(matches!(
22362236
client.get(server.uri()).send().await,
22372237
Err(reqwest_middleware::Error::Middleware(_))
2238-
),);
2238+
));
22392239

22402240
Ok(())
22412241
}

crates/uv-distribution/src/source/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1469,7 +1469,7 @@ impl<'a, T: BuildContext> SourceDistributionBuilder<'a, T> {
14691469
}
14701470
Ok(None) => {}
14711471
Err(err) => {
1472-
debug!("Failed to deserialize cached revision for: {source} ({err})",);
1472+
debug!("Failed to deserialize cached revision for: {source} ({err})");
14731473
}
14741474
}
14751475
}

crates/uv-installer/src/satisfies.rs

Lines changed: 18 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
use std::borrow::Cow;
22
use std::fmt::Debug;
33

4-
use owo_colors::OwoColorize;
54
use same_file::is_same_file;
65
use tracing::{debug, trace};
76
use url::Url;
@@ -399,18 +398,18 @@ fn generate_dist_compatibility_hint(wheel_tags: &ExpandedTags, tags: &Tags) -> O
399398

400399
if let Some(current) = current_tag {
401400
let message = if let Some(pretty) = current.pretty() {
402-
format!("{} (`{}`)", pretty.cyan(), current.cyan())
401+
format!("{pretty} (`{current}`)")
403402
} else {
404-
format!("`{}`", current.cyan())
403+
format!("`{current}`")
405404
};
406405

407406
Some(format!(
408407
"The distribution is compatible with {}, but you're using {}",
409408
wheel_tags
410409
.map(|tag| if let Some(pretty) = tag.pretty() {
411-
format!("{} (`{}`)", pretty.cyan(), tag.cyan())
410+
format!("{pretty} (`{tag}`)")
412411
} else {
413-
format!("`{}`", tag.cyan())
412+
format!("`{tag}`")
414413
})
415414
.collect::<Vec<_>>()
416415
.join(", "),
@@ -421,9 +420,9 @@ fn generate_dist_compatibility_hint(wheel_tags: &ExpandedTags, tags: &Tags) -> O
421420
"The distribution requires {}",
422421
wheel_tags
423422
.map(|tag| if let Some(pretty) = tag.pretty() {
424-
format!("{} (`{}`)", pretty.cyan(), tag.cyan())
423+
format!("{pretty} (`{tag}`)")
425424
} else {
426-
format!("`{}`", tag.cyan())
425+
format!("`{tag}`")
427426
})
428427
.collect::<Vec<_>>()
429428
.join(", ")
@@ -436,17 +435,17 @@ fn generate_dist_compatibility_hint(wheel_tags: &ExpandedTags, tags: &Tags) -> O
436435

437436
if let Some(current) = current_tag {
438437
let message = if let Some(pretty) = current.pretty() {
439-
format!("{} (`{}`)", pretty.cyan(), current.cyan())
438+
format!("{pretty} (`{current}`)")
440439
} else {
441-
format!("`{}`", current.cyan())
440+
format!("`{current}`")
442441
};
443442
Some(format!(
444443
"The distribution is compatible with {}, but you're using {}",
445444
wheel_tags
446445
.map(|tag| if let Some(pretty) = tag.pretty() {
447-
format!("{} (`{}`)", pretty.cyan(), tag.cyan())
446+
format!("{pretty} (`{tag}`)")
448447
} else {
449-
format!("`{}`", tag.cyan())
448+
format!("`{tag}`")
450449
})
451450
.collect::<Vec<_>>()
452451
.join(", "),
@@ -457,9 +456,9 @@ fn generate_dist_compatibility_hint(wheel_tags: &ExpandedTags, tags: &Tags) -> O
457456
"The distribution requires {}",
458457
wheel_tags
459458
.map(|tag| if let Some(pretty) = tag.pretty() {
460-
format!("{} (`{}`)", pretty.cyan(), tag.cyan())
459+
format!("{pretty} (`{tag}`)")
461460
} else {
462-
format!("`{}`", tag.cyan())
461+
format!("`{tag}`")
463462
})
464463
.collect::<Vec<_>>()
465464
.join(", ")
@@ -472,17 +471,17 @@ fn generate_dist_compatibility_hint(wheel_tags: &ExpandedTags, tags: &Tags) -> O
472471

473472
if let Some(current) = current_tag {
474473
let message = if let Some(pretty) = current.pretty() {
475-
format!("{} (`{}`)", pretty.cyan(), current.cyan())
474+
format!("{pretty} (`{current}`)")
476475
} else {
477-
format!("`{}`", current.cyan())
476+
format!("`{current}`")
478477
};
479478
Some(format!(
480479
"The distribution is compatible with {}, but you're on {}",
481480
wheel_tags
482481
.map(|tag| if let Some(pretty) = tag.pretty() {
483-
format!("{} (`{}`)", pretty.cyan(), tag.cyan())
482+
format!("{pretty} (`{tag}`)")
484483
} else {
485-
format!("`{}`", tag.cyan())
484+
format!("`{tag}`")
486485
})
487486
.collect::<Vec<_>>()
488487
.join(", "),
@@ -493,9 +492,9 @@ fn generate_dist_compatibility_hint(wheel_tags: &ExpandedTags, tags: &Tags) -> O
493492
"The distribution requires {}",
494493
wheel_tags
495494
.map(|tag| if let Some(pretty) = tag.pretty() {
496-
format!("{} (`{}`)", pretty.cyan(), tag.cyan())
495+
format!("{pretty} (`{tag}`)")
497496
} else {
498-
format!("`{}`", tag.cyan())
497+
format!("`{tag}`")
499498
})
500499
.collect::<Vec<_>>()
501500
.join(", ")

crates/uv-python/src/downloads.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1728,8 +1728,8 @@ mod tests {
17281728
request.version,
17291729
Some(VersionRequest::from_str("3.13.0rc1").unwrap())
17301730
);
1731-
assert_eq!(request.os, None,);
1732-
assert_eq!(request.arch, None,);
1731+
assert_eq!(request.os, None);
1732+
assert_eq!(request.arch, None);
17331733
assert_eq!(request.libc, None);
17341734
}
17351735

crates/uv/src/commands/python/install.rs

Lines changed: 7 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -312,7 +312,7 @@ pub(crate) async fn install(
312312
.peekable();
313313

314314
if matching_installations.peek().is_none() {
315-
debug!("No installation found for request `{}`", request.cyan());
315+
debug!("No installation found for request `{}`", request);
316316
unsatisfied.push(Cow::Borrowed(request));
317317
}
318318

@@ -325,7 +325,7 @@ pub(crate) async fn install(
325325
python_downloads_json_url.as_deref(),
326326
) {
327327
Ok(request) => {
328-
debug!("Will reinstall `{}`", installation.key().green());
328+
debug!("Will reinstall `{}`", installation.key());
329329
unsatisfied.push(Cow::Owned(request));
330330
}
331331
Err(err) => {
@@ -344,8 +344,8 @@ pub(crate) async fn install(
344344
// If we have real requests, just ignore the existing installation
345345
debug!(
346346
"Ignoring match `{}` for request `{}` due to `--reinstall` flag",
347-
installation.key().green(),
348-
request.cyan()
347+
installation.key(),
348+
request
349349
);
350350
unsatisfied.push(Cow::Borrowed(request));
351351
break;
@@ -366,14 +366,10 @@ pub(crate) async fn install(
366366
request.matches_installation(installation)
367367
}
368368
}) {
369-
debug!(
370-
"Found `{}` for request `{}`",
371-
installation.key().green(),
372-
request.cyan(),
373-
);
369+
debug!("Found `{}` for request `{}`", installation.key(), request);
374370
Either::Left(installation)
375371
} else {
376-
debug!("No installation found for request `{}`", request.cyan());
372+
debug!("No installation found for request `{}`", request);
377373
Either::Right(Cow::Borrowed(request))
378374
}
379375
})
@@ -394,8 +390,7 @@ pub(crate) async fn install(
394390
.inspect(|request| {
395391
debug!(
396392
"Found download `{}` for request `{}`",
397-
request.download,
398-
request.cyan(),
393+
request.download, request,
399394
);
400395
})
401396
.map(|request| request.download)

0 commit comments

Comments
 (0)