Skip to content

Commit 2d1696a

Browse files
committed
restore from other branch
1 parent 736faa1 commit 2d1696a

File tree

3 files changed

+36
-5
lines changed

3 files changed

+36
-5
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

codeflash/optimization/optimizer.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -139,7 +139,7 @@ def get_optimizable_functions(self) -> tuple[dict[Path, list[FunctionToOptimize]
139139
def create_function_optimizer(
140140
self,
141141
function_to_optimize: FunctionToOptimize,
142-
function_to_optimize_ast: ast.FunctionDef | None = None,
142+
function_to_optimize_ast: ast.FunctionDef | ast.AsyncFunctionDef | None = None,
143143
function_to_tests: dict[str, set[FunctionCalledInTest]] | None = None,
144144
function_to_optimize_source_code: str | None = "",
145145
function_benchmark_timings: dict[str, dict[BenchmarkKey, float]] | None = None,

uv.lock

Lines changed: 26 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)