Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/autocode_mcp/tools/validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -316,7 +316,7 @@ def _compare_output(self, actual: str, expected: str, tolerance: float) -> bool:
if len(actual_tokens) == len(expected_tokens):
actual_nums = [float(x) for x in actual_tokens]
expected_nums = [float(x) for x in expected_tokens]
return all(abs(a - e) < tolerance for a, e in zip(actual_nums, expected_nums))
return all(abs(a - e) < tolerance for a, e in zip(actual_nums, expected_nums, strict=False))
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here you already guard on len(actual_tokens) == len(expected_tokens), so using zip(..., strict=False) is redundant and slightly undermines the intent of being explicit about length mismatches. Consider strict=True (or rely on strict=True and drop the manual length check) to keep this float-compare path self-consistent.

Suggested change
return all(abs(a - e) < tolerance for a, e in zip(actual_nums, expected_nums, strict=False))
return all(abs(a - e) < tolerance for a, e in zip(actual_nums, expected_nums, strict=True))

Copilot uses AI. Check for mistakes.
except ValueError:
pass

Expand Down Expand Up @@ -364,7 +364,7 @@ def _extract_samples_from_readme(self, readme_path: str) -> list[dict]:
output_blocks = re.findall(pattern, content, re.DOTALL | re.IGNORECASE)

# 配对
for i, (inp, out) in enumerate(zip(input_blocks, output_blocks)):
for _i, (inp, out) in enumerate(zip(input_blocks, output_blocks, strict=False)):
Copy link

Copilot AI Apr 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_i is unused in this loop; since the index isn’t used, dropping enumerate(...) entirely (or using _ instead of _i) would make the intent clearer and avoid carrying an unused variable.

Suggested change
for _i, (inp, out) in enumerate(zip(input_blocks, output_blocks, strict=False)):
for inp, out in zip(input_blocks, output_blocks, strict=False):

Copilot uses AI. Check for mistakes.
samples.append({
"input": inp.strip(),
"expected_output": out.strip(),
Expand Down Expand Up @@ -392,10 +392,10 @@ def _extract_samples_from_readme(self, readme_path: str) -> list[dict]:
inputs = re.findall(input_pattern, content, re.DOTALL | re.IGNORECASE)
outputs = re.findall(output_pattern, content, re.DOTALL | re.IGNORECASE)

for inp, out in zip(inputs, outputs):
for inp, out in zip(inputs, outputs, strict=False):
samples.append({
"input": inp.strip(),
"expected_output": out.strip(),
})

return samples
return samples
2 changes: 0 additions & 2 deletions tests/test_validation.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@
import os
import tempfile

import pytest

from autocode_mcp.tools.validation import ProblemValidateTool


Expand Down
Loading