We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5cf3c7a commit 5949086Copy full SHA for 5949086
pycodestyle.py
@@ -965,8 +965,12 @@ def compound_statements(logical_line):
965
if ((counts['{'] <= counts['}'] and # {'a': 1} (dict)
966
counts['['] <= counts[']'] and # [1:2] (slice)
967
counts['('] <= counts[')'])): # (annotation)
968
- if LAMBDA_REGEX.search(line, 0, found):
969
- yield 0, "E731 do not assign a lambda expression, use a def"
+ lambda_kw = LAMBDA_REGEX.search(line, 0, found)
+ 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")
974
break
975
if line.startswith('def '):
976
yield 0, "E704 multiple statements on one line (def)"
0 commit comments