Skip to content

Commit 5949086

Browse files
committed
Modified patch for issue #314 so tests in E73.py pass
1 parent 5cf3c7a commit 5949086

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

pycodestyle.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -965,8 +965,12 @@ def compound_statements(logical_line):
965965
if ((counts['{'] <= counts['}'] and # {'a': 1} (dict)
966966
counts['['] <= counts[']'] and # [1:2] (slice)
967967
counts['('] <= counts[')'])): # (annotation)
968-
if LAMBDA_REGEX.search(line, 0, found):
969-
yield 0, "E731 do not assign a lambda expression, use a def"
968+
lambda_kw = LAMBDA_REGEX.search(line, 0, found)
969+
if lambda_kw:
970+
before = line[:lambda_kw.start()].rstrip()
971+
if before[-1:] == '=' and isidentifier(before[:-1].strip()):
972+
yield 0, ("E731 do not assign a lambda expression, use a "
973+
"def")
970974
break
971975
if line.startswith('def '):
972976
yield 0, "E704 multiple statements on one line (def)"

0 commit comments

Comments
 (0)