summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorArt Hall <arthall@gmail.com>2016-06-02 11:03:14 -0700
committerArt Hall <arthall@gmail.com>2016-06-02 11:03:14 -0700
commit594908607f98225884515bf225fb5e7a735e6722 (patch)
treee07c6b3d8c0fdbef2df37afca5ebeca7717fa4fe
parent5cf3c7a5d32ed4fbe4fcb09b67a967fcdd6fa786 (diff)
downloadpep8-594908607f98225884515bf225fb5e7a735e6722.tar.gz
Modified patch for issue #314 so tests in E73.py pass
-rwxr-xr-xpycodestyle.py8
1 files changed, 6 insertions, 2 deletions
diff --git a/pycodestyle.py b/pycodestyle.py
index e033547..e52cfbd 100755
--- a/pycodestyle.py
+++ b/pycodestyle.py
@@ -965,8 +965,12 @@ def compound_statements(logical_line):
if ((counts['{'] <= counts['}'] and # {'a': 1} (dict)
counts['['] <= counts[']'] and # [1:2] (slice)
counts['('] <= counts[')'])): # (annotation)
- if LAMBDA_REGEX.search(line, 0, found):
- yield 0, "E731 do not assign a lambda expression, use a def"
+ lambda_kw = LAMBDA_REGEX.search(line, 0, found)
+ if lambda_kw:
+ before = line[:lambda_kw.start()].rstrip()
+ if before[-1:] == '=' and isidentifier(before[:-1].strip()):
+ yield 0, ("E731 do not assign a lambda expression, use a "
+ "def")
break
if line.startswith('def '):
yield 0, "E704 multiple statements on one line (def)"