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]

Simplify duplication counting

Kilian Lieret37d041c845c0
diff --git a/sweagent/tools/commands.py b/sweagent/tools/commands.py
index e4935c8d..12998678 100644
--- a/sweagent/tools/commands.py
+++ b/sweagent/tools/commands.py
@@ -185,11 +185,9 @@ class Command(BaseModel):
raise ValueError(msg)
if not arg.required:
found_optional = True
- duplicates = {
- name
- for name in {arg.name for arg in self.arguments}
- if [arg.name for arg in self.arguments].count(name) > 1
- }
+ from collections import Counter
+ name_counts = Counter(arg.name for arg in self.arguments)
+ duplicates = {name for name, count in name_counts.items() if count > 1}
if duplicates:
msg = f"Command '{self.name}': Duplicate argument names: {duplicates}"
raise ValueError(msg)