|
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 |
@@ -239,7 +239,7 @@ def collect_setup_info() -> SetupInfo: |
239 | 239 | else: |
240 | 240 | apologize_and_exit() |
241 | 241 | else: |
242 | | - tests_root = Path(curdir) / Path(cast(str, tests_root_answer)) |
| 242 | + tests_root = Path(curdir) / Path(cast("str", tests_root_answer)) |
243 | 243 | tests_root = tests_root.relative_to(curdir) |
244 | 244 | ph("cli-tests-root-provided") |
245 | 245 |
|
@@ -302,7 +302,7 @@ def collect_setup_info() -> SetupInfo: |
302 | 302 | elif benchmarks_answer == no_benchmarks_option: |
303 | 303 | benchmarks_root = None |
304 | 304 | else: |
305 | | - benchmarks_root = tests_root / Path(cast(str, benchmarks_answer)) |
| 305 | + benchmarks_root = tests_root / Path(cast("str", benchmarks_answer)) |
306 | 306 |
|
307 | 307 | # TODO: Implement other benchmark framework options |
308 | 308 | # if benchmarks_root: |
@@ -354,9 +354,9 @@ def collect_setup_info() -> SetupInfo: |
354 | 354 | module_root=str(module_root), |
355 | 355 | tests_root=str(tests_root), |
356 | 356 | benchmarks_root=str(benchmarks_root) if benchmarks_root else None, |
357 | | - test_framework=cast(str, test_framework), |
| 357 | + test_framework=cast("str", test_framework), |
358 | 358 | ignore_paths=ignore_paths, |
359 | | - formatter=cast(str, formatter), |
| 359 | + formatter=cast("str", formatter), |
360 | 360 | git_remote=str(git_remote), |
361 | 361 | ) |
362 | 362 |
|
@@ -466,7 +466,7 @@ def check_for_toml_or_setup_file() -> str | None: |
466 | 466 | click.echo("⏩️ Skipping pyproject.toml creation.") |
467 | 467 | apologize_and_exit() |
468 | 468 | click.echo() |
469 | | - return cast(str, project_name) |
| 469 | + return cast("str", project_name) |
470 | 470 |
|
471 | 471 |
|
472 | 472 | def install_github_actions(override_formatter_check: bool = False) -> None: |
@@ -717,11 +717,7 @@ def configure_pyproject_toml(setup_info: SetupInfo) -> None: |
717 | 717 | ) |
718 | 718 | elif formatter == "don't use a formatter": |
719 | 719 | formatter_cmds.append("disabled") |
720 | | - if formatter in ["black", "ruff"]: |
721 | | - try: |
722 | | - subprocess.run([formatter], capture_output=True, check=False) |
723 | | - except (FileNotFoundError, NotADirectoryError): |
724 | | - click.echo(f"⚠️ Formatter not found: {formatter}, please ensure it is installed") |
| 720 | + check_formatter_installed(formatter_cmds) |
725 | 721 | codeflash_section["formatter-cmds"] = formatter_cmds |
726 | 722 | # Add the 'codeflash' section, ensuring 'tool' section exists |
727 | 723 | tool_section = pyproject_data.get("tool", tomlkit.table()) |
|
0 commit comments