mirror of
https://github.com/codeflash-ai/codeflash-agent.git
synced 2026-05-04 18:25:19 +00:00
Fix callee syntax validation in prepare_python_module
normalize_code no longer raises SyntaxError (it returns raw code as fallback), so validate callee source with ast.parse() explicitly before normalizing. Fixes test_callee_syntax_error_returns_none.
This commit is contained in:
parent
bd5613d22f
commit
43a4009294
1 changed files with 2 additions and 3 deletions
|
|
@ -67,9 +67,7 @@ def prepare_python_module(
|
|||
for analysis in imported_module_analyses:
|
||||
callee_original_code = analysis.file_path.read_text(encoding="utf8")
|
||||
try:
|
||||
normalized_callee_original_code = normalize_code(
|
||||
callee_original_code
|
||||
)
|
||||
ast.parse(callee_original_code)
|
||||
except SyntaxError:
|
||||
log.warning(
|
||||
"Syntax error parsing code in callee module %s",
|
||||
|
|
@ -77,6 +75,7 @@ def prepare_python_module(
|
|||
)
|
||||
log.info("Skipping optimization due to helper file error.")
|
||||
return None
|
||||
normalized_callee_original_code = normalize_code(callee_original_code)
|
||||
validated_original_code[analysis.file_path] = ValidCode(
|
||||
source_code=callee_original_code,
|
||||
normalized_code=normalized_callee_original_code,
|
||||
|
|
|
|||
Loading…
Reference in a new issue