Skip to content

Commit

Permalink
Standardize returning ResourceTypeSelector instances in dbt list
Browse files Browse the repository at this point in the history
…and `dbt build` (#10739)

* Remove duplicated constructor for `ResourceTypeSelector`

* Add type annotation for `ResourceTypeSelector`

* Standardize on constructor for `ResourceTypeSelector` where `include_empty_nodes=True`

* Changelog entry
  • Loading branch information
dbeatty10 authored and peterallenwebb committed Sep 20, 2024
1 parent 574e2d0 commit 5c0d7ce
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 23 deletions.
7 changes: 7 additions & 0 deletions .changes/unreleased/Under the Hood-20240918-170325.yaml
Original file line number Diff line number Diff line change
@@ -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"
7 changes: 0 additions & 7 deletions core/dbt/task/build.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
24 changes: 8 additions & 16 deletions core/dbt/task/list.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit 5c0d7ce

Please sign in to comment.