|
22 | 22 | from codeflash.cli_cmds.console import console, logger |
23 | 23 | from codeflash.code_utils.compat import LF |
24 | 24 | from codeflash.code_utils.config_parser import parse_config_file |
25 | | -from codeflash.code_utils.env_utils import get_codeflash_api_key |
| 25 | +from codeflash.code_utils.env_utils import check_formatter_installed, get_codeflash_api_key |
26 | 26 | from codeflash.code_utils.git_utils import get_git_remotes, get_repo_owner_and_name |
27 | 27 | from codeflash.code_utils.github_utils import get_github_secrets_page_url |
28 | 28 | from codeflash.code_utils.shell_utils import get_shell_rc_path, save_api_key_to_rc |
@@ -720,11 +720,7 @@ def configure_pyproject_toml(setup_info: SetupInfo) -> None: |
720 | 720 | ) |
721 | 721 | elif formatter == "don't use a formatter": |
722 | 722 | formatter_cmds.append("disabled") |
723 | | - if formatter in ["black", "ruff"]: |
724 | | - try: |
725 | | - subprocess.run([formatter], capture_output=True, check=False) |
726 | | - except (FileNotFoundError, NotADirectoryError): |
727 | | - click.echo(f"⚠️ Formatter not found: {formatter}, please ensure it is installed") |
| 723 | + check_formatter_installed(formatter_cmds) |
728 | 724 | codeflash_section["formatter-cmds"] = formatter_cmds |
729 | 725 | # Add the 'codeflash' section, ensuring 'tool' section exists |
730 | 726 | tool_section = pyproject_data.get("tool", tomlkit.table()) |
@@ -924,6 +920,14 @@ def test_sort(): |
924 | 920 |
|
925 | 921 |
|
926 | 922 | def run_end_to_end_test(args: Namespace, bubble_sort_path: str, bubble_sort_test_path: str) -> None: |
| 923 | + try: |
| 924 | + check_formatter_installed(args.formatter_cmds) |
| 925 | + except Exception: |
| 926 | + logger.error( |
| 927 | + "Formatter not found. Review the formatter_cmds in your pyproject.toml file and make sure the formatter is installed." |
| 928 | + ) |
| 929 | + return |
| 930 | + |
927 | 931 | command = ["codeflash", "--file", "bubble_sort.py", "--function", "sorter"] |
928 | 932 | if args.no_pr: |
929 | 933 | command.append("--no-pr") |
|
0 commit comments