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 E30X panics on blank lines with trailing white spaces #9907

Merged
merged 2 commits into from
Feb 9, 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
32 changes: 32 additions & 0 deletions crates/ruff_linter/resources/test/fixtures/pycodestyle/E30.py
Original file line number Diff line number Diff line change
Expand Up @@ -436,6 +436,15 @@ def b():
# end


# no error
def test():
pass

# Wrongly indented comment
pass
# end


# E301
class Class(object):

Expand Down Expand Up @@ -534,6 +543,20 @@ def g():
# end


# E302
class Test:

pass

def method1():
return 1


def method2():
return 22
# end


# E303
def fn():
_ = None
Expand Down Expand Up @@ -648,6 +671,15 @@ def b(self):
# end


# E303
def fn():
pass


pass
# end


# E304
@decorator

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -501,7 +501,6 @@ impl BlankLines {
}
}
BlankLines::Many { count, range } => {
assert_eq!(range.end(), line_range.start());
*count = count.saturating_add(1);
*range = TextRange::new(range.start(), line_range.end());
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
---
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
---
E30.py:444:5: E301 [*] Expected 1 blank line, found 0
E30.py:453:5: E301 [*] Expected 1 blank line, found 0
|
442 | def func1():
443 | pass
444 | def func2():
451 | def func1():
452 | pass
453 | def func2():
| ^^^ E301
445 | pass
446 | # end
454 | pass
455 | # end
|
= help: Add missing blank line

ℹ Safe fix
441 441 |
442 442 | def func1():
443 443 | pass
444 |+
444 445 | def func2():
445 446 | pass
446 447 | # end
450 450 |
451 451 | def func1():
452 452 | pass
453 |+
453 454 | def func2():
454 455 | pass
455 456 | # end

E30.py:455:5: E301 [*] Expected 1 blank line, found 0
E30.py:464:5: E301 [*] Expected 1 blank line, found 0
|
453 | pass
454 | # comment
455 | def fn2():
462 | pass
463 | # comment
464 | def fn2():
| ^^^ E301
456 | pass
457 | # end
465 | pass
466 | # end
|
= help: Add missing blank line

ℹ Safe fix
451 451 |
452 452 | def fn1():
453 453 | pass
454 |+
454 455 | # comment
455 456 | def fn2():
456 457 | pass
460 460 |
461 461 | def fn1():
462 462 | pass
463 |+
463 464 | # comment
464 465 | def fn2():
465 466 | pass


Loading
Loading