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]

Add very basic pre-commit config (#62)

Kilian Lieret91f78d2a5c9c
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
new file mode 100644
index 00000000..dbd0a53b
--- /dev/null
+++ b/.pre-commit-config.yaml
@@ -0,0 +1,20 @@
+ci:
+ autoupdate_commit_msg: "chore: update pre-commit hooks"
+
+repos:
+ - repo: https://github.com/pre-commit/pre-commit-hooks
+ rev: "v4.5.0"
+ hooks:
+ - id: check-added-large-files
+ - id: check-case-conflict
+ - id: check-merge-conflict
+ - id: check-symlinks
+ - id: mixed-line-ending
+ - id: detect-private-key
+ - id: check-ast
+
+ - repo: https://github.com/pycqa/flake8
+ rev: '4.0.1' # Use the latest flake8 version or the one you prefer
+ hooks:
+ - id: flake8
+ args: ['--select=F821,F822,F831,E111,E112,E113,E999,E902']
diff --git a/evaluation/aggregate_results.py b/evaluation/aggregate_results.py
index 35978d7a..dc94d8d3 100644
--- a/evaluation/aggregate_results.py
+++ b/evaluation/aggregate_results.py
@@ -90,13 +90,13 @@ def convert_experiments_to_rows(folder_name, runs_max):
continue
try:
- if "run-" in run:
- run = int(run.split("run-")[-1].split("-")[0].replace("_", "").strip())
- else:
- run = int(run.split("run")[-1].split("-")[0].replace("_", "").strip())
+ if "run-" in run:
+ run = int(run.split("run-")[-1].split("-")[0].replace("_", "").strip())
+ else:
+ run = int(run.split("run")[-1].split("-")[0].replace("_", "").strip())
except Exception as e:
- print(run)
- raise e
+ print(run)
+ raise e
if runs_max is not None and run > runs_max:
continue
diff --git a/sweagent/agent/agents.py b/sweagent/agent/agents.py
index bbe2c89a..593b6e71 100644
--- a/sweagent/agent/agents.py
+++ b/sweagent/agent/agents.py
@@ -549,12 +549,12 @@ class Agent:
try:
output = env.communicate(commands)
if env.returncode != 0:
- raise RuntimeError(f"Nonzero return code: {env.returncode}\nOutput: {output}")
+ raise RuntimeError(f"Nonzero return code: {env.returncode}\nOutput: {output}")
except KeyboardInterrupt:
- raise
+ raise
except Exception as e:
- logger.warning("Failed to set environment variables")
- raise e
+ logger.warning("Failed to set environment variables")
+ raise e
command_files = list()
for file in self.config.command_files:
datum = dict()