File tree Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Expand file tree Collapse file tree 2 files changed +7
-1
lines changed Original file line number Diff line number Diff line change 108108KEYWORD_REGEX = re .compile (r'(\s*)\b(?:%s)\b(\s*)' % r'|' .join (KEYWORDS ))
109109OPERATOR_REGEX = re .compile (r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+)(\s*)' )
110110LAMBDA_REGEX = re .compile (r'\blambda\b' )
111+ FIELD_ASSIGNMENT_REGEX = re .compile ('\s*.+\..+\s=' )
111112HUNK_REGEX = re .compile (r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$' )
112113
113114# Work around Python < 2.6 behaviour, which does not generate NL after
@@ -872,7 +873,9 @@ def compound_statements(logical_line):
872873 before .count ('[' ) <= before .count (']' ) and # [1:2] (slice)
873874 before .count ('(' ) <= before .count (')' ))): # (annotation)
874875 if LAMBDA_REGEX .search (before ):
875- yield 0 , "E731 do not assign a lambda expression, use a def"
876+ if not FIELD_ASSIGNMENT_REGEX .search (before ):
877+ yield 0 , ("E731 do not assign a lambda expression, use a"
878+ " def" )
876879 break
877880 if before .startswith ('def ' ):
878881 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'
You can’t perform that action at this time.
0 commit comments