Skip to content

Commit 5cd9024

Browse files
async function
1 parent 27419be commit 5cd9024

File tree

1 file changed

+8
-3
lines changed

1 file changed

+8
-3
lines changed

codeflash/context/unused_definition_remover.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -612,11 +612,16 @@ def _analyze_imports_in_optimized_code(
612612
return dict(imported_names_map)
613613

614614

615-
def find_target_node(root: ast.AST, function_to_optimize: FunctionToOptimize) -> Optional[ast.FunctionDef]:
616-
def _find(node: ast.AST, parents: list[FunctionParent]) -> Optional[ast.FunctionDef]:
615+
def find_target_node(
616+
root: ast.AST, function_to_optimize: FunctionToOptimize
617+
) -> Optional[ast.FunctionDef | ast.AsyncFunctionDef]:
618+
def _find(node: ast.AST, parents: list[FunctionParent]) -> Optional[ast.FunctionDef | ast.AsyncFunctionDef]:
617619
if not parents:
618620
for child in getattr(node, "body", []):
619-
if isinstance(child, ast.FunctionDef) and child.name == function_to_optimize.function_name:
621+
if (
622+
isinstance(child, (ast.FunctionDef, ast.AsyncFunctionDef))
623+
and child.name == function_to_optimize.function_name
624+
):
620625
return child
621626
return None
622627

0 commit comments

Comments
 (0)