fix: lint command with nested spaced strings

This commit is contained in:
Aaron Weisberg 2024-12-29 21:45:25 +01:00
parent f292e01980
commit acf654c984
3 changed files with 10 additions and 13 deletions

View file

@ -11,6 +11,7 @@ from grep_ast import TreeContext, filename_to_lang
from tree_sitter_languages import get_parser # noqa: E402
from aider.dump import dump # noqa: F401
from aider.run_cmd import run_cmd_subprocess # noqa: F401
# tree_sitter is throwing a FutureWarning
warnings.simplefilter("ignore", category=FutureWarning)
@ -44,26 +45,22 @@ class Linter:
def run_cmd(self, cmd, rel_fname, code):
cmd += " " + rel_fname
cmd = cmd.split()
returncode = 0
stdout = ""
try:
process = subprocess.Popen(
returncode, stdout = run_cmd_subprocess(
cmd,
stdout=subprocess.PIPE,
stderr=subprocess.STDOUT,
encoding=self.encoding,
errors="replace",
cwd=self.root,
encoding=self.encoding,
)
except OSError as err:
print(f"Unable to execute lint command: {err}")
return
stdout, _ = process.communicate()
errors = stdout
if process.returncode == 0:
if returncode == 0:
return # zero exit status
cmd = " ".join(cmd)
res = f"## Running: {cmd}\n\n"
res += errors