Skip to content

Commit fa9911d

Browse files
committed
check formatter during init
1 parent 2f81f2c commit fa9911d

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

codeflash/cli_cmds/cmd_init.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -587,6 +587,16 @@ def configure_pyproject_toml(setup_info: SetupInfo) -> None:
587587
)
588588
elif formatter == "don't use a formatter":
589589
formatter_cmds.append("disabled")
590+
if formatter in ["black", "ruff"]:
591+
try:
592+
result = subprocess.run([formatter], capture_output=True, check=False)
593+
click.echo(f"✅ Formatter exists on system")
594+
click.echo()
595+
except FileNotFoundError as e:
596+
click.echo(f"⚠️ Formatter not found: {formatter}")
597+
click.echo()
598+
# Not throwing an exception, letting the program proceed even though the formatter was not found, putting it on the user to install it later
599+
# raise e from None
590600
codeflash_section["formatter-cmds"] = formatter_cmds
591601
# Add the 'codeflash' section, ensuring 'tool' section exists
592602
tool_section = pyproject_data.get("tool", tomlkit.table())

0 commit comments

Comments
 (0)