mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-29 08:44:59 +00:00
do not try pexpect on windows; fix time.clock error on windows
This commit is contained in:
parent
bcb3fa1b47
commit
ce397b71e8
4 changed files with 5 additions and 23 deletions
|
@ -15,7 +15,6 @@ from prompt_toolkit.shortcuts import CompleteStyle, PromptSession
|
||||||
from prompt_toolkit.styles import Style
|
from prompt_toolkit.styles import Style
|
||||||
from pygments.lexers import MarkdownLexer, guess_lexer_for_filename
|
from pygments.lexers import MarkdownLexer, guess_lexer_for_filename
|
||||||
from pygments.token import Token
|
from pygments.token import Token
|
||||||
from pygments.util import ClassNotFound
|
|
||||||
from rich.console import Console
|
from rich.console import Console
|
||||||
from rich.style import Style as RichStyle
|
from rich.style import Style as RichStyle
|
||||||
from rich.text import Text
|
from rich.text import Text
|
||||||
|
@ -83,7 +82,7 @@ class AutoCompleter(Completer):
|
||||||
continue
|
continue
|
||||||
try:
|
try:
|
||||||
lexer = guess_lexer_for_filename(fname, content)
|
lexer = guess_lexer_for_filename(fname, content)
|
||||||
except ClassNotFound:
|
except Exception: # On Windows, bad ref to time.clock which is deprecated
|
||||||
continue
|
continue
|
||||||
tokens = list(lexer.get_tokens(content))
|
tokens = list(lexer.get_tokens(content))
|
||||||
self.words.update(
|
self.words.update(
|
||||||
|
|
|
@ -14,7 +14,6 @@ from diskcache import Cache
|
||||||
from grep_ast import TreeContext, filename_to_lang
|
from grep_ast import TreeContext, filename_to_lang
|
||||||
from pygments.lexers import guess_lexer_for_filename
|
from pygments.lexers import guess_lexer_for_filename
|
||||||
from pygments.token import Token
|
from pygments.token import Token
|
||||||
from pygments.util import ClassNotFound
|
|
||||||
from tqdm import tqdm
|
from tqdm import tqdm
|
||||||
|
|
||||||
from aider.dump import dump
|
from aider.dump import dump
|
||||||
|
@ -253,7 +252,7 @@ class RepoMap:
|
||||||
|
|
||||||
try:
|
try:
|
||||||
lexer = guess_lexer_for_filename(fname, code)
|
lexer = guess_lexer_for_filename(fname, code)
|
||||||
except ClassNotFound:
|
except Exception: # On Windows, bad ref to time.clock which is deprecated
|
||||||
return
|
return
|
||||||
|
|
||||||
tokens = list(lexer.get_tokens(code))
|
tokens = list(lexer.get_tokens(code))
|
||||||
|
|
|
@ -3,6 +3,8 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
from io import BytesIO
|
from io import BytesIO
|
||||||
|
|
||||||
|
import pexpect
|
||||||
|
|
||||||
|
|
||||||
def run_cmd(command):
|
def run_cmd(command):
|
||||||
import sys
|
import sys
|
||||||
|
@ -10,9 +12,7 @@ def run_cmd(command):
|
||||||
if not sys.stdin.isatty():
|
if not sys.stdin.isatty():
|
||||||
return run_cmd_subprocess(command)
|
return run_cmd_subprocess(command)
|
||||||
|
|
||||||
try:
|
if hasattr(pexpect, "spawn"):
|
||||||
import pexpect # noqa: F401
|
|
||||||
except ImportError:
|
|
||||||
return run_cmd_subprocess(command)
|
return run_cmd_subprocess(command)
|
||||||
|
|
||||||
return run_cmd_pexpect(command)
|
return run_cmd_pexpect(command)
|
||||||
|
|
|
@ -9,19 +9,3 @@ def test_run_cmd_echo():
|
||||||
|
|
||||||
assert exit_code == 0
|
assert exit_code == 0
|
||||||
assert output.strip() == "Hello, World!"
|
assert output.strip() == "Hello, World!"
|
||||||
|
|
||||||
|
|
||||||
def test_run_cmd_echo_with_quotes():
|
|
||||||
command = 'echo "Hello, World!"'
|
|
||||||
exit_code, output = run_cmd(command)
|
|
||||||
|
|
||||||
assert exit_code == 0
|
|
||||||
assert output.strip() == "Hello, World!"
|
|
||||||
|
|
||||||
|
|
||||||
def test_run_cmd_invalid_command():
|
|
||||||
command = "invalid_command_that_does_not_exist"
|
|
||||||
exit_code, output = run_cmd(command)
|
|
||||||
|
|
||||||
assert exit_code != 0
|
|
||||||
assert "command not found" in output.lower() or "is not recognized" in output.lower()
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue