diff --git a/.changes/unreleased/Under the Hood-20240918-170325.yaml b/.changes/unreleased/Under the Hood-20240918-170325.yaml new file mode 100644 index 00000000000..3f265a36eda --- /dev/null +++ b/.changes/unreleased/Under the Hood-20240918-170325.yaml @@ -0,0 +1,7 @@ +kind: Under the Hood +body: Standardize returning `ResourceTypeSelector` instances in `dbt list` and `dbt + build` +time: 2024-09-18T17:03:25.639516-06:00 +custom: + Author: dbeatty10 + Issue: "10739" diff --git a/core/dbt/task/build.py b/core/dbt/task/build.py index 832f7f0fe47..625a4498d6a 100644 --- a/core/dbt/task/build.py +++ b/core/dbt/task/build.py @@ -196,13 +196,6 @@ def get_node_selector(self, no_unit_tests=False) -> ResourceTypeSelector: resource_types = self.resource_types(no_unit_tests) - if resource_types == [NodeType.Test]: - return ResourceTypeSelector( - graph=self.graph, - manifest=self.manifest, - previous_state=self.previous_state, - resource_types=resource_types, - ) return ResourceTypeSelector( graph=self.graph, manifest=self.manifest, diff --git a/core/dbt/task/list.py b/core/dbt/task/list.py index 180cfc71693..2638920976a 100644 --- a/core/dbt/task/list.py +++ b/core/dbt/task/list.py @@ -196,24 +196,16 @@ def selection_arg(self): else: return self.args.select - def get_node_selector(self): + def get_node_selector(self) -> ResourceTypeSelector: if self.manifest is None or self.graph is None: raise DbtInternalError("manifest and graph must be set to get perform node selection") - if self.resource_types == [NodeType.Test]: - return ResourceTypeSelector( - graph=self.graph, - manifest=self.manifest, - previous_state=self.previous_state, - resource_types=self.resource_types, - ) - else: - return ResourceTypeSelector( - graph=self.graph, - manifest=self.manifest, - previous_state=self.previous_state, - resource_types=self.resource_types, - include_empty_nodes=True, - ) + return ResourceTypeSelector( + graph=self.graph, + manifest=self.manifest, + previous_state=self.previous_state, + resource_types=self.resource_types, + include_empty_nodes=True, + ) def interpret_results(self, results): # list command should always return 0 as exit code