File tree Expand file tree Collapse file tree 1 file changed +13
-17
lines changed Expand file tree Collapse file tree 1 file changed +13
-17
lines changed Original file line number Diff line number Diff line change @@ -1389,23 +1389,19 @@ def _check_consumer(
1389
1389
# class A:
1390
1390
# x = lambda attr: f + attr
1391
1391
# f = 42
1392
- if isinstance (frame , nodes .ClassDef ) and node .name in frame .locals :
1393
- if isinstance (node .parent , nodes .Arguments ):
1394
- if stmt .fromlineno <= defstmt .fromlineno :
1395
- # Doing the following is fine:
1396
- # class A:
1397
- # x = 42
1398
- # y = lambda attr=x: attr
1399
- self .add_message (
1400
- "used-before-assignment" ,
1401
- args = node .name ,
1402
- node = node ,
1403
- )
1404
- else :
1405
- self .add_message (
1406
- "undefined-variable" , args = node .name , node = node
1407
- )
1408
- return (VariableVisitConsumerAction .CONSUME , found_nodes )
1392
+ # We check lineno because doing the following is fine:
1393
+ # class A:
1394
+ # x = 42
1395
+ # y = lambda attr: x + attr
1396
+ if (
1397
+ isinstance (frame , nodes .ClassDef )
1398
+ and node .name in frame .locals
1399
+ and stmt .fromlineno <= defstmt .fromlineno
1400
+ ):
1401
+ self .add_message (
1402
+ "used-before-assignment" , args = node .name , node = node
1403
+ )
1404
+
1409
1405
elif current_consumer .scope_type == "lambda" :
1410
1406
self .add_message ("undefined-variable" , args = node .name , node = node )
1411
1407
return (VariableVisitConsumerAction .CONSUME , found_nodes )
You can’t perform that action at this time.
0 commit comments