fix: resolve ruff lint errors in validation.py and test_validation.py#1
Conversation
Agent-Logs-Url: https://github.com/SummerOneTwo/AutoCode/sessions/19d466ad-96c0-4698-97c3-ab82894be926 Co-authored-by: SummerOneTwo <89140025+SummerOneTwo@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR fixes CI failures by addressing Ruff lint issues introduced in the new validation tool and its unit tests.
Changes:
- Add explicit
strict=Falsetozip()calls to satisfyB905. - Rename an unused loop index variable and remove an unused test import to satisfy
B007/F401. - Ensure the source file ends with a trailing newline (
W292).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
tests/test_validation.py |
Removes an unused pytest import to satisfy Ruff (F401). |
src/autocode_mcp/tools/validation.py |
Updates zip() calls to be explicit about strict, renames an unused loop var, and fixes trailing newline. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| 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)) |
There was a problem hiding this comment.
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.
| 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)) |
|
|
||
| # 配对 | ||
| for i, (inp, out) in enumerate(zip(input_blocks, output_blocks)): | ||
| for _i, (inp, out) in enumerate(zip(input_blocks, output_blocks, strict=False)): |
There was a problem hiding this comment.
_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.
| for _i, (inp, out) in enumerate(zip(input_blocks, output_blocks, strict=False)): | |
| for inp, out in zip(input_blocks, output_blocks, strict=False): |
CI was failing due to 6 ruff lint errors introduced with the new
validation.pyand its test file.Changes
strict=Falseto threezip()calls (lines 319, 367, 395 invalidation.py) where input/output list lengths may legitimately differi→_iin theenumerate(zip(...))pairing loopvalidation.pyimport pytestfromtests/test_validation.py