fix: skip test files and test functions in Python type annotations check#493
fix: skip test files and test functions in Python type annotations check#493aviavraham wants to merge 3 commits into
Conversation
…eck (ambient-code#385) Test files (test_*.py, *_test.py, conftest.py, tests/ dirs) and test functions (test_*) were penalizing repos for missing type hints on code that doesn't benefit from annotations. Aligns Python behavior with the existing Go _test.go exclusion. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Enterprise Run ID: 📒 Files selected for processing (2)
📝 WalkthroughWalkthroughTypeAnnotationsAssessor now excludes Python test files and ChangesExclude tests from Python type annotation scoring
Suggested labels: 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
✨ Simplify code
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
📈 Test Coverage Report
Coverage calculated from unit tests only |
There was a problem hiding this comment.
Actionable comments posted: 2
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Inline comments:
In `@src/agentready/assessors/code_quality.py`:
- Around line 162-176: _is_python_test_file currently uses PurePosixPath which
doesn't split Windows backslash separators, so normalize the incoming file_path
by replacing backslashes with forward slashes (e.g., file_path =
file_path.replace("\\\\", "/")) before constructing PurePosixPath or split
parts; update the _is_python_test_file function to perform this normalization
(or alternatively use pathlib.PurePath with explicit normalization) so names
like "tests\\test_app.py" are correctly detected as test files while preserving
the existing name/parts checks (references: function _is_python_test_file,
PurePosixPath).
In `@tests/unit/test_assessors_code_quality.py`:
- Around line 39-65: Add Windows-style path variants to the test cases for
TypeAnnotationsAssessor._is_python_test_file: update the parameter list used by
test_identifies_test_files to include at least "tests\\test_foo.py" (and
optionally "test\\test_bar.py") so the underscore method is validated on
backslash-separated paths; keep the test_identifies_non_test_files list
unchanged unless you want to add non-test backslash examples similarly.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: bf718a70-e4e1-4998-b7eb-87e04829136f
📒 Files selected for processing (3)
docs/attributes.mdsrc/agentready/assessors/code_quality.pytests/unit/test_assessors_code_quality.py
There was a problem hiding this comment.
♻️ Duplicate comments (1)
tests/unit/test_assessors_code_quality.py (1)
40-51:⚠️ Potential issue | 🟠 Major | ⚡ Quick winAdd Windows-style path cases to lock in cross-platform test-file detection
Line 43-Line 51 only validate POSIX-style separators. Add at least one backslash path (e.g.,
tests\\test_foo.py) so_is_python_test_filebehavior is enforced for Windows-style paths too; this is the key edge case for path-based exclusion logic.Suggested minimal test update
`@pytest.mark.parametrize`( "path", [ "tests/test_foo.py", "test/test_bar.py", "tests/unit/test_baz.py", "src/tests/test_helpers.py", + r"tests\test_win.py", + r"test\unit\test_bar.py", "test_something.py", "foo_test.py", "conftest.py", "tests/conftest.py", ], )As per coding guidelines, “tests/**: Check for missing edge cases.”
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@tests/unit/test_assessors_code_quality.py` around lines 40 - 51, The parametric test only covers POSIX-style paths; add at least one Windows-style path with backslashes (for example "tests\\test_foo.py") to the pytest.mark.parametrize "path" list so the _is_python_test_file behavior is validated on Windows separators as well; update the list of test cases in tests/unit/test_assessors_code_quality.py (the pytest parametrization block) to include the backslash variant.Source: Coding guidelines
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Duplicate comments:
In `@tests/unit/test_assessors_code_quality.py`:
- Around line 40-51: The parametric test only covers POSIX-style paths; add at
least one Windows-style path with backslashes (for example "tests\\test_foo.py")
to the pytest.mark.parametrize "path" list so the _is_python_test_file behavior
is validated on Windows separators as well; update the list of test cases in
tests/unit/test_assessors_code_quality.py (the pytest parametrization block) to
include the backslash variant.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Path: .coderabbit.yaml
Review profile: ASSERTIVE
Plan: Enterprise
Run ID: 5d72f872-bda9-4c05-a349-a47dbdd9e3b1
📒 Files selected for processing (1)
tests/unit/test_assessors_code_quality.py
Addresses CodeRabbit review: PurePosixPath doesn't split Windows backslash separators, so normalize before classification. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@coderabbitai review |
✅ Action performedReview finished.
|
Summary
Fixes #385
test_*.py,*_test.py,conftest.py,tests//test/dirs) from Python type annotation scoringtest_*) inside non-test source files_test.goexclusiondocs/attributes.mdto document the exclusionTest plan
black,isort,ruff)Summary by CodeRabbit
Bug Fixes
Documentation
Tests