Skip to content

Commit a574081

Browse files
committed
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
1 parent 9f725fb commit a574081

File tree

2 files changed

+4
-1
lines changed

2 files changed

+4
-1
lines changed

pycodestyle.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@
122122
LAMBDA_REGEX = re.compile(r'\blambda\b')
123123
HUNK_REGEX = re.compile(r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$')
124124
STARTSWITH_DEF_REGEX = re.compile(r'^(async\s+def|def)')
125-
STARTSWITH_TOP_LEVEL_REGEX = re.compile(r'^(async\s+def|def|class|@)')
125+
STARTSWITH_TOP_LEVEL_REGEX = re.compile(r'^(async\s+def |def |class |@)')
126126
STARTSWITH_INDENT_STATEMENT_REGEX = re.compile(
127127
r'^\s*({0})'.format('|'.join(s.replace(' ', '\s+') for s in (
128128
'def', 'async def',

testsuite/E30not.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -155,3 +155,6 @@ class Bar(object):
155155
classification_errors = None
156156
#: Okay
157157
defined_properly = True
158+
#: Okay
159+
defaults = {}
160+
defaults.update({})

0 commit comments

Comments
 (0)