mirror of
https://github.com/Aider-AI/aider.git
synced 2025-06-02 18:54:59 +00:00
Updated linter to display relevant error lines and context.
This commit is contained in:
parent
ee2e633380
commit
828a5264b0
1 changed files with 6 additions and 4 deletions
|
@ -21,8 +21,9 @@ class Linter:
|
||||||
py_cmd = f"flake8 --select={fatal} --show-source" # noqa: F841
|
py_cmd = f"flake8 --select={fatal} --show-source" # noqa: F841
|
||||||
|
|
||||||
self.languages = dict(
|
self.languages = dict(
|
||||||
# python=self.py_lint,
|
python=self.py_lint,
|
||||||
python="/Users/gauthier/Projects/aider/tmp.sh"
|
#python="/Users/gauthier/Projects/aider/tmp.sh"
|
||||||
|
#python="flake8 --show-source"
|
||||||
)
|
)
|
||||||
|
|
||||||
def set_linter(self, lang, cmd):
|
def set_linter(self, lang, cmd):
|
||||||
|
@ -97,7 +98,8 @@ def lint_python_compile(fname, code):
|
||||||
|
|
||||||
tb_lines = tb_lines[:1] + tb_lines[last_file_i + 1 :]
|
tb_lines = tb_lines[:1] + tb_lines[last_file_i + 1 :]
|
||||||
|
|
||||||
res = "".join(tb_lines)
|
res = "# Fix this error:\n\n"
|
||||||
|
res += "".join(tb_lines)
|
||||||
res += "\n"
|
res += "\n"
|
||||||
res += tree_context(fname, code, line_numbers)
|
res += tree_context(fname, code, line_numbers)
|
||||||
return res
|
return res
|
||||||
|
@ -140,7 +142,7 @@ def tree_context(fname, code, line_nums):
|
||||||
context.add_lines_of_interest(line_nums)
|
context.add_lines_of_interest(line_nums)
|
||||||
context.add_context()
|
context.add_context()
|
||||||
s = "s" if len(line_nums) > 1 else ""
|
s = "s" if len(line_nums) > 1 else ""
|
||||||
output = f"# Fix the error{s}, see relevant line{s} below marked with █.\n\n"
|
output = f"## See relevant line{s} below marked with █.\n\n"
|
||||||
output += fname + ":\n"
|
output += fname + ":\n"
|
||||||
output += context.format()
|
output += context.format()
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue