Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix E221 and E222 to flag missing or extra whitespace around == operator #13890

Merged
merged 1 commit into from
Oct 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
Loading