Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions codeflash/languages/python/support.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,11 +685,7 @@ def validate_syntax(self, source: str, file_path: Path | None = None) -> bool:
True if valid, False otherwise.

"""
try:
compile(source, "<string>", "exec")
return True
except SyntaxError:
return False
return _compile_ok(source)

def normalize_code(self, source: str) -> str:
from codeflash.languages.python.normalizer import normalize_python_code
Expand Down Expand Up @@ -1361,3 +1357,12 @@ def generate_concolic_tests(
end_time = time.perf_counter()
logger.debug("Generated concolic tests in %.2f seconds", end_time - start_time)
return function_to_concolic_tests, concolic_test_suite_code


def _compile_ok(source: str) -> bool:
# Keep behavior identical to the original: use compile() and only catch SyntaxError.
try:
compile(source, "<string>", "exec")
return True
except SyntaxError:
return False
Loading