mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-24 06:15:00 +00:00
Replace shlex with cross-platform oslex
This commit is contained in:
parent
5251a2452c
commit
d9aa3cb2d4
5 changed files with 11 additions and 9 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():
|
||||
|
|
|
@ -184,6 +184,8 @@ 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
|
||||
|
@ -202,6 +204,8 @@ openai==1.73.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
|
||||
|
|
|
@ -28,6 +28,7 @@ watchfiles
|
|||
socksio
|
||||
pip
|
||||
pillow
|
||||
oslex
|
||||
|
||||
# The proper dependency is networkx[default], but this brings
|
||||
# in matplotlib and a bunch of other deps
|
||||
|
|
|
@ -43,7 +43,7 @@ class TestLinter(unittest.TestCase):
|
|||
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")
|
||||
result = linter.run_cmd("dir", "tests\\basic", "code")
|
||||
self.assertIsNone(result)
|
||||
|
||||
@patch("subprocess.Popen")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue