From b600e179108e154db7f435132b2438294216853a Mon Sep 17 00:00:00 2001 From: Paul Gauthier Date: Sat, 18 May 2024 17:42:04 -0700 Subject: [PATCH] Added traceback information to the linting output. --- aider/linter.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/aider/linter.py b/aider/linter.py index 1d69651d3..5eeaa3e0a 100644 --- a/aider/linter.py +++ b/aider/linter.py @@ -13,6 +13,7 @@ from grep_ast import TreeContext, filename_to_lang # tree_sitter is throwing a FutureWarning warnings.simplefilter("ignore", category=FutureWarning) from tree_sitter_languages import get_parser # noqa: E402 +import traceback class Linter: @@ -72,7 +73,7 @@ class Linter: def lint_pycompile(fname, code): try: - #py_compile.compile(fname, doraise=True) + # py_compile.compile(fname, doraise=True) compile(code, fname, 'exec') return except ValueError as err: @@ -83,7 +84,10 @@ def lint_pycompile(fname, code): dump(line_numbers) - # todo: print out the Traceback, but only the last call stack + # Print out the Traceback, but only the last call stack + tb_lines = traceback.format_exception(type(err), err, err.__traceback__) + last_call_stack = ''.join(tb_lines[-2:]) + res += last_call_stack res += '\n' res += tree_context(fname, code, line_numbers)