Skip to content

Commit

Permalink
Add Applicability to pycodestyle (#5282)
Browse files Browse the repository at this point in the history
  • Loading branch information
evanrittenhouse committed Jun 22, 2023
1 parent e8ebe0a commit 84259f5
Show file tree
Hide file tree
Showing 10 changed files with 23 additions and 27 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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),
)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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')],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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$'
Expand All @@ -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 = '''
Expand All @@ -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(
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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$'
Expand All @@ -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 = '''
Expand All @@ -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(
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 |+

Expand Down

0 comments on commit 84259f5

Please sign in to comment.