Skip to content

Commit cd63955

Browse files
committed
more pythonic
1 parent 498f401 commit cd63955

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

codeflash/code_utils/env_utils.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import os
2+
import shlex
23
import subprocess
34
from functools import lru_cache
45
from typing import Optional
@@ -8,9 +9,9 @@
89

910

1011
def check_formatter_installed(formatter_cmds: list[str]) -> bool:
11-
cmd_parts = formatter_cmds[0].split(" ")
12-
if "black" in cmd_parts or "ruff" in cmd_parts:
13-
formatter = cmd_parts[0]
12+
cmd_parts = shlex.split(formatter_cmds[0]," ")
13+
formatter = "black" if "black" in cmd_parts else "ruff" if "ruff" in cmd_parts else None
14+
if not formatter:
1415
try:
1516
subprocess.run([formatter], check=False)
1617
except (FileNotFoundError, NotADirectoryError):

0 commit comments

Comments
 (0)