Repository navigation
fix(allowlist): exclude pytest-style test_*.py from review - #1439
Conversation
…eview Python's exclude list only covered *_test.py. pytest collects test_*.py and *_test.py by default, so ordinary pytest test files were still selected for review.
|
✅ OpenCodeReview: Review complete: 0 finding(s) across 1 selected item(s). |
| "**/test_*.py", | ||
| "**/conftest.py", |
There was a problem hiding this comment.
I do not really recommend you exclude **/confest.py, it is true executable code in Python ...
They should be reviewed all the time.
| "**/test_*.py", | |
| "**/conftest.py", | |
| "**/conftest.py", |
There was a problem hiding this comment.
Agreed. Removed in 880e0f2, so conftest.py is reviewable by default again.
| {"python pytest prefix at root", "test_utils.py", true}, | ||
| {"python pytest prefix nested", "app/test_handler.py", true}, | ||
| {"python pytest prefix in tests dir", "tests/test_utils.py", true}, | ||
| {"python pytest prefix deeply nested", "packages/core/app/test_api.py", true}, | ||
| {"python conftest at root", "conftest.py", true}, | ||
| {"python conftest nested", "tests/unit/conftest.py", true}, |
There was a problem hiding this comment.
as above
| {"python pytest prefix at root", "test_utils.py", true}, | |
| {"python pytest prefix nested", "app/test_handler.py", true}, | |
| {"python pytest prefix in tests dir", "tests/test_utils.py", true}, | |
| {"python pytest prefix deeply nested", "packages/core/app/test_api.py", true}, | |
| {"python conftest at root", "conftest.py", true}, | |
| {"python conftest nested", "tests/unit/conftest.py", true}, | |
| {"python pytest prefix at root", "test_utils.py", true}, | |
| {"python pytest prefix nested", "app/test_handler.py", true}, | |
| {"python pytest prefix in tests dir", "tests/test_utils.py", true}, | |
| {"python pytest prefix deeply nested", "packages/core/app/test_api.py", true}, |
NanaseInori
left a comment
There was a problem hiding this comment.
The **/test_*.py addition looks correct to me. Pytest's default python_files patterns are test_*.py and *_test.py, and OCR already excludes the latter, so covering the prefix form closes a real gap. The positive and negative regression cases around that pattern also look good.
I do share the concern raised above about **/conftest.py, with one distinction: the issue is not merely that it is executable Python. Pytest does not treat conftest.py as one of its python_files test-module patterns; it auto-loads it as a local plugin. A conftest can implement collection/runtime hooks and shared fixture or environment setup, so excluding it by default removes pytest control/infrastructure code from review rather than simply completing the missing test-file naming convention.
For this focused fix, I would keep **/test_*.py and leave conftest.py reviewable by default unless the project explicitly decides that pytest plugin/fixture infrastructure should also be part of the built-in exclusion policy. That broader policy choice can be discussed separately if desired.
There is also a documentation update needed here. review-rules.md explicitly enumerates the built-in default path exclusions and explains their include-override behavior. After adding test_*.py (and conftest.py if it is ultimately retained), that list becomes stale. Please update the maintained documentation locales accordingly.
With those points addressed, I do not see another blocking issue in this patch.
This review was conducted by Qiyuanqiii's review bot, using the model GPT-5.6 Sol. If you need a human review, please manually @.
docs point fixed in 880e0f2: |
Summary
Expanded Python's built-in exclude list to cover pytest's default test-file pattern:
**/test_*.pyThis prevents ordinary pytest test files from being selected for review and sent to the model.
conftest.pyis deliberately not excluded: pytest does not treat it as a test module (python_files), it is auto-loaded as a localplugin that can implement collection/runtime hooks and shared fixture or environment setup, so it stays reviewable by default.
Behavior
Before/after using
ocr review --previewon the same changeset:6->4app/test_handler.pytests/test_api.pyapp/handler.pyapp/contest_utils.pyconftest.pysrc/test_helpers.goUsers who want test files reviewed can add them to
include, which overrides the default-path gate.Tests
Added coverage for the new matches and non-matches:
test_*.pyconftest.py,contest_utils.py,attestation.py,latest.pyUpdated the assertions in
allowed_ext_test.gothat pinned the previous behavior.Docs
Added
**/test_*.pyto the enumerated default-exclusion list inreview-rules.mdfor all maintained locales:en,ja,ko,ru,zh.Verified:
make testwith race detectionmake checkmake coverageat 92.5%AI Disclosure
AI/LLM assistance: implemented with Claude Code; I reviewed every line.