From 594908607f98225884515bf225fb5e7a735e6722 Mon Sep 17 00:00:00 2001 From: Art Hall Date: Thu, 2 Jun 2016 11:03:14 -0700 Subject: Modified patch for issue #314 so tests in E73.py pass --- pycodestyle.py | 8 ++++++-- 1 file 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)" -- cgit v1.2.1