Compare commits

...

1 Commits

Author SHA1 Message Date
Charlie Marsh
9dac0858f2 Insert blank lines before comments in E305 2024-05-23 16:42:18 -04:00
3 changed files with 30 additions and 34 deletions

View File

@@ -1009,10 +1009,10 @@ impl<'a> BlankLinesChecker<'a> {
))); )));
} else { } else {
diagnostic.set_fix(Fix::safe_edit(Edit::insertion( diagnostic.set_fix(Fix::safe_edit(Edit::insertion(
self.stylist self.stylist.line_ending().repeat(
.line_ending() (BLANK_LINES_TOP_LEVEL - line.preceding_blank_lines.count()) as usize,
.repeat(BLANK_LINES_TOP_LEVEL as usize), ),
self.locator.line_start(line.first_token_range.start()), self.locator.line_start(state.last_non_comment_line_end),
))); )));
} }

View File

@@ -11,14 +11,13 @@ E30.py:806:1: E305 [*] Expected 2 blank lines after class or function definition
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
803 803 | # comment 800 800 | def fn():
804 804 | 801 801 | print()
805 805 | # another comment 802 802 |
806 |+ 803 |+
807 |+ 803 804 | # comment
806 808 | fn() 804 805 |
807 809 | # end 805 806 | # another comment
808 810 |
E30.py:817:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) E30.py:817:1: E305 [*] Expected 2 blank lines after class or function definition, found (1)
| |
@@ -30,14 +29,13 @@ E30.py:817:1: E305 [*] Expected 2 blank lines after class or function definition
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
814 814 | # comment 811 811 | class Class():
815 815 | 812 812 | pass
816 816 | # another comment 813 813 |
817 |+ 814 |+
818 |+ 814 815 | # comment
817 819 | a = 1 815 816 |
818 820 | # end 816 817 | # another comment
819 821 |
E30.py:829:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) E30.py:829:1: E305 [*] Expected 2 blank lines after class or function definition, found (1)
| |
@@ -70,14 +68,13 @@ E30.py:841:1: E305 [*] Expected 2 blank lines after class or function definition
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
837 837 | def a():
838 838 | print() 838 838 | print()
839 839 | 839 839 |
840 840 | # Two spaces before comments, too. 840 |+
841 |+ 840 841 | # Two spaces before comments, too.
842 |+ 841 842 | if a():
841 843 | if a(): 842 843 | a()
842 844 | a()
843 845 | # end
E30.py:854:1: E305 [*] Expected 2 blank lines after class or function definition, found (1) E30.py:854:1: E305 [*] Expected 2 blank lines after class or function definition, found (1)
| |

View File

@@ -12,11 +12,10 @@ E30.ipynb:55:1: E305 [*] Expected 2 blank lines after class or function definiti
= help: Add missing blank line(s) = help: Add missing blank line(s)
Safe fix Safe fix
52 52 | # comment 49 49 | def fn():
53 53 | 50 50 | print()
54 54 | # another comment 51 51 |
55 |+ 52 |+
56 |+ 52 53 | # comment
55 57 | fn() 53 54 |
56 58 | # end 54 55 | # another comment
57 59 | # E306:3:5