Configures PT rules to be disabled for non-test dirs#1252
Conversation
…for non-test dirs
There was a problem hiding this comment.
Pull request overview
This PR adds functionality to configure Ruff's PT (pytest) rules to be disabled in non-test directories, preventing pytest-specific linting rules from applying to production code. The change introduces a new nontests_unmanaged_ignored field to the RuleConfig model that works alongside the existing tests_unmanaged_ignored field.
Key Changes:
- Added
nontests_unmanaged_ignoredfield toRuleConfigto track rules that should be ignored outside of test directories - Modified pytest tool configuration to automatically ignore
PTrules in non-test files using the!tests/**/*.pyglob pattern - Updated Ruff's
apply_rule_configmethod to apply non-test directory ignore rules when the tests directory exists
Reviewed changes
Copilot reviewed 4 out of 4 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| src/usethis/_tool/rule.py | Added nontests_unmanaged_ignored field to RuleConfig model and updated all relevant methods to handle this new field |
| src/usethis/_tool/impl/pytest.py | Modified get_rule_config to include PT rules in nontests_unmanaged_ignored list |
| src/usethis/_tool/impl/ruff.py | Updated apply_rule_config to apply non-test directory ignore rules using the !tests/**/*.py glob |
| tests/usethis/_core/test_core_tool.py | Added two integration tests to verify PT rules are ignored in non-test files regardless of whether pytest or ruff is added first |
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
CodSpeed Performance ReportMerging #1252 will not alter performanceComparing Summary
|
No description provided.