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
|
Note Reviews pausedIt looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the Use the following commands to manage reviews:
Use the checkboxes below for quick actions:
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 (1)
📝 WalkthroughWalkthroughType annotation scoring now excludes Python test files and ChangesSkip tests in Python type-annotation scoring
🚥 Pre-merge checks | ✅ 4 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (4 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 |
📈 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
|
@coderabbitai review |
✅ Action performedReview finished.
|
jwm4
left a comment
There was a problem hiding this comment.
Review from Bill Murdock with assistance from Claude Code
Nice work on this fix, @aviavraham. Clean implementation that aligns well with the existing Go _test.go exclusion pattern. The two-layer exclusion (file-level + function-level), the not_applicable handling for test-only repos, and the Windows path normalization are all well done.
There are merge conflicts with main that need resolving. Sorry about that, I believe my recent PR is what caused them. Should be straightforward to rebase.
Once that's resolved, this is good to go.
…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>
Addresses CodeRabbit review: PurePosixPath doesn't split Windows backslash separators, so normalize before classification. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2d942e6 to
0c044c1
Compare
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
|
@jwm4, the PR is ready to merge |
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
test_*test functions from evaluation.Documentation
test_*functions are not included in scoring.Tests