From 5305013d163fff2d9ed5677b26d34c8c1bd00d43 Mon Sep 17 00:00:00 2001 From: Phong Do Date: Tue, 16 Dec 2025 19:08:43 +0100 Subject: [PATCH] Revert "update snapshot tests" This reverts commit 99a52eba908762420c0922ff89fcb2e17884a1c9. --- Cargo.lock | 1 - .../test/fixtures/pyupgrade/UP032_0.py | 3 -- ...__rules__pyupgrade__tests__UP032_0.py.snap | 16 --------- crates/ruff_python_literal/Cargo.toml | 1 - crates/ruff_python_literal/src/format.rs | 36 ++++++++++++++++--- ...ts__format_multiple_escape_with_field.snap | 18 ---------- ..._format__tests__format_unicode_escape.snap | 13 ------- ...sts__format_unicode_escape_with_field.snap | 18 ---------- 8 files changed, 32 insertions(+), 74 deletions(-) delete mode 100644 crates/ruff_python_literal/src/snapshots/ruff_python_literal__format__tests__format_multiple_escape_with_field.snap delete mode 100644 crates/ruff_python_literal/src/snapshots/ruff_python_literal__format__tests__format_unicode_escape.snap delete mode 100644 crates/ruff_python_literal/src/snapshots/ruff_python_literal__format__tests__format_unicode_escape_with_field.snap diff --git a/Cargo.lock b/Cargo.lock index 2974fa021c..6bde255074 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -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", diff --git a/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP032_0.py b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP032_0.py index 98202cc636..53e993795b 100644 --- a/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP032_0.py +++ b/crates/ruff_linter/resources/test/fixtures/pyupgrade/UP032_0.py @@ -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) diff --git a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap index f2b5649b48..a507e2ab85 100644 --- a/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap +++ b/crates/ruff_linter/src/rules/pyupgrade/snapshots/ruff_linter__rules__pyupgrade__tests__UP032_0.py.snap @@ -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}°" diff --git a/crates/ruff_python_literal/Cargo.toml b/crates/ruff_python_literal/Cargo.toml index f39e2c23f4..3e2ffb0914 100644 --- a/crates/ruff_python_literal/Cargo.toml +++ b/crates/ruff_python_literal/Cargo.toml @@ -22,7 +22,6 @@ itertools = { workspace = true } unic-ucd-category = { workspace = true } [dev-dependencies] -insta = { workspace = true } [lints] workspace = true diff --git a/crates/ruff_python_literal/src/format.rs b/crates/ruff_python_literal/src/format.rs index a94f4d587c..687694c8bc 100644 --- a/crates/ruff_python_literal/src/format.rs +++ b/crates/ruff_python_literal/src/format.rs @@ -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); } } diff --git a/crates/ruff_python_literal/src/snapshots/ruff_python_literal__format__tests__format_multiple_escape_with_field.snap b/crates/ruff_python_literal/src/snapshots/ruff_python_literal__format__tests__format_multiple_escape_with_field.snap deleted file mode 100644 index 300b682529..0000000000 --- a/crates/ruff_python_literal/src/snapshots/ruff_python_literal__format__tests__format_multiple_escape_with_field.snap +++ /dev/null @@ -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: "", - }, - ], - }, -) diff --git a/crates/ruff_python_literal/src/snapshots/ruff_python_literal__format__tests__format_unicode_escape.snap b/crates/ruff_python_literal/src/snapshots/ruff_python_literal__format__tests__format_unicode_escape.snap deleted file mode 100644 index 65c72be148..0000000000 --- a/crates/ruff_python_literal/src/snapshots/ruff_python_literal__format__tests__format_unicode_escape.snap +++ /dev/null @@ -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}", - ), - ], - }, -) diff --git a/crates/ruff_python_literal/src/snapshots/ruff_python_literal__format__tests__format_unicode_escape_with_field.snap b/crates/ruff_python_literal/src/snapshots/ruff_python_literal__format__tests__format_unicode_escape_with_field.snap deleted file mode 100644 index 236e498e75..0000000000 --- a/crates/ruff_python_literal/src/snapshots/ruff_python_literal__format__tests__format_unicode_escape_with_field.snap +++ /dev/null @@ -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: "", - }, - ], - }, -)