Skip to content

Commit 01f1a26

Browse files
committed
fix: PythonValidator.validate_dependencies() now checks pyproject.toml
The dependency validation only checked requirements.txt for declared dependencies, causing tasks that use pyproject.toml (cgen-deps-install-001, iamactionhunter-deps-install-001) to always score 0.0 even when the agent correctly added dependencies to [project].dependencies. Now falls through to parse pyproject.toml when requirements.txt is absent or empty. Updated all 8 ccb_build task copies of validators.py.
1 parent 77868ad commit 01f1a26

File tree

8 files changed

+312
-24
lines changed

8 files changed

+312
-24
lines changed

benchmarks/ccb_build/cgen-deps-install-001/tests/validators.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ def _is_valid_requirement(line: str) -> bool:
131131
def validate_dependencies(self) -> Tuple[bool, List[str]]:
132132
"""Check that at least some dependencies are declared."""
133133
errors = []
134-
135-
req_path = self.repo_path / "requirements.txt"
136134
has_deps = False
137135

136+
# Check requirements.txt
137+
req_path = self.repo_path / "requirements.txt"
138138
if req_path.exists():
139139
try:
140140
with open(req_path) as f:
@@ -146,9 +146,45 @@ def validate_dependencies(self) -> Tuple[bool, List[str]]:
146146
except Exception:
147147
pass
148148

149+
# Check pyproject.toml [project].dependencies
150+
if not has_deps:
151+
pyproject_path = self.repo_path / "pyproject.toml"
152+
if pyproject_path.exists():
153+
try:
154+
with open(pyproject_path) as f:
155+
content = f.read()
156+
# Look for a non-empty dependencies list under [project]
157+
in_project = False
158+
in_deps = False
159+
for line in content.splitlines():
160+
stripped = line.strip()
161+
if stripped == "[project]":
162+
in_project = True
163+
continue
164+
if in_project and stripped.startswith("[") and stripped != "[project]":
165+
in_project = False
166+
in_deps = False
167+
continue
168+
if in_project and stripped.startswith("dependencies"):
169+
in_deps = True
170+
# Handle inline list: dependencies = ["foo"]
171+
if '"' in stripped or "'" in stripped:
172+
has_deps = True
173+
break
174+
continue
175+
if in_deps:
176+
if stripped == "]":
177+
in_deps = False
178+
continue
179+
if stripped and not stripped.startswith("#"):
180+
has_deps = True
181+
break
182+
except Exception:
183+
pass
184+
149185
if not has_deps:
150186
errors.append(
151-
"No dependencies found in requirements.txt (expected for most projects)"
187+
"No dependencies found in requirements.txt or pyproject.toml (expected for most projects)"
152188
)
153189

154190
return len(errors) == 0, errors

benchmarks/ccb_build/codecoverage-deps-install-001/tests/validators.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ def _is_valid_requirement(line: str) -> bool:
131131
def validate_dependencies(self) -> Tuple[bool, List[str]]:
132132
"""Check that at least some dependencies are declared."""
133133
errors = []
134-
135-
req_path = self.repo_path / "requirements.txt"
136134
has_deps = False
137135

136+
# Check requirements.txt
137+
req_path = self.repo_path / "requirements.txt"
138138
if req_path.exists():
139139
try:
140140
with open(req_path) as f:
@@ -146,9 +146,45 @@ def validate_dependencies(self) -> Tuple[bool, List[str]]:
146146
except Exception:
147147
pass
148148

149+
# Check pyproject.toml [project].dependencies
150+
if not has_deps:
151+
pyproject_path = self.repo_path / "pyproject.toml"
152+
if pyproject_path.exists():
153+
try:
154+
with open(pyproject_path) as f:
155+
content = f.read()
156+
# Look for a non-empty dependencies list under [project]
157+
in_project = False
158+
in_deps = False
159+
for line in content.splitlines():
160+
stripped = line.strip()
161+
if stripped == "[project]":
162+
in_project = True
163+
continue
164+
if in_project and stripped.startswith("[") and stripped != "[project]":
165+
in_project = False
166+
in_deps = False
167+
continue
168+
if in_project and stripped.startswith("dependencies"):
169+
in_deps = True
170+
# Handle inline list: dependencies = ["foo"]
171+
if '"' in stripped or "'" in stripped:
172+
has_deps = True
173+
break
174+
continue
175+
if in_deps:
176+
if stripped == "]":
177+
in_deps = False
178+
continue
179+
if stripped and not stripped.startswith("#"):
180+
has_deps = True
181+
break
182+
except Exception:
183+
pass
184+
149185
if not has_deps:
150186
errors.append(
151-
"No dependencies found in requirements.txt (expected for most projects)"
187+
"No dependencies found in requirements.txt or pyproject.toml (expected for most projects)"
152188
)
153189

154190
return len(errors) == 0, errors

benchmarks/ccb_build/dotenv-expand-deps-install-001/tests/validators.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ def _is_valid_requirement(line: str) -> bool:
131131
def validate_dependencies(self) -> Tuple[bool, List[str]]:
132132
"""Check that at least some dependencies are declared."""
133133
errors = []
134-
135-
req_path = self.repo_path / "requirements.txt"
136134
has_deps = False
137135

136+
# Check requirements.txt
137+
req_path = self.repo_path / "requirements.txt"
138138
if req_path.exists():
139139
try:
140140
with open(req_path) as f:
@@ -146,9 +146,45 @@ def validate_dependencies(self) -> Tuple[bool, List[str]]:
146146
except Exception:
147147
pass
148148

149+
# Check pyproject.toml [project].dependencies
150+
if not has_deps:
151+
pyproject_path = self.repo_path / "pyproject.toml"
152+
if pyproject_path.exists():
153+
try:
154+
with open(pyproject_path) as f:
155+
content = f.read()
156+
# Look for a non-empty dependencies list under [project]
157+
in_project = False
158+
in_deps = False
159+
for line in content.splitlines():
160+
stripped = line.strip()
161+
if stripped == "[project]":
162+
in_project = True
163+
continue
164+
if in_project and stripped.startswith("[") and stripped != "[project]":
165+
in_project = False
166+
in_deps = False
167+
continue
168+
if in_project and stripped.startswith("dependencies"):
169+
in_deps = True
170+
# Handle inline list: dependencies = ["foo"]
171+
if '"' in stripped or "'" in stripped:
172+
has_deps = True
173+
break
174+
continue
175+
if in_deps:
176+
if stripped == "]":
177+
in_deps = False
178+
continue
179+
if stripped and not stripped.startswith("#"):
180+
has_deps = True
181+
break
182+
except Exception:
183+
pass
184+
149185
if not has_deps:
150186
errors.append(
151-
"No dependencies found in requirements.txt (expected for most projects)"
187+
"No dependencies found in requirements.txt or pyproject.toml (expected for most projects)"
152188
)
153189

154190
return len(errors) == 0, errors

benchmarks/ccb_build/dotnetkoans-deps-install-001/tests/validators.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ def _is_valid_requirement(line: str) -> bool:
131131
def validate_dependencies(self) -> Tuple[bool, List[str]]:
132132
"""Check that at least some dependencies are declared."""
133133
errors = []
134-
135-
req_path = self.repo_path / "requirements.txt"
136134
has_deps = False
137135

136+
# Check requirements.txt
137+
req_path = self.repo_path / "requirements.txt"
138138
if req_path.exists():
139139
try:
140140
with open(req_path) as f:
@@ -146,9 +146,45 @@ def validate_dependencies(self) -> Tuple[bool, List[str]]:
146146
except Exception:
147147
pass
148148

149+
# Check pyproject.toml [project].dependencies
150+
if not has_deps:
151+
pyproject_path = self.repo_path / "pyproject.toml"
152+
if pyproject_path.exists():
153+
try:
154+
with open(pyproject_path) as f:
155+
content = f.read()
156+
# Look for a non-empty dependencies list under [project]
157+
in_project = False
158+
in_deps = False
159+
for line in content.splitlines():
160+
stripped = line.strip()
161+
if stripped == "[project]":
162+
in_project = True
163+
continue
164+
if in_project and stripped.startswith("[") and stripped != "[project]":
165+
in_project = False
166+
in_deps = False
167+
continue
168+
if in_project and stripped.startswith("dependencies"):
169+
in_deps = True
170+
# Handle inline list: dependencies = ["foo"]
171+
if '"' in stripped or "'" in stripped:
172+
has_deps = True
173+
break
174+
continue
175+
if in_deps:
176+
if stripped == "]":
177+
in_deps = False
178+
continue
179+
if stripped and not stripped.startswith("#"):
180+
has_deps = True
181+
break
182+
except Exception:
183+
pass
184+
149185
if not has_deps:
150186
errors.append(
151-
"No dependencies found in requirements.txt (expected for most projects)"
187+
"No dependencies found in requirements.txt or pyproject.toml (expected for most projects)"
152188
)
153189

154190
return len(errors) == 0, errors

benchmarks/ccb_build/eslint-markdown-deps-install-001/tests/validators.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ def _is_valid_requirement(line: str) -> bool:
131131
def validate_dependencies(self) -> Tuple[bool, List[str]]:
132132
"""Check that at least some dependencies are declared."""
133133
errors = []
134-
135-
req_path = self.repo_path / "requirements.txt"
136134
has_deps = False
137135

136+
# Check requirements.txt
137+
req_path = self.repo_path / "requirements.txt"
138138
if req_path.exists():
139139
try:
140140
with open(req_path) as f:
@@ -146,9 +146,45 @@ def validate_dependencies(self) -> Tuple[bool, List[str]]:
146146
except Exception:
147147
pass
148148

149+
# Check pyproject.toml [project].dependencies
150+
if not has_deps:
151+
pyproject_path = self.repo_path / "pyproject.toml"
152+
if pyproject_path.exists():
153+
try:
154+
with open(pyproject_path) as f:
155+
content = f.read()
156+
# Look for a non-empty dependencies list under [project]
157+
in_project = False
158+
in_deps = False
159+
for line in content.splitlines():
160+
stripped = line.strip()
161+
if stripped == "[project]":
162+
in_project = True
163+
continue
164+
if in_project and stripped.startswith("[") and stripped != "[project]":
165+
in_project = False
166+
in_deps = False
167+
continue
168+
if in_project and stripped.startswith("dependencies"):
169+
in_deps = True
170+
# Handle inline list: dependencies = ["foo"]
171+
if '"' in stripped or "'" in stripped:
172+
has_deps = True
173+
break
174+
continue
175+
if in_deps:
176+
if stripped == "]":
177+
in_deps = False
178+
continue
179+
if stripped and not stripped.startswith("#"):
180+
has_deps = True
181+
break
182+
except Exception:
183+
pass
184+
149185
if not has_deps:
150186
errors.append(
151-
"No dependencies found in requirements.txt (expected for most projects)"
187+
"No dependencies found in requirements.txt or pyproject.toml (expected for most projects)"
152188
)
153189

154190
return len(errors) == 0, errors

benchmarks/ccb_build/iamactionhunter-deps-install-001/tests/validators.py

Lines changed: 39 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ def _is_valid_requirement(line: str) -> bool:
131131
def validate_dependencies(self) -> Tuple[bool, List[str]]:
132132
"""Check that at least some dependencies are declared."""
133133
errors = []
134-
135-
req_path = self.repo_path / "requirements.txt"
136134
has_deps = False
137135

136+
# Check requirements.txt
137+
req_path = self.repo_path / "requirements.txt"
138138
if req_path.exists():
139139
try:
140140
with open(req_path) as f:
@@ -146,9 +146,45 @@ def validate_dependencies(self) -> Tuple[bool, List[str]]:
146146
except Exception:
147147
pass
148148

149+
# Check pyproject.toml [project].dependencies
150+
if not has_deps:
151+
pyproject_path = self.repo_path / "pyproject.toml"
152+
if pyproject_path.exists():
153+
try:
154+
with open(pyproject_path) as f:
155+
content = f.read()
156+
# Look for a non-empty dependencies list under [project]
157+
in_project = False
158+
in_deps = False
159+
for line in content.splitlines():
160+
stripped = line.strip()
161+
if stripped == "[project]":
162+
in_project = True
163+
continue
164+
if in_project and stripped.startswith("[") and stripped != "[project]":
165+
in_project = False
166+
in_deps = False
167+
continue
168+
if in_project and stripped.startswith("dependencies"):
169+
in_deps = True
170+
# Handle inline list: dependencies = ["foo"]
171+
if '"' in stripped or "'" in stripped:
172+
has_deps = True
173+
break
174+
continue
175+
if in_deps:
176+
if stripped == "]":
177+
in_deps = False
178+
continue
179+
if stripped and not stripped.startswith("#"):
180+
has_deps = True
181+
break
182+
except Exception:
183+
pass
184+
149185
if not has_deps:
150186
errors.append(
151-
"No dependencies found in requirements.txt (expected for most projects)"
187+
"No dependencies found in requirements.txt or pyproject.toml (expected for most projects)"
152188
)
153189

154190
return len(errors) == 0, errors

0 commit comments

Comments
 (0)