Add support for reformatting byte strings (#3176)
This commit is contained in:
@@ -37,6 +37,7 @@ impl Format<ASTFormatContext<'_>> for StringLiteralPart {
|
||||
}
|
||||
}
|
||||
|
||||
// Retain raw prefixes.
|
||||
let mut is_raw = false;
|
||||
if leading_quote.contains('r') {
|
||||
is_raw = true;
|
||||
@@ -46,6 +47,11 @@ impl Format<ASTFormatContext<'_>> for StringLiteralPart {
|
||||
f.write_element(FormatElement::StaticText { text: "R" })?;
|
||||
}
|
||||
|
||||
// Normalize bytes literals to use b"...".
|
||||
if leading_quote.contains('b') || leading_quote.contains('B') {
|
||||
f.write_element(FormatElement::StaticText { text: "b" })?;
|
||||
}
|
||||
|
||||
if trailing_quote.len() == 1 {
|
||||
// Single-quoted string.
|
||||
if dquotes == 0 || squotes > 0 {
|
||||
|
||||
Reference in New Issue
Block a user