Skip to content

Commit

Permalink
Revert "Allow a targeted (named rule) enable to override a module dis…
Browse files Browse the repository at this point in the history
…able #463"

This reverts commit f0dfb39.
  • Loading branch information
amyreese authored Jun 21, 2024
1 parent f0dfb39 commit 7fae461
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 30 deletions.
14 changes: 2 additions & 12 deletions src/fixit/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,7 +207,6 @@ def collect_rules(
"""

all_rules: Set[Type[LintRule]] = set()
named_enables: Set[Type[LintRule]] = set()
if debug_reasons is not None:
disabled_rules = debug_reasons
else:
Expand All @@ -223,19 +222,10 @@ def collect_rules(
stack.enter_context(append_sys_path(path))

for qualified_rule in config.enable:
rules = set(find_rules(qualified_rule))
if qualified_rule.name:
named_enables |= rules
all_rules |= rules
all_rules |= set(find_rules(qualified_rule))

for qualified_rule in config.disable:
disabled_rules.update(
{
r: "disabled"
for r in find_rules(qualified_rule)
if r not in named_enables
}
)
disabled_rules.update({r: "disabled" for r in find_rules(qualified_rule)})
all_rules -= set(disabled_rules)

if config.tags:
Expand Down
18 changes: 0 additions & 18 deletions src/fixit/tests/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -476,24 +476,6 @@ def collect_types(cfg: Config) -> List[Type[LintRule]]:
)
self.assertListEqual([UseClsInClassmethod], rules)

with self.subTest("disable builtins"):
rules = collect_types(
Config(
disable=[QualifiedRule("fixit.rules")],
python_version=None,
)
)
self.assertListEqual([], rules)

with self.subTest("override broad opt-out"):
rules = collect_types(
Config(
disable=[QualifiedRule("fixit.rules")],
enable=[QualifiedRule("fixit.rules", "UseClsInClassmethod")],
)
)
self.assertListEqual([UseClsInClassmethod], rules)

with self.subTest("version match"):
rules = collect_types(
Config(
Expand Down

0 comments on commit 7fae461

Please sign in to comment.