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 fd65c70
Show file tree
Hide file tree
Showing 8 changed files with 433 additions and 474 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
@@ -1,44 +1,44 @@
---
source: crates/ruff_linter/src/rules/pycodestyle/mod.rs
---
E30.py:357:5: E301 [*] Expected 1 blank line, found 0
E30.py:364:5: E301 [*] Expected 1 blank line, found 0
|
355 | def func1():
356 | pass
357 | def func2():
362 | def func1():
363 | pass
364 | def func2():
| ^^^ E301
358 | pass
359 | # end
365 | pass
366 | # end
|
= help: Add missing blank line(s)

Safe fix
354 354 |
355 355 | def func1():
356 356 | pass
357 |+
357 358 | def func2():
358 359 | pass
359 360 | # end
361 361 |
362 362 | def func1():
363 363 | pass
364 |+
364 365 | def func2():
365 366 | pass
366 367 | # end

E30.py:368:5: E301 [*] Expected 1 blank line, found 0
E30.py:375:5: E301 [*] Expected 1 blank line, found 0
|
366 | pass
367 | # comment
368 | def fn2():
373 | pass
374 | # comment
375 | def fn2():
| ^^^ E301
369 | pass
370 | # end
376 | pass
377 | # end
|
= help: Add missing blank line(s)

Safe fix
364 364 |
365 365 | def fn1():
366 366 | pass
367 |+
367 368 | # comment
368 369 | def fn2():
369 370 | pass
371 371 |
372 372 | def fn1():
373 373 | pass
374 |+
374 375 | # comment
375 376 | def fn2():
376 377 | pass


Loading

0 comments on commit fd65c70

Please sign in to comment.