From a574081fd55c15f509a8c0724d40c79ac74dd2f6 Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Mon, 30 Jan 2017 09:48:41 -0600 Subject: Fix regression in E302 detection This was similar to an issue we had with E306 in which we were only checking that a line started with "def" or "class" which catches global vars like "defaults" or "classification". Closes gh-617 --- pycodestyle.py | 2 +- testsuite/E30not.py | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/pycodestyle.py b/pycodestyle.py index 2e4ebed..9f14444 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -122,7 +122,7 @@ OPERATOR_REGEX = re.compile(r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+)(\s*)') LAMBDA_REGEX = re.compile(r'\blambda\b') HUNK_REGEX = re.compile(r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$') STARTSWITH_DEF_REGEX = re.compile(r'^(async\s+def|def)') -STARTSWITH_TOP_LEVEL_REGEX = re.compile(r'^(async\s+def|def|class|@)') +STARTSWITH_TOP_LEVEL_REGEX = re.compile(r'^(async\s+def |def |class |@)') STARTSWITH_INDENT_STATEMENT_REGEX = re.compile( r'^\s*({0})'.format('|'.join(s.replace(' ', '\s+') for s in ( 'def', 'async def', diff --git a/testsuite/E30not.py b/testsuite/E30not.py index 63ff733..00bee95 100644 --- a/testsuite/E30not.py +++ b/testsuite/E30not.py @@ -155,3 +155,6 @@ if __name__ == '__main__': classification_errors = None #: Okay defined_properly = True +#: Okay +defaults = {} +defaults.update({}) -- cgit v1.2.1 From b10ea40cab108bb0cf742872c6cfa6499411f1dd Mon Sep 17 00:00:00 2001 From: Ian Cordasco Date: Mon, 30 Jan 2017 10:00:19 -0600 Subject: Allow for multiple spaces in top level regex --- pycodestyle.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pycodestyle.py b/pycodestyle.py index 9f14444..05e8e5d 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -122,7 +122,7 @@ OPERATOR_REGEX = re.compile(r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+)(\s*)') LAMBDA_REGEX = re.compile(r'\blambda\b') HUNK_REGEX = re.compile(r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$') STARTSWITH_DEF_REGEX = re.compile(r'^(async\s+def|def)') -STARTSWITH_TOP_LEVEL_REGEX = re.compile(r'^(async\s+def |def |class |@)') +STARTSWITH_TOP_LEVEL_REGEX = re.compile(r'^(async\s+def\s+|def\s+|class\s+|@)') STARTSWITH_INDENT_STATEMENT_REGEX = re.compile( r'^\s*({0})'.format('|'.join(s.replace(' ', '\s+') for s in ( 'def', 'async def', -- cgit v1.2.1