@@ -93,7 +93,7 @@ def find_and_update_line_node(
9393 # it's much more efficient to visit nodes manually. We'll only descend into expressions/statements.
9494
9595 # Helper for manual walk
96- def iter_ast_calls (node ):
96+ def iter_ast_calls (node ): # noqa: ANN202, ANN001
9797 # Generator to yield each ast.Call in test_node, preserves node identity
9898 stack = [node ]
9999 while stack :
@@ -102,11 +102,11 @@ def iter_ast_calls(node):
102102 yield n
103103 # Instead of using ast.walk (which calls iter_child_nodes under the hood in Python, which copy lists and stack-frames for EVERY node),
104104 # do a specialized BFS with only the necessary attributes
105- for field , value in ast .iter_fields (n ):
105+ for _field , value in ast .iter_fields (n ):
106106 if isinstance (value , list ):
107107 for item in reversed (value ):
108108 if isinstance (item , ast .AST ):
109- stack .append (item )
109+ stack .append (item ) # noqa: PERF401
110110 elif isinstance (value , ast .AST ):
111111 stack .append (value )
112112
@@ -137,6 +137,10 @@ def iter_ast_calls(node):
137137 if isinstance (node_func , ast .Name ):
138138 function_name = node_func .id
139139
140+ # Check if this is the function we want to instrument
141+ if function_name != fn_obj .function_name :
142+ continue
143+
140144 if fn_obj .is_async :
141145 return [test_node ]
142146
0 commit comments