Skip to content

SWE-agent takes a GitHub issue and tries to automatically fix it, using your LM of choice. It can also be employed for offensive cybersecurity or competitive coding challenges. [NeurIPS 2024]

Tools: Have flake8 show line numbers

Kilian Lieretc74d71449953
diff --git a/tools/defaults/lib/default_utils.py b/tools/defaults/lib/default_utils.py
index e59604d4..ac6564bf 100644
--- a/tools/defaults/lib/default_utils.py
+++ b/tools/defaults/lib/default_utils.py
@@ -178,6 +178,13 @@ class WindowedFile:
def get_window_text(
self, *, line_numbers: bool = False, status_line: bool = False, pre_post_line: bool = False
) -> str:
+ """Get the text in the current display window with optional status/extra information
+
+ Args:
+ line_numbers: include line numbers in the output
+ status_line: include the status line in the output (file path, total lines)
+ pre_post_line: include the pre/post line in the output (number of lines above/below)
+ """
start_line, end_line = self.line_range
lines = self.text.split("\n")[start_line : end_line + 1]
out_lines = []
diff --git a/tools/defaults/lib/flake8_utils.py b/tools/defaults/lib/flake8_utils.py
index 492e2115..1ad05507 100644
--- a/tools/defaults/lib/flake8_utils.py
+++ b/tools/defaults/lib/flake8_utils.py
@@ -76,7 +76,7 @@ def _update_previous_errors(
def format_flake8_output(
input_string: str,
- show_line_numbers: bool = False,
+ show_line_numbers: bool = True,
*,
previous_errors_string: str = "",
replacement_window: Optional[Tuple[int, int]] = None,
@@ -108,7 +108,7 @@ def format_flake8_output(
if not show_line_numbers:
lines.append(f"- {error.problem}")
else:
- lines.append(f"- {error.line_number}:{error.col_number} {error.problem}")
+ lines.append(f"- line {error.line_number} col {error.col_number}: {error.problem}")
return "\n".join(lines)