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]
Fix: PatchFormatter to deal with empty patches
Kilian Lieret2106b70b278e
diff --git a/sweagent/environment/utils.py b/sweagent/environment/utils.pyindex 0bbbf823..d1663be4 100644--- a/sweagent/environment/utils.py+++ b/sweagent/environment/utils.py@@ -4,8 +4,9 @@ import hashlibimport jsonimport osimport re+from collections.abc import Callablefrom pathlib import Path-from typing import Any, Callable+from typing import Anyfrom datasets import load_dataset, load_from_diskfrom ghapi.all import GhApi@@ -554,6 +555,9 @@ class PatchFormatter:For example `starts=[1, 5, 18]`, `stops=[10, 13, 20]`should return `starts=[1, 18]`, `stops=[13, 20]`"""+ if not starts:+ assert not stops+ return [], []intervals = sorted(zip(starts, stops))merged = []@@ -578,6 +582,10 @@ class PatchFormatter:The first line is line 1.linenos: Whether to include line numbers"""+ if not starts:+ assert not stops+ return ""+assert len(starts) == len(stops)assert all(start >= 1 for start in starts)assert all(start < stop for start, stop in zip(starts, stops))