Skip to content

Commit 0223077

Browse files
Add missing is_used check
1 parent 3455233 commit 0223077

2 files changed

Lines changed: 14 additions & 1 deletion

File tree

src/usethis/_core/tool.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -402,7 +402,9 @@ def use_ruff(
402402
):
403403
rule_config = _get_basic_rule_config()
404404
for _tool in ALL_TOOLS:
405-
rule_config |= _tool.get_rule_config()
405+
tool_rule_config = _tool.get_rule_config()
406+
if not tool_rule_config.empty and _tool.is_used():
407+
rule_config |= tool_rule_config
406408
else:
407409
rule_config = RuleConfig()
408410

src/usethis/_tool/rule.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,17 @@ def get_all_ignored(self) -> list[Rule]:
4747
"""Get all (project-scope) ignored rules."""
4848
return self.ignored + self.unmanaged_ignored
4949

50+
@property
51+
def empty(self) -> bool:
52+
"""Check if the rule config is empty."""
53+
return (
54+
not self.selected
55+
and not self.ignored
56+
and not self.unmanaged_selected
57+
and not self.unmanaged_ignored
58+
and not self.tests_unmanaged_ignored
59+
)
60+
5061
def __repr__(self) -> str:
5162
"""Representation which omits empty-list fields."""
5263
args = []

0 commit comments

Comments
 (0)