Skip to content

Commit 5c3903e

Browse files
committed
will exit the cli if user doesn't have the formatter installed while running codeflash AFTER init
1 parent 3232228 commit 5c3903e

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

codeflash/main.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
"""Thanks for being curious about how codeflash works! If you might want to work with us on finally making performance a
22
solved problem, please reach out to us at [email protected]. We're hiring!
33
"""
4-
4+
import subprocess
55
from pathlib import Path
6+
import sys
7+
8+
import click
69

710
from codeflash.cli_cmds.cli import parse_args, process_pyproject_config
811
from codeflash.cli_cmds.cmd_init import CODEFLASH_LOGO, ask_run_end_to_end_test
@@ -36,6 +39,14 @@ def main() -> None:
3639
ask_run_end_to_end_test(args)
3740
else:
3841
args = process_pyproject_config(args)
42+
if args.formatter_cmds[0].startswith("black") or args.formatter_cmds[0].startswith("uv"):
43+
formatter = args.formatter_cmds[0].split(" ")[0]
44+
try:
45+
subprocess.run([formatter], capture_output=True, check=False)
46+
except (FileNotFoundError, NotADirectoryError):
47+
click.echo(f"⚠️ Formatter not found: {formatter}, please ensure it is installed")
48+
sys.exit(1)
49+
3950
args.previous_checkpoint_functions = ask_should_use_checkpoint_get_functions(args)
4051
init_sentry(not args.disable_telemetry, exclude_errors=True)
4152
posthog_cf.initialize_posthog(not args.disable_telemetry)

0 commit comments

Comments
 (0)