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 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
112
HUNK_REGEX = re .compile (r'^@@ -\d+(?:,\d+)? \+(\d+)(?:,(\d+))? @@.*$' )
112
113
113
114
# Work around Python < 2.6 behaviour, which does not generate NL after
@@ -872,7 +873,9 @@ def compound_statements(logical_line):
872
873
before .count ('[' ) <= before .count (']' ) and # [1:2] (slice)
873
874
before .count ('(' ) <= before .count (')' ))): # (annotation)
874
875
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" )
876
879
break
877
880
if before .startswith ('def ' ):
878
881
yield 0 , "E704 multiple statements on one line (def)"
Original file line number Diff line number Diff line change 5
5
#: E731:2:5
6
6
while False :
7
7
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