Skip to content

Commit 15448f5

Browse files
committed
fix
1 parent 8ce2519 commit 15448f5

File tree

3 files changed

+10
-7
lines changed

3 files changed

+10
-7
lines changed

codeflash/code_utils/env_utils.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,13 +22,12 @@ def check_formatter_installed(formatter_cmds: list[str], exit_on_failure: bool =
2222
f.flush()
2323
tmp_file = Path(f.name)
2424
try:
25-
format_code(formatter_cmds, tmp_file, print_status=False)
25+
format_code(formatter_cmds, tmp_file, print_status=False, exit_on_failure=exit_on_failure)
2626
except Exception:
2727
exit_with_message(
2828
"⚠️ Codeflash requires a code formatter to be installed in your environment, but none was found. Please install a supported formatter, verify the formatter-cmds in your codeflash pyproject.toml config and try again.",
2929
error_on_exit=True,
3030
)
31-
3231
return return_code
3332

3433

codeflash/code_utils/formatter.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@ def apply_formatter_cmds(
4343
path: Path,
4444
test_dir_str: Optional[str],
4545
print_status: bool, # noqa
46+
exit_on_failure: bool = True, # noqa
4647
) -> tuple[Path, str]:
4748
# TODO: Only allow a particular whitelist of formatters here to prevent arbitrary code execution
4849
formatter_name = cmds[0].lower()
@@ -84,8 +85,8 @@ def apply_formatter_cmds(
8485
expand=False,
8586
)
8687
console.print(panel)
87-
88-
raise e from None
88+
if exit_on_failure:
89+
raise e from None
8990

9091
return file_path, file_path.read_text(encoding="utf8")
9192

@@ -106,6 +107,7 @@ def format_code(
106107
optimized_function: str = "",
107108
check_diff: bool = False, # noqa
108109
print_status: bool = True, # noqa
110+
exit_on_failure: bool = True, # noqa
109111
) -> str:
110112
with tempfile.TemporaryDirectory() as test_dir_str:
111113
if isinstance(path, str):
@@ -138,7 +140,9 @@ def format_code(
138140
)
139141
return original_code
140142
# TODO : We can avoid formatting the whole file again and only formatting the optimized code standalone and replace in formatted file above.
141-
_, formatted_code = apply_formatter_cmds(formatter_cmds, path, test_dir_str=None, print_status=print_status)
143+
_, formatted_code = apply_formatter_cmds(
144+
formatter_cmds, path, test_dir_str=None, print_status=print_status, exit_on_failure=exit_on_failure
145+
)
142146
logger.debug(f"Formatted {path} with commands: {formatter_cmds}")
143147
return formatted_code
144148

codeflash/version.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
# These version placeholders will be replaced by poetry-dynamic-versioning during `poetry build`.
2-
__version__ = "0.14.4"
3-
__version_tuple__ = (0, 14, 4)
2+
__version__ = "0.14.4.post2.dev0+8ce25197"
3+
__version_tuple__ = (0, 14, 4, "post2", "dev0", "8ce25197")

0 commit comments

Comments
 (0)