File tree Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Expand file tree Collapse file tree 2 files changed +15
-1
lines changed Original file line number Diff line number Diff line change 112112KEYWORD_REGEX = re .compile (r'(\s*)\b(?:%s)\b(\s*)' % r'|' .join (KEYWORDS ))
113113OPERATOR_REGEX = re .compile (r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+)(\s*)' )
114114LAMBDA_REGEX = re .compile (r'\blambda\b' )
115+ IDENTIFIER_REGEX = re .compile ('\s*[^.[\]]+\s=' )
115116HUNK_REGEX = re .compile (r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$' )
116117
117118# Work around Python < 2.6 behaviour, which does not generate NL after
@@ -923,7 +924,9 @@ def compound_statements(logical_line):
923924 before .count ('[' ) <= before .count (']' ) and # [1:2] (slice)
924925 before .count ('(' ) <= before .count (')' ))): # (annotation)
925926 if LAMBDA_REGEX .search (before ):
926- yield 0 , "E731 do not assign a lambda expression, use a def"
927+ if IDENTIFIER_REGEX .match (before ):
928+ yield 0 , ("E731 do not assign a lambda expression, use a"
929+ " def" )
927930 break
928931 if before .startswith ('def ' ):
929932 yield 0 , "E704 multiple statements on one line (def)"
Original file line number Diff line number Diff line change 55#: E731:2:5
66while False :
77 this = lambda y , z : 2 * x
8+ #: Okay
9+ f = object ()
10+ f .method = lambda : 'Method'
11+ #: Okay
12+ f = {}
13+ f ['a' ] = lambda x : x ** 2
14+ #: Okay
15+ f = []
16+ f .append (lambda x : x ** 2 )
17+ #: Okay
18+ lambda : 'no-op'
You can’t perform that action at this time.
0 commit comments