Skip to content

Configures PT rules to be disabled for non-test dirs#1252

Merged
nathanjmcdougall merged 1 commit into
mainfrom
1093-usethis-tool-ruff-with-pytest-should-configure-pt-rules-to-be-disabled-for-non-test-dirs
Dec 30, 2025
Merged

Configures PT rules to be disabled for non-test dirs#1252
nathanjmcdougall merged 1 commit into
mainfrom
1093-usethis-tool-ruff-with-pytest-should-configure-pt-rules-to-be-disabled-for-non-test-dirs

Conversation

@nathanjmcdougall

Copy link
Copy Markdown
Collaborator

No description provided.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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_ignored field to RuleConfig to track rules that should be ignored outside of test directories
  • Modified pytest tool configuration to automatically ignore PT rules in non-test files using the !tests/**/*.py glob pattern
  • Updated Ruff's apply_rule_config method 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

codecov Bot commented Dec 30, 2025

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 85.71429% with 1 line in your changes missing coverage. Please review.
✅ All tests successful. No failed tests found.

Files with missing lines Patch % Lines
src/usethis/_tool/rule.py 80.00% 1 Missing ⚠️

📢 Thoughts on this report? Let us know!

@codspeed-hq

codspeed-hq Bot commented Dec 30, 2025

Copy link
Copy Markdown

CodSpeed Performance Report

Merging #1252 will not alter performance

Comparing 1093-usethis-tool-ruff-with-pytest-should-configure-pt-rules-to-be-disabled-for-non-test-dirs (19883d7) with main (3a06c95)

Summary

✅ 2 untouched

@nathanjmcdougall nathanjmcdougall merged commit bd54adf into main Dec 30, 2025
18 of 19 checks passed
@nathanjmcdougall nathanjmcdougall deleted the 1093-usethis-tool-ruff-with-pytest-should-configure-pt-rules-to-be-disabled-for-non-test-dirs branch December 30, 2025 07:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

usethis tool ruff with pytest should configure PT rules to be disabled for non-test dirs

2 participants