File tree Expand file tree Collapse file tree 1 file changed +2
-15
lines changed
Expand file tree Collapse file tree 1 file changed +2
-15
lines changed Original file line number Diff line number Diff line change 99from typing import Optional
1010
1111from codeflash .cli_cmds .console import logger
12+ from codeflash .code_utils .formatter import format_code
1213from codeflash .code_utils .shell_utils import read_api_key_from_shell_config
1314
1415
@@ -28,22 +29,8 @@ def check_formatter_installed(formatter_cmds: list[str]) -> bool:
2829 f .write (tmp_code )
2930 f .flush ()
3031 tmp_file = Path (f .name )
31- file_token = "$file" # noqa: S105
32- for command in set (formatter_cmds ):
33- formatter_cmd_list = shlex .split (command , posix = os .name != "nt" )
34- formatter_cmd_list = [tmp_file .as_posix () if chunk == file_token else chunk for chunk in formatter_cmd_list ]
35- try :
36- result = subprocess .run (formatter_cmd_list , capture_output = True , check = False )
37- except (FileNotFoundError , NotADirectoryError ):
38- return_code = False
39- break
40- if result .returncode :
41- return_code = False
42- break
32+ format_code (formatter_cmds , tmp_file )
4333 tmp_file .unlink (missing_ok = True )
44- if not return_code :
45- msg = f"Error running formatter command: { command } "
46- raise FormatterNotFoundError (msg )
4734 return return_code
4835
4936
You can’t perform that action at this time.
0 commit comments