diff --git a/src/python/pants/build_graph/target_filter_subsystem.py b/src/python/pants/build_graph/target_filter_subsystem.py index af6d4b766fa..ae53b7cd743 100644 --- a/src/python/pants/build_graph/target_filter_subsystem.py +++ b/src/python/pants/build_graph/target_filter_subsystem.py @@ -31,15 +31,14 @@ def register_options(cls, register): def apply(self, targets): exclude_tags = set(self.get_options().exclude_tags) - return TargetFiltering(targets, exclude_tags).apply_tag_blacklist() + return TargetFiltering(exclude_tags).apply_tag_blacklist(targets) class TargetFiltering(object): """Apply filtering logic against targets.""" - def __init__(self, targets, exclude_tags): - self.targets = targets + def __init__(self, exclude_tags): self.exclude_tags = exclude_tags - def apply_tag_blacklist(self): - return [t for t in self.targets if not self.exclude_tags.intersection(t.tags)] + def apply_tag_blacklist(self, targets): + return [t for t in targets if not self.exclude_tags.intersection(t.tags)] diff --git a/tests/python/pants_test/build_graph/test_target_filter_subsystem.py b/tests/python/pants_test/build_graph/test_target_filter_subsystem.py index 3c9fd41c0d1..9b7cb3f8bf8 100644 --- a/tests/python/pants_test/build_graph/test_target_filter_subsystem.py +++ b/tests/python/pants_test/build_graph/test_target_filter_subsystem.py @@ -41,7 +41,7 @@ def test_filtering_single_tag(self): b = self.make_target('b', tags=['skip-me']) c = self.make_target('c', tags=['tag1', 'skip-me']) - filtered_targets = TargetFiltering([a, b, c], {'skip-me'}).apply_tag_blacklist() + filtered_targets = TargetFiltering({'skip-me'}).apply_tag_blacklist([a, b, c]) self.assertEqual([a], filtered_targets) def test_filtering_multiple_tags(self): @@ -49,7 +49,7 @@ def test_filtering_multiple_tags(self): b = self.make_target('b', tags=['tag1', 'tag2', 'skip-me']) c = self.make_target('c', tags=['tag2']) - filtered_targets = TargetFiltering([a, b, c], {'skip-me', 'tag2'}).apply_tag_blacklist() + filtered_targets = TargetFiltering({'skip-me', 'tag2'}).apply_tag_blacklist([a, b, c]) self.assertEqual([], filtered_targets) def test_filtering_no_tags(self): @@ -57,5 +57,5 @@ def test_filtering_no_tags(self): b = self.make_target('b', tags=['tag1', 'tag2']) c = self.make_target('c', tags=['tag2']) - filtered_targets = TargetFiltering([a, b, c], set()).apply_tag_blacklist() + filtered_targets = TargetFiltering(set()).apply_tag_blacklist([a, b, c]) self.assertEqual([a, b, c], filtered_targets)