Skip to content

Commit

Permalink
Fix handling of E306 for nested definitions
Browse files Browse the repository at this point in the history
This was another case of a sloppy regular expression that wasn't made to
catch only *keywords* in the language.

Closes PyCQAgh-619
  • Loading branch information
sigmavirus24 committed Jan 30, 2017
1 parent 9f725fb commit 0343b14
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pycodestyle.py
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,9 @@
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',
Expand Down
4 changes: 4 additions & 0 deletions testsuite/E30not.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,3 +155,7 @@ class Bar(object):
classification_errors = None
#: Okay
defined_properly = True
#: Okay
def foo(x):
classification = x
definitely = not classification

0 comments on commit 0343b14

Please sign in to comment.