From a6bb953b0893a4fefd27320d858759cd96e1711f Mon Sep 17 00:00:00 2001 From: Evan Rittenhouse Date: Wed, 21 Jun 2023 08:11:50 -0500 Subject: [PATCH 1/2] Add Applicability to pyflakes --- .../src/rules/pyflakes/rules/f_string_missing_placeholders.rs | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/crates/ruff/src/rules/pyflakes/rules/f_string_missing_placeholders.rs b/crates/ruff/src/rules/pyflakes/rules/f_string_missing_placeholders.rs index b8d04af426861..7beee3a19a94c 100644 --- a/crates/ruff/src/rules/pyflakes/rules/f_string_missing_placeholders.rs +++ b/crates/ruff/src/rules/pyflakes/rules/f_string_missing_placeholders.rs @@ -89,8 +89,7 @@ fn fix_f_string_missing_placeholders( checker: &mut Checker, ) -> Fix { let content = &checker.locator.contents()[TextRange::new(prefix_range.end(), tok_range.end())]; - #[allow(deprecated)] - Fix::unspecified(Edit::replacement( + Fix::suggested(Edit::replacement( unescape_f_string(content), prefix_range.start(), tok_range.end(), From cc8212765424585afaf57a9aca105fabeb055aff Mon Sep 17 00:00:00 2001 From: Charlie Marsh Date: Wed, 21 Jun 2023 12:58:52 -0400 Subject: [PATCH 2/2] Automatic --- .../rules/f_string_missing_placeholders.rs | 2 +- ..._rules__pyflakes__tests__F541_F541.py.snap | 30 +++++++++---------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/crates/ruff/src/rules/pyflakes/rules/f_string_missing_placeholders.rs b/crates/ruff/src/rules/pyflakes/rules/f_string_missing_placeholders.rs index 7beee3a19a94c..25171ea0eb532 100644 --- a/crates/ruff/src/rules/pyflakes/rules/f_string_missing_placeholders.rs +++ b/crates/ruff/src/rules/pyflakes/rules/f_string_missing_placeholders.rs @@ -89,7 +89,7 @@ fn fix_f_string_missing_placeholders( checker: &mut Checker, ) -> Fix { let content = &checker.locator.contents()[TextRange::new(prefix_range.end(), tok_range.end())]; - Fix::suggested(Edit::replacement( + Fix::automatic(Edit::replacement( unescape_f_string(content), prefix_range.start(), tok_range.end(), diff --git a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F541_F541.py.snap b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F541_F541.py.snap index 34c7b466fa8ce..1681859307a7d 100644 --- a/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F541_F541.py.snap +++ b/crates/ruff/src/rules/pyflakes/snapshots/ruff__rules__pyflakes__tests__F541_F541.py.snap @@ -11,7 +11,7 @@ F541.py:6:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 3 3 | b = f"ghi{'jkl'}" 4 4 | 5 5 | # Errors @@ -32,7 +32,7 @@ F541.py:7:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 4 4 | 5 5 | # Errors 6 6 | c = f"def" @@ -53,7 +53,7 @@ F541.py:9:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 6 6 | c = f"def" 7 7 | d = f"def" + "ghi" 8 8 | e = ( @@ -74,7 +74,7 @@ F541.py:13:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 10 10 | "ghi" 11 11 | ) 12 12 | f = ( @@ -95,7 +95,7 @@ F541.py:14:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 11 11 | ) 12 12 | f = ( 13 13 | f"a" @@ -116,7 +116,7 @@ F541.py:16:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 13 13 | f"a" 14 14 | F"b" 15 15 | "c" @@ -137,7 +137,7 @@ F541.py:17:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 14 14 | F"b" 15 15 | "c" 16 16 | rf"d" @@ -158,7 +158,7 @@ F541.py:19:5: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 16 16 | rf"d" 17 17 | fr"e" 18 18 | ) @@ -178,7 +178,7 @@ F541.py:25:13: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 22 22 | g = f"ghi{123:{45}}" 23 23 | 24 24 | # Error @@ -198,7 +198,7 @@ F541.py:34:7: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 31 31 | f"{f'{v:0.2f}'}" 32 32 | 33 33 | # Errors @@ -219,7 +219,7 @@ F541.py:35:4: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 32 32 | 33 33 | # Errors 34 34 | f"{v:{f'0.2f'}}" @@ -240,7 +240,7 @@ F541.py:36:1: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 33 33 | # Errors 34 34 | f"{v:{f'0.2f'}}" 35 35 | f"{f''}" @@ -261,7 +261,7 @@ F541.py:37:1: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 34 34 | f"{v:{f'0.2f'}}" 35 35 | f"{f''}" 36 36 | f"{{test}}" @@ -281,7 +281,7 @@ F541.py:38:1: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 35 35 | f"{f''}" 36 36 | f"{{test}}" 37 37 | f'{{ 40 }}' @@ -302,7 +302,7 @@ F541.py:39:1: F541 [*] f-string without any placeholders | = help: Remove extraneous `f` prefix -ℹ Suggested fix +ℹ Fix 36 36 | f"{{test}}" 37 37 | f'{{ 40 }}' 38 38 | f"{{a {{x}}"