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 108
108
KEYWORD_REGEX = re .compile (r'(\s*)\b(?:%s)\b(\s*)' % r'|' .join (KEYWORDS ))
109
109
OPERATOR_REGEX = re .compile (r'(?:[^,\s])(\s*)(?:[-+*/|!<=>%&^]+)(\s*)' )
110
110
LAMBDA_REGEX = re .compile (r'\blambda\b' )
111
- FIELD_ASSIGNMENT_REGEX = re .compile ('\s*.+\.. +\s=' )
111
+ IDENTIFIER_REGEX = re .compile ('\s*[^.[\]] +\s=' )
112
112
HUNK_REGEX = re .compile (r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$' )
113
113
114
114
# Work around Python < 2.6 behaviour, which does not generate NL after
@@ -873,7 +873,7 @@ def compound_statements(logical_line):
873
873
before .count ('[' ) <= before .count (']' ) and # [1:2] (slice)
874
874
before .count ('(' ) <= before .count (')' ))): # (annotation)
875
875
if LAMBDA_REGEX .search (before ):
876
- if not FIELD_ASSIGNMENT_REGEX . search (before ):
876
+ if IDENTIFIER_REGEX . match (before ):
877
877
yield 0 , ("E731 do not assign a lambda expression, use a"
878
878
" def" )
879
879
break
Original file line number Diff line number Diff line change 8
8
#: Okay
9
9
f = object ()
10
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