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
5 changes: 5 additions & 0 deletions codeflash/cli_cmds/cmd_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -587,6 +587,11 @@ def configure_pyproject_toml(setup_info: SetupInfo) -> None:
)
elif formatter == "don't use a formatter":
formatter_cmds.append("disabled")
if formatter in ["black", "ruff"]:
try:
result = subprocess.run([formatter], capture_output=True, check=False)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: shouldnt we use shutil.which to check if its in file path rather than running the process?
And we might have to test this in other OS for consistency.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we want to test for existence the same way it is run later for formatting. To reduce any inconsistencies

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

        choices=["black", "ruff", "other", "don't use a formatter"],

in here
we allow for other as a choice, won't this break that behavior?

except FileNotFoundError as e:
click.echo(f"⚠️ Formatter not found: {formatter}, please ensure it is installed")
codeflash_section["formatter-cmds"] = formatter_cmds
# Add the 'codeflash' section, ensuring 'tool' section exists
tool_section = pyproject_data.get("tool", tomlkit.table())
Expand Down
Loading