diff options
-rwxr-xr-x | pycodestyle.py | 2 | ||||
-rw-r--r-- | testsuite/E30.py | 5 | ||||
-rw-r--r-- | testsuite/E30not.py | 10 | ||||
-rw-r--r-- | testsuite/test_blank_lines.py | 4 |
4 files changed, 12 insertions, 9 deletions
diff --git a/pycodestyle.py b/pycodestyle.py index 235532c..d2e9337 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -350,7 +350,7 @@ def blank_lines(logical_line, blank_lines, indent_level, line_number, top_level_lines = BLANK_LINES_CONFIG['top_level'] method_lines = BLANK_LINES_CONFIG['method'] - if line_number < top_level_lines + 1 and not previous_logical: + if not previous_logical and blank_before < top_level_lines: return # Don't expect blank lines before the first line if previous_logical.startswith('@'): if blank_lines: diff --git a/testsuite/E30.py b/testsuite/E30.py index 15fbdf3..8d1879b 100644 --- a/testsuite/E30.py +++ b/testsuite/E30.py @@ -16,11 +16,6 @@ class X: #: -#: E302:3:1 -#!python -# -*- coding: utf-8 -*- -def a(): - pass #: E302:2:1 """Main module.""" def _main(): diff --git a/testsuite/E30not.py b/testsuite/E30not.py index ba0f742..a86b99e 100644 --- a/testsuite/E30not.py +++ b/testsuite/E30not.py @@ -177,3 +177,13 @@ def foo(): # for no E30x being emitted. def bar(): pass def baz(): pass +#: Okay +#!python +# -*- coding: utf-8 -*- +def a(): + pass +#: Okay +def f( + a, +): + pass diff --git a/testsuite/test_blank_lines.py b/testsuite/test_blank_lines.py index 2b37ad1..e239f8b 100644 --- a/testsuite/test_blank_lines.py +++ b/testsuite/test_blank_lines.py @@ -139,7 +139,6 @@ class AFarEnoughClass(object): pass """) self.assertEqual([ - 'E302:4:1', # some_function 'E302:7:1', # another_function 'E302:14:1', # SomeCloseClass ], result) @@ -438,7 +437,7 @@ def some_function(): def test_top_level_fewer_blank_lines(self): """ - It will trigger an error when less 2 blank lines are found + It will trigger an error when less 3 blank lines are found before top level definitions. """ result = self.check("""# First comment line. @@ -471,7 +470,6 @@ class AFarEnoughClass(object): pass """) self.assertEqual([ - 'E302:5:1', # some_function 'E302:9:1', # another_function 'E302:17:1', # SomeCloseClass ], result) |