mirror of https://github.com/astral-sh/ruff
parent
0cfca59908
commit
5305013d16
|
|
@ -3333,7 +3333,6 @@ name = "ruff_python_literal"
|
|||
version = "0.0.0"
|
||||
dependencies = [
|
||||
"bitflags 2.10.0",
|
||||
"insta",
|
||||
"itertools 0.14.0",
|
||||
"ruff_python_ast",
|
||||
"unic-ucd-category",
|
||||
|
|
|
|||
|
|
@ -276,6 +276,3 @@ if __name__ == "__main__":
|
|||
number = 0
|
||||
string = "{}".format(number := number + 1)
|
||||
print(string)
|
||||
|
||||
# Unicode escape
|
||||
"\N{angle}AOB = {angle}°".format(angle=180)
|
||||
|
|
|
|||
|
|
@ -1368,19 +1368,3 @@ help: Convert to f-string
|
|||
- string = "{}".format(number := number + 1)
|
||||
277 + string = f"{(number := number + 1)}"
|
||||
278 | print(string)
|
||||
279 |
|
||||
280 | # Unicode escape
|
||||
|
||||
UP032 [*] Use f-string instead of `format` call
|
||||
--> UP032_0.py:281:1
|
||||
|
|
||||
280 | # Unicode escape
|
||||
281 | "\N{angle}AOB = {angle}°".format(angle=180)
|
||||
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
|
||||
help: Convert to f-string
|
||||
278 | print(string)
|
||||
279 |
|
||||
280 | # Unicode escape
|
||||
- "\N{angle}AOB = {angle}°".format(angle=180)
|
||||
281 + f"\N{angle}AOB = {180}°"
|
||||
|
|
|
|||
|
|
@ -22,7 +22,6 @@ itertools = { workspace = true }
|
|||
unic-ucd-category = { workspace = true }
|
||||
|
||||
[dev-dependencies]
|
||||
insta = { workspace = true }
|
||||
|
||||
[lints]
|
||||
workspace = true
|
||||
|
|
|
|||
|
|
@ -729,7 +729,6 @@ impl<'a> FromTemplate<'a> for FormatString {
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
use insta::assert_debug_snapshot;
|
||||
|
||||
#[test]
|
||||
fn test_fill_and_align() {
|
||||
|
|
@ -1043,16 +1042,45 @@ mod tests {
|
|||
|
||||
#[test]
|
||||
fn test_format_unicode_escape() {
|
||||
assert_debug_snapshot!(FormatString::from_str("I am a \\N{snowman}"));
|
||||
let expected = Ok(FormatString {
|
||||
format_parts: vec![FormatPart::Literal("I am a \\N{snowman}".to_owned())],
|
||||
});
|
||||
|
||||
assert_eq!(FormatString::from_str("I am a \\N{snowman}"), expected);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_unicode_escape_with_field() {
|
||||
assert_debug_snapshot!(FormatString::from_str("I am a \\N{snowman}{snowman}"))
|
||||
let expected = Ok(FormatString {
|
||||
format_parts: vec![
|
||||
FormatPart::Literal("I am a \\N{snowman}".to_owned()),
|
||||
FormatPart::Field {
|
||||
field_name: "snowman".to_owned(),
|
||||
conversion_spec: None,
|
||||
format_spec: String::new(),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
assert_eq!(
|
||||
FormatString::from_str("I am a \\N{snowman}{snowman}"),
|
||||
expected
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn test_format_multiple_escape_with_field() {
|
||||
assert_debug_snapshot!(FormatString::from_str("I am a \\\\N{snowman}"));
|
||||
let expected = Ok(FormatString {
|
||||
format_parts: vec![
|
||||
FormatPart::Literal("I am a \\\\N".to_owned()),
|
||||
FormatPart::Field {
|
||||
field_name: "snowman".to_owned(),
|
||||
conversion_spec: None,
|
||||
format_spec: String::new(),
|
||||
},
|
||||
],
|
||||
});
|
||||
|
||||
assert_eq!(FormatString::from_str("I am a \\\\N{snowman}"), expected);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1,18 +0,0 @@
|
|||
---
|
||||
source: crates/ruff_python_literal/src/format.rs
|
||||
expression: "FormatString::from_str(\"I am a \\\\\\\\N{snowman}\")"
|
||||
---
|
||||
Ok(
|
||||
FormatString {
|
||||
format_parts: [
|
||||
Literal(
|
||||
"I am a \\\\N",
|
||||
),
|
||||
Field {
|
||||
field_name: "snowman",
|
||||
conversion_spec: None,
|
||||
format_spec: "",
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
||||
|
|
@ -1,13 +0,0 @@
|
|||
---
|
||||
source: crates/ruff_python_literal/src/format.rs
|
||||
expression: "FormatString::from_str(\"I am a \\\\N{snowman}\")"
|
||||
---
|
||||
Ok(
|
||||
FormatString {
|
||||
format_parts: [
|
||||
Literal(
|
||||
"I am a \\N{snowman}",
|
||||
),
|
||||
],
|
||||
},
|
||||
)
|
||||
|
|
@ -1,18 +0,0 @@
|
|||
---
|
||||
source: crates/ruff_python_literal/src/format.rs
|
||||
expression: "FormatString::from_str(\"I am a \\\\N{snowman}{snowman}\")"
|
||||
---
|
||||
Ok(
|
||||
FormatString {
|
||||
format_parts: [
|
||||
Literal(
|
||||
"I am a \\N{snowman}",
|
||||
),
|
||||
Field {
|
||||
field_name: "snowman",
|
||||
conversion_spec: None,
|
||||
format_spec: "",
|
||||
},
|
||||
],
|
||||
},
|
||||
)
|
||||
Loading…
Reference in New Issue