diff --git a/pycodestyle.py b/pycodestyle.py index f866dd4a..db6d21ed 100755 --- a/pycodestyle.py +++ b/pycodestyle.py @@ -140,7 +140,9 @@ ) KEYWORD_REGEX = re.compile(r'(\s*)\b(?:%s)\b(\s*)' % r'|'.join(KEYWORDS)) OPERATOR_REGEX = re.compile(r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+|:=)(\s*)') -LAMBDA_REGEX = re.compile(r'\blambda\b') +LAMBDA_ASSIGNMENT_REGEX = re.compile( + r'(?= (3, 8) and line[found + 1] == '=')): # assignment expression - lambda_kw = LAMBDA_REGEX.search(line, 0, found) - if lambda_kw: - before = line[:lambda_kw.start()].rstrip() - if before[-1:] == '=' and before[:-1].strip().isidentifier(): - yield 0, ("E731 do not assign a lambda expression, use a " - "def") - break if STARTSWITH_DEF_REGEX.match(line): yield 0, "E704 multiple statements on one line (def)" elif STARTSWITH_INDENT_STATEMENT_REGEX.match(line):