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]
chore: update pre-commit hooks (#730)
pre-commit-ci[bot]8884cc13c543
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yamlindex 2b7fb1b8..b26712f1 100644--- a/.pre-commit-config.yaml+++ b/.pre-commit-config.yaml@@ -22,7 +22,7 @@ repos:exclude: pyproject.toml- repo: https://github.com/astral-sh/ruff-pre-commit- rev: v0.5.7+ rev: v0.6.1hooks:# Run the linter.- id: ruffdiff --git a/tests/conftest.py b/tests/conftest.pyindex 8d1fcaf9..c5d5b5ad 100644--- a/tests/conftest.py+++ b/tests/conftest.py@@ -14,28 +14,28 @@ sys.path.insert(0, str(root_dir))sys.path.insert(1, str(package_dir))def test_data_path() -> Path:p = _this_dir / "test_data"assert p.is_dir()return pdef test_trajectories_path(test_data_path) -> Path:p = test_data_path / "trajectories"assert p.is_dir()return pdef test_data_sources_path(test_data_path) -> Path:p = test_data_path / "data_sources"assert p.is_dir()return pdef test_trajectory_path(test_trajectories_path) -> Path:traj = (test_trajectories_path@@ -46,6 +46,6 @@ def test_trajectory_path(test_trajectories_path) -> Path:return trajdef test_trajectory(test_trajectory_path):return json.loads(test_trajectory_path.read_text())diff --git a/tests/test_env.py b/tests/test_env.pyindex 58f9169e..a543e3d4 100644--- a/tests/test_env.py+++ b/tests/test_env.py@@ -58,27 +58,27 @@ def swe_env_context(env_args):env.close()def test_init_swe_env(test_env_args):with swe_env_context(test_env_args) as env:env.reset()def test_init_swe_env_conservative_clone(test_env_args):with mock.patch.dict("os.environ", {"SWE_AGENT_CLONE_METHOD": "full"}):with swe_env_context(test_env_args) as env:env.reset()def test_init_swe_env_non_persistent(test_env_args):test_env_args = dataclasses.replace(test_env_args, container_name=None)with swe_env_context(test_env_args) as env:env.reset()def test_init_swe_env_cached_task_image(test_env_args):test_env_args = dataclasses.replace(test_env_args, cache_task_images=True, container_name=None)start = time.perf_counter()@@ -105,7 +105,7 @@ def test_init_swe_env_cached_task_image(test_env_args):client.images.remove(image.id)def test_execute_setup_script(tmp_path, test_env_args):test_script = "echo 'hello world'"script_path = Path(tmp_path / "test_script.sh")@@ -115,7 +115,7 @@ def test_execute_setup_script(tmp_path, test_env_args):env.reset()def test_execute_environment(tmp_path, test_env_args, capsys):test_env = {"python": "3.6",@@ -134,7 +134,7 @@ def test_execute_environment(tmp_path, test_env_args, capsys):assert "Cloned python conda environment" not in outdef test_execute_environment_default(test_env_args):env_config_paths = (CONFIG_DIR / "environment_setup").iterdir()assert env_config_paths@@ -151,7 +151,7 @@ def test_execute_environment_default(test_env_args):env.reset()def test_execute_environment_clone_python(tmp_path, test_env_args, capsys):"""This should clone the existing python 3.10 conda environment for speedup"""test_env = {@@ -171,7 +171,7 @@ def test_execute_environment_clone_python(tmp_path, test_env_args, capsys):assert "Cloned python conda environment" in outdef test_open_pr(test_env_args):test_env_args = dataclasses.replace(test_env_args,@@ -183,21 +183,21 @@ def test_open_pr(test_env_args):env.open_pr(_dry_run=True, trajectory=[])def test_interrupt_close(test_env_args):with swe_env_context(test_env_args) as env:env.reset()env.interrupt()def test_communicate_old(test_env_args):with mock.patch.dict("os.environ", {"SWE_AGENT_COMMUNICATE_METHOD": "processes"}):with swe_env_context(test_env_args) as env:env.reset()def test_env_with_hook(test_env_args):with swe_env_context(test_env_args) as env:env.add_hook(EnvHook())diff --git a/tests/test_models.py b/tests/test_models.pyindex 4ad20986..ac3f57c8 100644--- a/tests/test_models.py+++ b/tests/test_models.py@@ -7,7 +7,7 @@ import pytestfrom sweagent.agent.models import GroqModel, ModelArguments, OpenAIModel, TogetherModeldef openai_mock_client():model = Mock()response = Mock()@@ -21,7 +21,7 @@ def openai_mock_client():return modeldef mock_together_response():return {"choices": [{"text": "<human>Hello</human>"}],diff --git a/tests/test_replay.py b/tests/test_replay.pyindex 558633dc..c45c15a0 100644--- a/tests/test_replay.py+++ b/tests/test_replay.py@@ -9,7 +9,7 @@ from run_replay import get_args, mainfrom sweagent import CONFIG_DIRdef swe_agent_test_repo_clone(tmp_path):local_repo_path = tmp_path / "test-repo"clone_cmd = ["git", "clone", "https://github.com/swe-agent/test-repo", local_repo_path]@@ -17,7 +17,7 @@ def swe_agent_test_repo_clone(tmp_path):return local_repo_pathdef swe_agent_test_repo_traj(test_trajectories_path) -> Path:p = (test_trajectories_path@@ -28,14 +28,14 @@ def swe_agent_test_repo_traj(test_trajectories_path) -> Path:return pdef swe_agent_test_repo_local_problem_stmt(swe_agent_test_repo_clone) -> Path:problem_stmt = swe_agent_test_repo_clone / "problem_statements" / "1.md"assert problem_stmt.is_file()return problem_stmt@pytest.mark.parametrize("problem_statement_source", ["github", "local"])def test_model_replay_github_repo(tmpdir,@@ -64,7 +64,7 @@ def test_model_replay_github_repo(main(**vars(args), forward_args=remaining_args)def test_model_replay_from_json(test_trajectories_path, test_data_sources_path):traj_path = (test_trajectories_path@@ -96,7 +96,7 @@ def test_run_cli_help():subprocess.run(args, check=True)@pytest.mark.parametrize("problem_statement_source", ["github", "local"])def test_model_replay_local_repo(swe_agent_test_repo_clone, swe_agent_test_repo_traj, problem_statement_source):local_repo_path = swe_agent_test_repo_clonediff --git a/tests/test_run.py b/tests/test_run.pyindex c8f894ce..b5bfa5ad 100644--- a/tests/test_run.py+++ b/tests/test_run.py@@ -17,7 +17,7 @@ from sweagent.agent.models import ModelArgumentsfrom sweagent.environment.swe_env import EnvironmentArguments, SWEEnvdef test_run_cli_help():args = ["python",@@ -27,7 +27,7 @@ def test_run_cli_help():subprocess.run(args, check=True)def open_pr_hook_init_for_sop():hook = OpenPRHook()hook._token = os.environ.get("GITHUB_TOKEN", "")@@ -37,7 +37,7 @@ def open_pr_hook_init_for_sop():return hookdef info_dict():return {"submission": "asdf",@@ -100,7 +100,7 @@ class RaisesExceptionHook(MainHook):raise ValueError(msg)def test_script_args():return ScriptArguments(suffix="",@@ -128,7 +128,7 @@ def test_script_args():)def test_exception_raised(test_script_args: ScriptArguments):assert test_script_args.raise_exceptionsmain = Main(test_script_args)@@ -137,7 +137,7 @@ def test_exception_raised(test_script_args: ScriptArguments):main.main()class CreateFakeLogFile(MainHook):"""Testing the skip functionality"""@@ -153,21 +153,21 @@ class CreateFakeLogFile(MainHook):(self._traj_dir / f"{instance_id}.traj").write_text(json.dumps(dct))def test_existing_corrupted_args(test_script_args: ScriptArguments):main = Main(test_script_args)main.add_hook(CreateFakeLogFile())main.main()def test_main_hook(test_script_args: ScriptArguments):main = Main(test_script_args)main.add_hook(MainHook())main.main()def test_agent_with_hook(test_script_args: ScriptArguments):main = Main(test_script_args)main.agent.add_hook(AgentHook())@@ -177,7 +177,7 @@ def test_agent_with_hook(test_script_args: ScriptArguments):PERSISTENT_CONTAINER_NAME = "sweagent-test-persistent-container"def _cleanup_persistent_container():yieldclient = docker.from_env()@@ -185,7 +185,7 @@ def _cleanup_persistent_container():container.remove(force=True)@pytest.mark.usefixtures("_cleanup_persistent_container")def test_agent_persistent_container(test_script_args: ScriptArguments, capsys):test_script_args = dataclasses.replace(diff --git a/tests/test_server.py b/tests/test_server.pyindex 304fcfcd..6b9b2aa0 100644--- a/tests/test_server.py+++ b/tests/test_server.py@@ -6,14 +6,14 @@ from flask_socketio import SocketIOTestClientfrom sweagent.api.server import app, socketiodef client():with app.test_client() as client:with app.app_context():yield clientdef socket_client():client = SocketIOTestClient(app, socketio)yield client