From 84259f5440d3f267af0fa5348632d1ed83f8ca42 Mon Sep 17 00:00:00 2001 From: Evan Rittenhouse Date: Thu, 22 Jun 2023 10:25:20 -0500 Subject: [PATCH] Add Applicability to pycodestyle (#5282) --- .../rules/pycodestyle/rules/invalid_escape_sequence.rs | 3 +-- .../rules/logical_lines/missing_whitespace.rs | 3 +-- .../logical_lines/whitespace_before_parameters.rs | 3 +-- .../rules/missing_newline_at_end_of_file.rs | 3 +-- .../ruff__rules__pycodestyle__tests__E211_E21.py.snap | 8 ++++---- .../ruff__rules__pycodestyle__tests__E231_E23.py.snap | 10 +++++----- ...uff__rules__pycodestyle__tests__W292_W292_0.py.snap | 2 +- ...uff__rules__pycodestyle__tests__W605_W605_0.py.snap | 8 ++++---- ...uff__rules__pycodestyle__tests__W605_W605_1.py.snap | 8 ++++---- .../ruff__rules__pycodestyle__tests__w292_4.snap | 2 +- 10 files changed, 23 insertions(+), 27 deletions(-) diff --git a/crates/ruff/src/rules/pycodestyle/rules/invalid_escape_sequence.rs b/crates/ruff/src/rules/pycodestyle/rules/invalid_escape_sequence.rs index 4bd8d52ed9..792ec845ec 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/invalid_escape_sequence.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/invalid_escape_sequence.rs @@ -108,8 +108,7 @@ pub(crate) fn invalid_escape_sequence( let range = TextRange::at(location, next_char.text_len() + TextSize::from(1)); let mut diagnostic = Diagnostic::new(InvalidEscapeSequence(*next_char), range); if autofix { - #[allow(deprecated)] - diagnostic.set_fix(Fix::unspecified(Edit::insertion( + diagnostic.set_fix(Fix::automatic(Edit::insertion( r"\".to_string(), range.start() + TextSize::from(1), ))); diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs index 385ea9efe0..1c50f85e35 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/missing_whitespace.rs @@ -92,8 +92,7 @@ pub(crate) fn missing_whitespace( let mut diagnostic = Diagnostic::new(kind, token.range()); if autofix { - #[allow(deprecated)] - diagnostic.set_fix(Fix::unspecified(Edit::insertion( + diagnostic.set_fix(Fix::automatic(Edit::insertion( " ".to_string(), token.end(), ))); diff --git a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs index a65220fa74..3cb6c0694d 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/logical_lines/whitespace_before_parameters.rs @@ -65,8 +65,7 @@ pub(crate) fn whitespace_before_parameters( let mut diagnostic = Diagnostic::new(kind, TextRange::new(start, end)); if autofix { - #[allow(deprecated)] - diagnostic.set_fix(Fix::unspecified(Edit::deletion(start, end))); + diagnostic.set_fix(Fix::automatic(Edit::deletion(start, end))); } context.push_diagnostic(diagnostic); } diff --git a/crates/ruff/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs b/crates/ruff/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs index 58bb6d12c7..ea876524e4 100644 --- a/crates/ruff/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs +++ b/crates/ruff/src/rules/pycodestyle/rules/missing_newline_at_end_of_file.rs @@ -55,8 +55,7 @@ pub(crate) fn no_newline_at_end_of_file( let mut diagnostic = Diagnostic::new(MissingNewlineAtEndOfFile, range); if autofix { - #[allow(deprecated)] - diagnostic.set_fix(Fix::unspecified(Edit::insertion( + diagnostic.set_fix(Fix::automatic(Edit::insertion( stylist.line_ending().to_string(), range.start(), ))); diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E211_E21.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E211_E21.py.snap index bd71617569..594efa073b 100644 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E211_E21.py.snap +++ b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E211_E21.py.snap @@ -11,7 +11,7 @@ E21.py:2:5: E211 [*] Whitespace before '(' | = help: Removed whitespace before '(' -ℹ Suggested fix +ℹ Fix 1 1 | #: E211 2 |-spam (1) 2 |+spam(1) @@ -30,7 +30,7 @@ E21.py:4:5: E211 [*] Whitespace before '[' | = help: Removed whitespace before '[' -ℹ Suggested fix +ℹ Fix 1 1 | #: E211 2 2 | spam (1) 3 3 | #: E211 E211 @@ -51,7 +51,7 @@ E21.py:4:20: E211 [*] Whitespace before '[' | = help: Removed whitespace before '[' -ℹ Suggested fix +ℹ Fix 1 1 | #: E211 2 2 | spam (1) 3 3 | #: E211 E211 @@ -72,7 +72,7 @@ E21.py:6:12: E211 [*] Whitespace before '[' | = help: Removed whitespace before '[' -ℹ Suggested fix +ℹ Fix 3 3 | #: E211 E211 4 4 | dict ['key'] = list [index] 5 5 | #: E211 diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E231_E23.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E231_E23.py.snap index a985571437..34bd1a6274 100644 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E231_E23.py.snap +++ b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__E231_E23.py.snap @@ -11,7 +11,7 @@ E23.py:2:7: E231 [*] Missing whitespace after ',' | = help: Added missing whitespace after ',' -ℹ Suggested fix +ℹ Fix 1 1 | #: E231 2 |-a = (1,2) 2 |+a = (1, 2) @@ -30,7 +30,7 @@ E23.py:4:5: E231 [*] Missing whitespace after ',' | = help: Added missing whitespace after ',' -ℹ Suggested fix +ℹ Fix 1 1 | #: E231 2 2 | a = (1,2) 3 3 | #: E231 @@ -51,7 +51,7 @@ E23.py:6:10: E231 [*] Missing whitespace after ':' | = help: Added missing whitespace after ':' -ℹ Suggested fix +ℹ Fix 3 3 | #: E231 4 4 | a[b1,:] 5 5 | #: E231 @@ -71,7 +71,7 @@ E23.py:19:10: E231 [*] Missing whitespace after ',' | = help: Added missing whitespace after ',' -ℹ Suggested fix +ℹ Fix 16 16 | 17 17 | def foo() -> None: 18 18 | #: E231 @@ -91,7 +91,7 @@ E23.py:29:20: E231 [*] Missing whitespace after ':' | = help: Added missing whitespace after ':' -ℹ Suggested fix +ℹ Fix 26 26 | #: E231:2:20 27 27 | mdtypes_template = { 28 28 | 'tag_full': [('mdtype', 'u4'), ('byte_count', 'u4')], diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_0.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_0.py.snap index 90f1c0015d..7b67a4f6a1 100644 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_0.py.snap +++ b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W292_W292_0.py.snap @@ -9,7 +9,7 @@ W292_0.py:2:9: W292 [*] No newline at end of file | = help: Add trailing newline -ℹ Suggested fix +ℹ Fix 1 1 | def fn() -> None: 2 |- pass 2 |+ pass diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_0.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_0.py.snap index 60999dc01a..fb5b4e8950 100644 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_0.py.snap +++ b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_0.py.snap @@ -11,7 +11,7 @@ W605_0.py:2:10: W605 [*] Invalid escape sequence: `\.` | = help: Add backslash to escape sequence -ℹ Suggested fix +ℹ Fix 1 1 | #: W605:1:10 2 |-regex = '\.png$' 2 |+regex = '\\.png$' @@ -29,7 +29,7 @@ W605_0.py:6:1: W605 [*] Invalid escape sequence: `\.` | = help: Add backslash to escape sequence -ℹ Suggested fix +ℹ Fix 3 3 | 4 4 | #: W605:2:1 5 5 | regex = ''' @@ -49,7 +49,7 @@ W605_0.py:11:6: W605 [*] Invalid escape sequence: `\_` | = help: Add backslash to escape sequence -ℹ Suggested fix +ℹ Fix 8 8 | 9 9 | #: W605:2:6 10 10 | f( @@ -70,7 +70,7 @@ W605_0.py:18:6: W605 [*] Invalid escape sequence: `\_` | = help: Add backslash to escape sequence -ℹ Suggested fix +ℹ Fix 15 15 | """ 16 16 | multi-line 17 17 | literal diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_1.py.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_1.py.snap index e0e9a9371c..b6e26e233a 100644 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_1.py.snap +++ b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__W605_W605_1.py.snap @@ -11,7 +11,7 @@ W605_1.py:2:10: W605 [*] Invalid escape sequence: `\.` | = help: Add backslash to escape sequence -ℹ Suggested fix +ℹ Fix 1 1 | #: W605:1:10 2 |-regex = '\.png$' 2 |+regex = '\\.png$' @@ -29,7 +29,7 @@ W605_1.py:6:1: W605 [*] Invalid escape sequence: `\.` | = help: Add backslash to escape sequence -ℹ Suggested fix +ℹ Fix 3 3 | 4 4 | #: W605:2:1 5 5 | regex = ''' @@ -49,7 +49,7 @@ W605_1.py:11:6: W605 [*] Invalid escape sequence: `\_` | = help: Add backslash to escape sequence -ℹ Suggested fix +ℹ Fix 8 8 | 9 9 | #: W605:2:6 10 10 | f( @@ -70,7 +70,7 @@ W605_1.py:18:6: W605 [*] Invalid escape sequence: `\_` | = help: Add backslash to escape sequence -ℹ Suggested fix +ℹ Fix 15 15 | """ 16 16 | multi-line 17 17 | literal diff --git a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__w292_4.snap b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__w292_4.snap index 2b15945ea1..68d23e984d 100644 --- a/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__w292_4.snap +++ b/crates/ruff/src/rules/pycodestyle/snapshots/ruff__rules__pycodestyle__tests__w292_4.snap @@ -8,7 +8,7 @@ W292_4.py:1:2: W292 [*] No newline at end of file | = help: Add trailing newline -ℹ Suggested fix +ℹ Fix 1 |- 1 |+