Skip to content

Commit e3809f0

Browse files
committed
fix: add anthropic to dev deps, format files
1 parent 411e8ae commit e3809f0

4 files changed

Lines changed: 52 additions & 48 deletions

File tree

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ requires-python = ">=3.11"
66
dependencies = ["aiohttp>=3.9.0", "aiodocker>=0.22.0", "pydantic>=2.5.0", "pydantic-settings>=2.1.0", "litellm>=1.20.0", "typer>=0.9.0", "rich>=13.7.0", "aiosqlite>=0.19.0", "aiofiles>=23.2.0", "pyarrow>=15.0.0", "huggingface_hub>=0.20.0", "tenacity>=8.2.0", "structlog>=24.1.0"]
77

88
[project.optional-dependencies]
9-
dev = ["pytest>=8.0.0", "pytest-asyncio>=0.23.0", "pytest-cov>=4.1.0", "mypy>=1.8.0", "ruff>=0.2.0"]
9+
dev = ["pytest>=8.0.0", "pytest-asyncio>=0.23.0", "pytest-cov>=4.1.0", "mypy>=1.8.0", "ruff>=0.2.0", "anthropic>=0.18.0"]
1010

1111
[project.scripts]
1212
swe-forge = "swe_forge.__main__:main"

src/swe_forge/swe/models.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,7 @@ class SweTask(BaseModel):
101101
fail_to_pass: list[str] = Field(default_factory=list)
102102
pass_to_pass: list[str] = Field(default_factory=list)
103103
install_config: dict[str, Any] = Field(
104-
default_factory=dict,
105-
description="Agentic-detected install configuration"
104+
default_factory=dict, description="Agentic-detected install configuration"
106105
)
107106
meta: dict[str, str] = Field(default_factory=dict)
108107
prompt: str = ""
@@ -125,14 +124,14 @@ def validate_repo_name_field(cls, v: str) -> str:
125124

126125
def is_install_ready(self) -> bool:
127126
"""Check if install_config has been populated by agent.
128-
127+
129128
Returns:
130129
True if agent has detected working install commands.
131130
"""
132131
return bool(
133-
self.install_config.get("install_commands") or
134-
self.install_config.get("commands")
132+
self.install_config.get("install_commands")
133+
or self.install_config.get("commands")
135134
) and self.install_config.get("validated", False)
136-
135+
137136
def has_tests(self) -> bool:
138137
return bool(self.fail_to_pass or self.pass_to_pass)

tests/test_swe/test_agentic_config.py

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212

1313
class TestRepositoryConfig:
1414
"""Test RepositoryConfig dataclass."""
15-
15+
1616
def test_config_creation(self):
1717
"""Test basic config creation."""
1818
config = RepositoryConfig(
@@ -24,11 +24,11 @@ def test_config_creation(self):
2424
docker_image="python:3.11-slim",
2525
validated=True,
2626
)
27-
27+
2828
assert config.python_version == "3.11"
2929
assert config.package_manager == "poetry"
3030
assert config.is_valid() is True
31-
31+
3232
def test_config_invalid_missing_fields(self):
3333
"""Test config validation with missing fields."""
3434
# Missing install_commands
@@ -40,7 +40,7 @@ def test_config_invalid_missing_fields(self):
4040
validated=True,
4141
)
4242
assert config1.is_valid() is False
43-
43+
4444
# Missing test_command
4545
config2 = RepositoryConfig(
4646
python_version="3.11",
@@ -50,7 +50,7 @@ def test_config_invalid_missing_fields(self):
5050
validated=True,
5151
)
5252
assert config2.is_valid() is False
53-
53+
5454
def test_config_not_validated(self):
5555
"""Test config that wasn't validated."""
5656
config = RepositoryConfig(
@@ -60,14 +60,14 @@ def test_config_not_validated(self):
6060
test_command="pytest",
6161
validated=False, # Not validated!
6262
)
63-
63+
6464
# Should be invalid even if fields are filled
6565
assert config.is_valid() is False
6666

6767

6868
class TestSubmitConfigArgs:
6969
"""Test SubmitConfigArgs validation."""
70-
70+
7171
def test_submit_config_args(self):
7272
"""Test SubmitConfigArgs creation."""
7373
args = SubmitConfigArgs(
@@ -77,23 +77,23 @@ def test_submit_config_args(self):
7777
test_command="pytest",
7878
test_framework="pytest",
7979
)
80-
80+
8181
assert args.python_version == "3.11"
8282
assert args.package_manager == "poetry"
8383

8484

8585
class TestEmptyConfig:
8686
"""Test that empty config is invalid."""
87-
87+
8888
def test_empty_config_invalid(self):
8989
"""Test that empty config is invalid."""
9090
config = RepositoryConfig()
91-
91+
9292
# Should be invalid - no fields set
9393
assert config.is_valid() is False
9494
assert config.python_version == ""
9595
assert config.package_manager == ""
96-
96+
9797
def test_config_with_validation_errors(self):
9898
"""Test config with validation errors."""
9999
config = RepositoryConfig(
@@ -103,7 +103,7 @@ def test_config_with_validation_errors(self):
103103
test_command="",
104104
validated=False,
105105
)
106-
106+
107107
assert config.is_valid() is False
108108
assert len(config.validation_errors) >= 0 # May have no errors explicitly
109109

tests/test_swe/test_dataset_validator.py

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
class TestValidationResult:
1717
"""Test ValidationResult dataclass."""
18-
18+
1919
def test_result_creation(self):
2020
"""Test basic result creation."""
2121
result = ValidationResult(
@@ -25,11 +25,11 @@ def test_result_creation(self):
2525
install_commands_worked=["pip install -e ."],
2626
test_results={"base:pytest": False, "patch:pytest": True},
2727
)
28-
28+
2929
assert result.passed is True
3030
assert result.phase == "complete"
3131
assert len(result.install_commands_worked) == 1
32-
32+
3333
def test_result_to_dict(self):
3434
"""Test result serialization."""
3535
result = ValidationResult(
@@ -39,34 +39,34 @@ def test_result_to_dict(self):
3939
error_message="Install failed",
4040
install_commands_failed=["pip install -e ."],
4141
)
42-
42+
4343
data = result.to_dict()
44-
44+
4545
assert data["task_id"] == "test-002"
4646
assert data["passed"] is False
4747
assert data["error_message"] == "Install failed"
48-
48+
4949
def test_failed_install_tracking(self):
5050
"""Test tracking of failed install commands."""
5151
result = ValidationResult(task_id="test-003", passed=False, phase="install")
52-
52+
5353
result.install_commands_worked.append("apt-get update")
5454
result.install_commands_failed.append("pip install broken-package")
55-
55+
5656
assert len(result.install_commands_worked) == 1
5757
assert len(result.install_commands_failed) == 1
5858

5959

6060
class TestDatasetValidationReport:
6161
"""Test DatasetValidationReport."""
62-
62+
6363
def test_empty_report(self):
6464
"""Test empty report."""
6565
report = DatasetValidationReport()
66-
66+
6767
assert report.total_tasks == 0
6868
assert report.pass_rate == 0.0
69-
69+
7070
def test_report_with_results(self):
7171
"""Test report with validation results."""
7272
report = DatasetValidationReport(
@@ -76,40 +76,45 @@ def test_report_with_results(self):
7676
validation_results=[
7777
ValidationResult(task_id="t1", passed=True, phase="complete"),
7878
ValidationResult(task_id="t2", passed=True, phase="complete"),
79-
ValidationResult(task_id="t3", passed=False, phase="test_base", error_message="Test failed"),
79+
ValidationResult(
80+
task_id="t3",
81+
passed=False,
82+
phase="test_base",
83+
error_message="Test failed",
84+
),
8085
],
8186
)
82-
83-
assert report.pass_rate == 2/3
87+
88+
assert report.pass_rate == 2 / 3
8489
assert report.failed_tasks == 1
85-
90+
8691
def test_report_to_json(self):
8792
"""Test report JSON serialization."""
8893
report = DatasetValidationReport(
8994
total_tasks=2,
9095
passed_tasks=1,
9196
failed_tasks=1,
9297
)
93-
98+
9499
json_str = report.to_json()
95100
data = json.loads(json_str)
96-
101+
97102
assert data["total_tasks"] == 2
98103
assert data["pass_rate"] == 0.5
99104

100105

101106
class TestPrintValidationReport:
102107
"""Test print_validation_report function."""
103-
108+
104109
def test_print_empty_report(self, capsys):
105110
"""Test printing empty report."""
106111
report = DatasetValidationReport()
107112
print_validation_report(report)
108-
113+
109114
captured = capsys.readouterr()
110115
assert "Total tasks: 0" in captured.out
111116
assert "Pass rate:" in captured.out
112-
117+
113118
def test_print_report_with_results(self, capsys):
114119
"""Test printing report with results."""
115120
report = DatasetValidationReport(
@@ -119,16 +124,16 @@ def test_print_report_with_results(self, capsys):
119124
validation_results=[
120125
ValidationResult(task_id="t1", passed=True, phase="complete"),
121126
ValidationResult(
122-
task_id="t2",
123-
passed=False,
127+
task_id="t2",
128+
passed=False,
124129
phase="test_base",
125-
error_message="Test failed on base"
130+
error_message="Test failed on base",
126131
),
127132
],
128133
)
129-
134+
130135
print_validation_report(report)
131-
136+
132137
captured = capsys.readouterr()
133138
assert "Passed: 3" in captured.out
134139
assert "Failed: 2" in captured.out
@@ -137,7 +142,7 @@ def test_print_report_with_results(self, capsys):
137142

138143
class TestSweTaskInstallConfig:
139144
"""Test SweTask with install_config field."""
140-
145+
141146
def test_task_with_install_config(self):
142147
"""Test task creation with install_config."""
143148
task = SweTask(
@@ -152,10 +157,10 @@ def test_task_with_install_config(self):
152157
"validated": True,
153158
},
154159
)
155-
160+
156161
assert task.install_config["python_version"] == "3.11"
157162
assert task.install_config["package_manager"] == "poetry"
158-
163+
159164
def test_task_is_install_ready(self):
160165
"""Test is_install_ready method."""
161166
# Not ready
@@ -164,7 +169,7 @@ def test_task_is_install_ready(self):
164169
install_config={},
165170
)
166171
assert task1.is_install_ready() is False
167-
172+
168173
# Ready
169174
task2 = SweTask(
170175
id="test-002",

0 commit comments

Comments
 (0)