Skip to content

Commit 6b27835

Browse files
committed
minor fixes
1 parent ac0894a commit 6b27835

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

codeflash/code_utils/env_utils.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import subprocess
44
import tempfile
55
from functools import lru_cache
6+
from pathlib import Path
67
from typing import Optional
78

89
from codeflash.cli_cmds.console import logger
@@ -14,7 +15,8 @@ def check_formatter_installed(formatter_cmds: list[str]) -> bool:
1415
if formatter_cmds[0] == "disabled":
1516
return return_code
1617
tmp_code = """print("hello world")"""
17-
tmp_file = tempfile.NamedTemporaryFile(suffix=".py").write_text(tmp_code, encoding="utf8")
18+
tmp_file = tempfile.NamedTemporaryFile(suffix=".py")
19+
Path(tmp_file.name).write_text(tmp_code, encoding="utf8")
1820
file_token = "$file" # noqa: S105
1921
for command in set(formatter_cmds):
2022
formatter_cmd_list = shlex.split(command, posix=os.name != "nt")
@@ -23,6 +25,7 @@ def check_formatter_installed(formatter_cmds: list[str]) -> bool:
2325
if result.returncode:
2426
return_code = False
2527
break
28+
tmp_file.close()
2629
tmp_file.unlink(missing_ok=True)
2730
return return_code
2831

0 commit comments

Comments
 (0)