@@ -654,11 +654,7 @@ def _get_return_nodes_skip_functions(self):
654654 yield from ()
655655
656656 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 ()
662658
663659 def _infer_name (self , frame , name ):
664660 # overridden for ImportFrom, Import, Global, TryExcept and Arguments
@@ -2708,6 +2704,10 @@ def postinit(self, value=None):
27082704 def get_children (self ):
27092705 yield self .value
27102706
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+
27112711
27122712class Ellipsis (NodeNG ): # pylint: disable=redefined-builtin
27132713 """Class representing an :class:`ast.Ellipsis` node.
@@ -2834,6 +2834,12 @@ def _get_return_nodes_skip_functions(self):
28342834 continue
28352835 yield from child_node ._get_return_nodes_skip_functions ()
28362836
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+
28372843
28382844class Exec (Statement ):
28392845 """Class representing the ``exec`` statement.
@@ -2995,6 +3001,17 @@ def _get_return_nodes_skip_functions(self):
29953001 continue
29963002 yield from child_node ._get_return_nodes_skip_functions ()
29973003
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+
29983015
29993016class AsyncFor (For ):
30003017 """Class representing an :class:`ast.AsyncFor` node.
@@ -3286,6 +3303,17 @@ def _get_return_nodes_skip_functions(self):
32863303 continue
32873304 yield from child_node ._get_return_nodes_skip_functions ()
32883305
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+
32893317
32903318class IfExp (NodeNG ):
32913319 """Class representing an :class:`ast.IfExp` node.
@@ -4017,6 +4045,17 @@ def _get_return_nodes_skip_functions(self):
40174045 for matching in child_node ._get_return_nodes_skip_functions ():
40184046 yield matching
40194047
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+
40204059
40214060class TryFinally (mixins .BlockRangeMixIn , Statement ):
40224061 """Class representing an :class:`ast.TryFinally` node.
@@ -4096,6 +4135,17 @@ def _get_return_nodes_skip_functions(self):
40964135 for matching in child_node ._get_return_nodes_skip_functions ():
40974136 yield matching
40984137
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+
40994149
41004150class Tuple (_BaseContainer ):
41014151 """Class representing an :class:`ast.Tuple` node.
@@ -4306,6 +4356,17 @@ def _get_return_nodes_skip_functions(self):
43064356 for matching in child_node ._get_return_nodes_skip_functions ():
43074357 yield matching
43084358
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+
43094370
43104371class With (mixins .BlockRangeMixIn , mixins .AssignTypeMixin , Statement ):
43114372 """Class representing an :class:`ast.With` node.
@@ -4373,6 +4434,12 @@ def _get_return_nodes_skip_functions(self):
43734434 continue
43744435 yield from child_node ._get_return_nodes_skip_functions ()
43754436
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+
43764443
43774444class AsyncWith (With ):
43784445 """Asynchronous ``with`` built with the ``async`` keyword."""
@@ -4407,12 +4474,6 @@ def get_children(self):
44074474 def _get_yield_nodes_skip_lambdas (self ):
44084475 yield self
44094476
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-
44164477
44174478class YieldFrom (Yield ):
44184479 """Class representing an :class:`ast.YieldFrom` node."""
0 commit comments