mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 00:35:00 +00:00
Merge pull request #3869 from titusz/fix/shlex
Fix shlex.quote() use in linter on Windows
This commit is contained in:
commit
cbaaf96324
5 changed files with 24 additions and 8 deletions
|
@ -4,7 +4,7 @@ import subprocess
|
|||
import sys
|
||||
import traceback
|
||||
import warnings
|
||||
import shlex
|
||||
import oslex
|
||||
from dataclasses import dataclass
|
||||
from pathlib import Path
|
||||
|
||||
|
@ -45,7 +45,7 @@ class Linter:
|
|||
return fname
|
||||
|
||||
def run_cmd(self, cmd, rel_fname, code):
|
||||
cmd += " " + shlex.quote(rel_fname)
|
||||
cmd += " " + oslex.quote(rel_fname)
|
||||
|
||||
returncode = 0
|
||||
stdout = ""
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
import itertools
|
||||
import os
|
||||
import platform
|
||||
import shlex
|
||||
import oslex
|
||||
import subprocess
|
||||
import sys
|
||||
import tempfile
|
||||
|
@ -384,10 +384,7 @@ def printable_shell_command(cmd_list):
|
|||
Returns:
|
||||
str: Shell-escaped command string.
|
||||
"""
|
||||
if platform.system() == "Windows":
|
||||
return subprocess.list2cmdline(cmd_list)
|
||||
else:
|
||||
return shlex.join(cmd_list)
|
||||
return oslex.join(cmd_list)
|
||||
|
||||
|
||||
def main():
|
||||
|
|
|
@ -237,6 +237,12 @@ mixpanel==4.10.1
|
|||
# via
|
||||
# -c requirements/common-constraints.txt
|
||||
# -r requirements/requirements.in
|
||||
monotonic==1.6
|
||||
# via
|
||||
# -c requirements/common-constraints.txt
|
||||
# posthog
|
||||
mslex==1.3.0
|
||||
# via oslex
|
||||
multidict==6.4.3
|
||||
# via
|
||||
# -c requirements/common-constraints.txt
|
||||
|
@ -255,6 +261,8 @@ openai==1.75.0
|
|||
# via
|
||||
# -c requirements/common-constraints.txt
|
||||
# litellm
|
||||
oslex==0.1.3
|
||||
# via -r requirements/requirements.in
|
||||
packaging==24.2
|
||||
# via
|
||||
# -c requirements/common-constraints.txt
|
||||
|
@ -515,6 +523,6 @@ zipp==3.21.0
|
|||
# via
|
||||
# -c requirements/common-constraints.txt
|
||||
# importlib-metadata
|
||||
|
||||
|
||||
tree-sitter==0.23.2; python_version < "3.10"
|
||||
tree-sitter==0.24.0; python_version >= "3.10"
|
||||
|
|
|
@ -28,6 +28,7 @@ watchfiles
|
|||
socksio
|
||||
pip
|
||||
pillow
|
||||
oslex
|
||||
google-generativeai
|
||||
|
||||
# The proper dependency is networkx[default], but this brings
|
||||
|
|
|
@ -1,3 +1,4 @@
|
|||
import os
|
||||
import unittest
|
||||
from unittest.mock import MagicMock, patch
|
||||
|
||||
|
@ -36,6 +37,15 @@ class TestLinter(unittest.TestCase):
|
|||
result = self.linter.run_cmd("test_cmd", "test_file.py", "code")
|
||||
self.assertIsNone(result)
|
||||
|
||||
def test_run_cmd_win(self):
|
||||
if os.name != "nt":
|
||||
self.skipTest("This test only runs on Windows")
|
||||
from pathlib import Path
|
||||
root = Path(__file__).parent.parent.parent.absolute().as_posix()
|
||||
linter = Linter(encoding="utf-8", root=root)
|
||||
result = linter.run_cmd("dir", "tests\\basic", "code")
|
||||
self.assertIsNone(result)
|
||||
|
||||
@patch("subprocess.Popen")
|
||||
def test_run_cmd_with_errors(self, mock_popen):
|
||||
mock_process = MagicMock()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue