@@ -654,11 +654,7 @@ def _get_return_nodes_skip_functions(self):
654
654
yield from ()
655
655
656
656
def _get_yield_nodes_skip_lambdas (self ):
657
- for child_node in self .get_children ():
658
- if child_node .is_lambda :
659
- continue
660
- for matching in child_node ._get_yield_nodes_skip_lambdas ():
661
- yield matching
657
+ yield from ()
662
658
663
659
def _infer_name (self , frame , name ):
664
660
# overridden for ImportFrom, Import, Global, TryExcept and Arguments
@@ -2708,6 +2704,10 @@ def postinit(self, value=None):
2708
2704
def get_children (self ):
2709
2705
yield self .value
2710
2706
2707
+ def _get_yield_nodes_skip_lambdas (self ):
2708
+ if not self .value .is_lambda :
2709
+ yield from self .value ._get_yield_nodes_skip_lambdas ()
2710
+
2711
2711
2712
2712
class Ellipsis (NodeNG ): # pylint: disable=redefined-builtin
2713
2713
"""Class representing an :class:`ast.Ellipsis` node.
@@ -2834,6 +2834,12 @@ def _get_return_nodes_skip_functions(self):
2834
2834
continue
2835
2835
yield from child_node ._get_return_nodes_skip_functions ()
2836
2836
2837
+ def _get_yield_nodes_skip_lambdas (self ):
2838
+ for child_node in self .body :
2839
+ if child_node .is_lambda :
2840
+ continue
2841
+ yield from child_node ._get_yield_nodes_skip_lambdas ()
2842
+
2837
2843
2838
2844
class Exec (Statement ):
2839
2845
"""Class representing the ``exec`` statement.
@@ -2995,6 +3001,17 @@ def _get_return_nodes_skip_functions(self):
2995
3001
continue
2996
3002
yield from child_node ._get_return_nodes_skip_functions ()
2997
3003
3004
+ def _get_yield_nodes_skip_lambdas (self ):
3005
+ for child_node in self .body :
3006
+ if child_node .is_lambda :
3007
+ continue
3008
+ yield from child_node ._get_yield_nodes_skip_lambdas ()
3009
+
3010
+ for child_node in self .orelse :
3011
+ if child_node .is_lambda :
3012
+ continue
3013
+ yield from child_node ._get_yield_nodes_skip_lambdas ()
3014
+
2998
3015
2999
3016
class AsyncFor (For ):
3000
3017
"""Class representing an :class:`ast.AsyncFor` node.
@@ -3286,6 +3303,17 @@ def _get_return_nodes_skip_functions(self):
3286
3303
continue
3287
3304
yield from child_node ._get_return_nodes_skip_functions ()
3288
3305
3306
+ def _get_yield_nodes_skip_lambdas (self ):
3307
+ for child_node in self .body :
3308
+ if child_node .is_lambda :
3309
+ continue
3310
+ yield from child_node ._get_yield_nodes_skip_lambdas ()
3311
+
3312
+ for child_node in self .orelse :
3313
+ if child_node .is_lambda :
3314
+ continue
3315
+ yield from child_node ._get_yield_nodes_skip_lambdas ()
3316
+
3289
3317
3290
3318
class IfExp (NodeNG ):
3291
3319
"""Class representing an :class:`ast.IfExp` node.
@@ -4017,6 +4045,17 @@ def _get_return_nodes_skip_functions(self):
4017
4045
for matching in child_node ._get_return_nodes_skip_functions ():
4018
4046
yield matching
4019
4047
4048
+ def _get_yield_nodes_skip_lambdas (self ):
4049
+ for child_node in self .body :
4050
+ if child_node .is_lambda :
4051
+ continue
4052
+ yield from child_node ._get_yield_nodes_skip_lambdas ()
4053
+
4054
+ for child_node in self .orelse :
4055
+ if child_node .is_lambda :
4056
+ continue
4057
+ yield from child_node ._get_yield_nodes_skip_lambdas ()
4058
+
4020
4059
4021
4060
class TryFinally (mixins .BlockRangeMixIn , Statement ):
4022
4061
"""Class representing an :class:`ast.TryFinally` node.
@@ -4096,6 +4135,17 @@ def _get_return_nodes_skip_functions(self):
4096
4135
for matching in child_node ._get_return_nodes_skip_functions ():
4097
4136
yield matching
4098
4137
4138
+ def _get_yield_nodes_skip_lambdas (self ):
4139
+ for child_node in self .body :
4140
+ if child_node .is_lambda :
4141
+ continue
4142
+ yield from child_node ._get_yield_nodes_skip_lambdas ()
4143
+
4144
+ for child_node in self .finalbody :
4145
+ if child_node .is_lambda :
4146
+ continue
4147
+ yield from child_node ._get_yield_nodes_skip_lambdas ()
4148
+
4099
4149
4100
4150
class Tuple (_BaseContainer ):
4101
4151
"""Class representing an :class:`ast.Tuple` node.
@@ -4306,6 +4356,17 @@ def _get_return_nodes_skip_functions(self):
4306
4356
for matching in child_node ._get_return_nodes_skip_functions ():
4307
4357
yield matching
4308
4358
4359
+ def _get_yield_nodes_skip_lambdas (self ):
4360
+ for child_node in self .body :
4361
+ if child_node .is_lambda :
4362
+ continue
4363
+ yield from child_node ._get_yield_nodes_skip_lambdas ()
4364
+
4365
+ for child_node in self .orelse :
4366
+ if child_node .is_lambda :
4367
+ continue
4368
+ yield from child_node ._get_yield_nodes_skip_lambdas ()
4369
+
4309
4370
4310
4371
class With (mixins .BlockRangeMixIn , mixins .AssignTypeMixin , Statement ):
4311
4372
"""Class representing an :class:`ast.With` node.
@@ -4373,6 +4434,12 @@ def _get_return_nodes_skip_functions(self):
4373
4434
continue
4374
4435
yield from child_node ._get_return_nodes_skip_functions ()
4375
4436
4437
+ def _get_yield_nodes_skip_lambdas (self ):
4438
+ for child_node in self .body :
4439
+ if child_node .is_lambda :
4440
+ continue
4441
+ yield from child_node ._get_yield_nodes_skip_lambdas ()
4442
+
4376
4443
4377
4444
class AsyncWith (With ):
4378
4445
"""Asynchronous ``with`` built with the ``async`` keyword."""
@@ -4407,12 +4474,6 @@ def get_children(self):
4407
4474
def _get_yield_nodes_skip_lambdas (self ):
4408
4475
yield self
4409
4476
4410
- for child_node in self .get_children ():
4411
- if child_node .is_function_or_lambda :
4412
- continue
4413
- for matching in child_node ._get_yield_nodes_skip_lambdas ():
4414
- yield matching
4415
-
4416
4477
4417
4478
class YieldFrom (Yield ):
4418
4479
"""Class representing an :class:`ast.YieldFrom` node."""
0 commit comments