Skip to content

Commit

Permalink
Fix E221 and E222 to flag missing or extra whitespace around == ope…
Browse files Browse the repository at this point in the history
…rator (#13890)
  • Loading branch information
MichaReiser authored Oct 23, 2024
1 parent 00b0782 commit 72c18c8
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 0 deletions.
3 changes: 3 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/pycodestyle/E22.py
Original file line number Diff line number Diff line change
Expand Up @@ -180,3 +180,6 @@ def squares(n):
if i == -1:
pass
#:

if a == 1:
print(a)
Original file line number Diff line number Diff line change
Expand Up @@ -302,6 +302,7 @@ const fn is_operator_token(token: TokenKind) -> bool {
| TokenKind::Equal
| TokenKind::Percent
| TokenKind::NotEqual
| TokenKind::EqEqual
| TokenKind::LessEqual
| TokenKind::GreaterEqual
| TokenKind::CircumFlex
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,4 +168,20 @@ E22.py:19:14: E221 [*] Multiple spaces before operator
21 21 | x = 1
22 22 | y = 2

E22.py:184:5: E221 [*] Multiple spaces before operator
|
182 | #:
183 |
184 | if a == 1:
| ^^ E221
185 | print(a)
|
= help: Replace with single space

Safe fix
181 181 | pass
182 182 | #:
183 183 |
184 |-if a == 1:
184 |+if a == 1:
185 185 | print(a)
Original file line number Diff line number Diff line change
Expand Up @@ -105,4 +105,20 @@ E22.py:36:7: E222 [*] Multiple spaces after operator
38 38 | #:
39 39 |

E22.py:184:9: E222 [*] Multiple spaces after operator
|
182 | #:
183 |
184 | if a == 1:
| ^^ E222
185 | print(a)
|
= help: Replace with single space

Safe fix
181 181 | pass
182 182 | #:
183 183 |
184 |-if a == 1:
184 |+if a == 1:
185 185 | print(a)

0 comments on commit 72c18c8

Please sign in to comment.