Skip to content

Commit

Permalink
Update E306
Browse files Browse the repository at this point in the history
  • Loading branch information
hoel-bagard committed Nov 24, 2023
1 parent 9b15d8c commit 21bd298
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 50 deletions.
14 changes: 7 additions & 7 deletions crates/ruff_linter/resources/test/fixtures/pycodestyle/E30.py
Original file line number Diff line number Diff line change
Expand Up @@ -349,6 +349,13 @@ class Class:
# end


# no error
def f():
def f():
pass
# end


# E301
class Class(object):

Expand Down Expand Up @@ -656,13 +663,6 @@ def baz():
# end


# E306
def f():
def f():
pass
# end


# E306
def a():
x = 2
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -315,7 +315,6 @@ impl AlwaysFixableViolation for BlankLinesAfterFunctionOrClass {
/// Use instead:
/// ```python
/// def outer():
///
/// def inner():
/// pass
///
Expand Down Expand Up @@ -535,8 +534,8 @@ pub(crate) fn blank_lines(
&& !tracked_vars.follows_decorator
// The class's docstring can directly precede the first function.
&& !tracked_vars.follows_docstring
// Do not trigger when the def/class follows an "indenting token" (if/while/etc...), unless that "indenting token" is a def.
&& prev_indent_level.is_some_and(|prev_indent_level| prev_indent_level >= indent_level || tracked_vars.follows_def)
// Do not trigger when the def/class follows an "indenting token" (if/while/etc...).
&& prev_indent_level.is_some_and(|prev_indent_level| prev_indent_level >= indent_level)
// Allow groups of one-liners.
&& !(tracked_vars.follows_def
&& line
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -121,26 +121,6 @@ E30.py:638:5: E306 [*] Expected 1 blank line before a nested definition, found 0
639 640 | pass
640 641 | # end

E30.py:645:5: E306 [*] Expected 1 blank line before a nested definition, found 0
|
643 | # E306
644 | def foo():
645 | def bar():
| ^^^ E306
646 | pass
647 | def baz(): pass
|
= help: Add missing blank line

Safe fix
642 642 |
643 643 | # E306
644 644 | def foo():
645 |+
645 646 | def bar():
646 647 | pass
647 648 | def baz(): pass

E30.py:647:5: E306 [*] Expected 1 blank line before a nested definition, found 0
|
645 | def bar():
Expand Down Expand Up @@ -180,26 +160,6 @@ E30.py:654:5: E306 [*] Expected 1 blank line before a nested definition, found 0
655 656 | pass
656 657 | # end

E30.py:661:5: E306 [*] Expected 1 blank line before a nested definition, found 0
|
659 | # E306
660 | def f():
661 | def f():
| ^^^ E306
662 | pass
663 | # end
|
= help: Add missing blank line

Safe fix
658 658 |
659 659 | # E306
660 660 | def f():
661 |+
661 662 | def f():
662 663 | pass
663 664 | # end

E30.py:669:5: E306 [*] Expected 1 blank line before a nested definition, found 0
|
667 | def a():
Expand Down

0 comments on commit 21bd298

Please sign in to comment.