mirror of
https://github.com/Aider-AI/aider.git
synced 2025-05-21 21:04:59 +00:00
Add linter output to the dump for debugging
This commit is contained in:
parent
9c24d41d41
commit
5edce8ae1b
2 changed files with 9 additions and 8 deletions
|
@ -6,12 +6,12 @@ import subprocess
|
||||||
import sys
|
import sys
|
||||||
import traceback
|
import traceback
|
||||||
import warnings
|
import warnings
|
||||||
|
from contextlib import redirect_stdout
|
||||||
from dataclasses import dataclass
|
from dataclasses import dataclass
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
from grep_ast import TreeContext, filename_to_lang
|
from grep_ast import TreeContext, filename_to_lang
|
||||||
from tree_sitter_languages import get_parser # noqa: E402
|
from tree_sitter_languages import get_parser # noqa: E402
|
||||||
from contextlib import redirect_stdout
|
|
||||||
|
|
||||||
from aider.dump import dump # noqa: F401
|
from aider.dump import dump # noqa: F401
|
||||||
|
|
||||||
|
@ -51,6 +51,7 @@ class Linter:
|
||||||
)
|
)
|
||||||
stdout, _ = process.communicate()
|
stdout, _ = process.communicate()
|
||||||
errors = stdout.decode()
|
errors = stdout.decode()
|
||||||
|
dump(errors)
|
||||||
if process.returncode == 0:
|
if process.returncode == 0:
|
||||||
return # zero exit status
|
return # zero exit status
|
||||||
|
|
||||||
|
@ -88,19 +89,19 @@ class Linter:
|
||||||
cmd = self.languages.get(lang)
|
cmd = self.languages.get(lang)
|
||||||
|
|
||||||
if callable(cmd):
|
if callable(cmd):
|
||||||
linkres = cmd(fname, rel_fname, code)
|
lintres = cmd(fname, rel_fname, code)
|
||||||
elif cmd:
|
elif cmd:
|
||||||
linkres = self.run_cmd(cmd, rel_fname, code)
|
lintres = self.run_cmd(cmd, rel_fname, code)
|
||||||
else:
|
else:
|
||||||
linkres = basic_lint(rel_fname, code)
|
lintres = basic_lint(rel_fname, code)
|
||||||
|
|
||||||
if not linkres:
|
if not lintres:
|
||||||
return
|
return
|
||||||
|
|
||||||
res = "# Fix any errors below, if possible.\n\n"
|
res = "# Fix any errors below, if possible.\n\n"
|
||||||
res += linkres.text
|
res += lintres.text
|
||||||
res += "\n"
|
res += "\n"
|
||||||
res += tree_context(rel_fname, code, linkres.lines)
|
res += tree_context(rel_fname, code, lintres.lines)
|
||||||
|
|
||||||
return res
|
return res
|
||||||
|
|
||||||
|
|
|
@ -743,7 +743,7 @@ class TestCommands(TestCase):
|
||||||
commands.cmd_lint()
|
commands.cmd_lint()
|
||||||
|
|
||||||
# Check if the linter was called with the dirty file
|
# Check if the linter was called with the dirty file
|
||||||
mock_lint.assert_called_once_with(filename)
|
mock_lint.assert_called_once_with(Path(filename).name)
|
||||||
|
|
||||||
# Verify that the file is still dirty after linting
|
# Verify that the file is still dirty after linting
|
||||||
self.assertTrue(repo.is_dirty(filename))
|
self.assertTrue(repo.is_dirty(filename))
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue