diff --git a/codeflash/code_utils/env_utils.py b/codeflash/code_utils/env_utils.py index 8bf8a506c..26528439b 100644 --- a/codeflash/code_utils/env_utils.py +++ b/codeflash/code_utils/env_utils.py @@ -22,7 +22,7 @@ def check_formatter_installed(formatter_cmds: list[str], exit_on_failure: bool = f.flush() tmp_file = Path(f.name) try: - format_code(formatter_cmds, tmp_file) + format_code(formatter_cmds, tmp_file, print_status=False) except Exception: print( "⚠️ Codeflash requires a code formatter to be installed in your environment, but none was found. Please install a supported formatter, verify the formatter-cmds in your codeflash pyproject.toml config and try again." diff --git a/codeflash/code_utils/formatter.py b/codeflash/code_utils/formatter.py index 77d7d6cb8..927a4d4cb 100644 --- a/codeflash/code_utils/formatter.py +++ b/codeflash/code_utils/formatter.py @@ -13,7 +13,7 @@ from pathlib import Path -def format_code(formatter_cmds: list[str], path: Path) -> str: +def format_code(formatter_cmds: list[str], path: Path, print_status: bool = True) -> str: # noqa # TODO: Only allow a particular whitelist of formatters here to prevent arbitrary code execution formatter_name = formatter_cmds[0].lower() if not path.exists(): @@ -28,7 +28,8 @@ def format_code(formatter_cmds: list[str], path: Path) -> str: try: result = subprocess.run(formatter_cmd_list, capture_output=True, check=False) if result.returncode == 0: - console.rule(f"Formatted Successfully with: {formatter_name.replace('$file', path.name)}") + if print_status: + console.rule(f"Formatted Successfully with: {formatter_name.replace('$file', path.name)}") else: logger.error(f"Failed to format code with {' '.join(formatter_cmd_list)}") except FileNotFoundError as e: