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
3 changes: 3 additions & 0 deletions codeflash/code_utils/formatter.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ def is_diff_line(line: str) -> bool:


def format_generated_code(generated_test_source: str, formatter_cmds: list[str]) -> str:
formatter_name = formatter_cmds[0].lower() if formatter_cmds else "disabled"
if formatter_name == "disabled": # nothing to do if no formatter provided
return re.sub(r"\n{2,}", "\n\n", generated_test_source)
with tempfile.TemporaryDirectory() as test_dir_str:
# try running formatter, if nothing changes (could be due to formatting failing or no actual formatting needed) return code with 2 or more newlines substituted with 2 newlines
original_temp = Path(test_dir_str) / "original_temp.py"
Expand Down
Loading