Skip to content

Commit e292c5e

Browse files
committed
re-revert
1 parent 66eac2a commit e292c5e

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

codeflash/code_utils/static_analysis.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -128,13 +128,19 @@ def get_first_top_level_object_def_ast(
128128

129129
def get_first_top_level_function_or_method_ast(
130130
function_name: str, parents: list[FunctionParent], node: ast.AST
131-
) -> ast.FunctionDef | None:
131+
) -> ast.FunctionDef | ast.AsyncFunctionDef | None:
132132
if not parents:
133-
return get_first_top_level_object_def_ast(function_name, ast.FunctionDef, node)
133+
result = get_first_top_level_object_def_ast(function_name, ast.FunctionDef, node)
134+
if result is not None:
135+
return result
136+
return get_first_top_level_object_def_ast(function_name, ast.AsyncFunctionDef, node)
134137
if parents[0].type == "ClassDef" and (
135138
class_node := get_first_top_level_object_def_ast(parents[0].name, ast.ClassDef, node)
136139
):
137-
return get_first_top_level_object_def_ast(function_name, ast.FunctionDef, class_node)
140+
result = get_first_top_level_object_def_ast(function_name, ast.FunctionDef, class_node)
141+
if result is not None:
142+
return result
143+
return get_first_top_level_object_def_ast(function_name, ast.AsyncFunctionDef, class_node)
138144
return None
139145

140146

0 commit comments

Comments
 (0)