File tree Expand file tree Collapse file tree 2 files changed +10
-2
lines changed Expand file tree Collapse file tree 2 files changed +10
-2
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=' )
111+ IDENTIFIER_REGEX = re .compile ('\s*[^.[\]] +\s=' )
112112HUNK_REGEX = re .compile (r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$' )
113113
114114# Work around Python < 2.6 behaviour, which does not generate NL after
@@ -873,7 +873,7 @@ def compound_statements(logical_line):
873873 before .count ('[' ) <= before .count (']' ) and # [1:2] (slice)
874874 before .count ('(' ) <= before .count (')' ))): # (annotation)
875875 if LAMBDA_REGEX .search (before ):
876- if not FIELD_ASSIGNMENT_REGEX . search (before ):
876+ if IDENTIFIER_REGEX . match (before ):
877877 yield 0 , ("E731 do not assign a lambda expression, use a"
878878 " def" )
879879 break
Original file line number Diff line number Diff line change 88#: Okay
99f = object ()
1010f .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