Skip to content

Commit

Permalink
[#4069] Use more standard disabled lookup functions (#4073)
Browse files Browse the repository at this point in the history
automatic commit by git-black, original commits:
  80a5d27
  • Loading branch information
gshank authored and iknox-fa committed Feb 8, 2022
1 parent 58f1549 commit 2005971
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 8 deletions.
11 changes: 5 additions & 6 deletions core/dbt/contracts/graph/manifest.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ def __init__(self, manifest: "Manifest"):
def get_unique_id(self, search_name, package: Optional[PackageName]):
return find_unique_id_for_package(self.storage, search_name, package)

def find(self, search_name, package: Optional[PackageName], manifest: 'Manifest'):
def find(self, search_name, package: Optional[PackageName], manifest: "Manifest"):
unique_id = self.get_unique_id(search_name, package)
if unique_id is not None:
return self.perform_lookup(unique_id, manifest)
Expand Down Expand Up @@ -187,8 +187,7 @@ def perform_lookup(

# This handles both models/seeds/snapshots and sources
class DisabledLookup(dbtClassMixin):

def __init__(self, manifest: 'Manifest'):
def __init__(self, manifest: "Manifest"):
self.storage: Dict[str, Dict[PackageName, List[Any]]] = {}
self.populate(manifest)

Expand Down Expand Up @@ -601,7 +600,7 @@ class Manifest(MacroMethods, DataClassMessagePackMixin, dbtClassMixin):
default=None, metadata={"serialize": lambda x: None, "deserialize": lambda x: None}
)
_disabled_lookup: Optional[DisabledLookup] = field(
default=None, metadata={'serialize': lambda x: None, 'deserialize': lambda x: None}
default=None, metadata={"serialize": lambda x: None, "deserialize": lambda x: None}
)
_analysis_lookup: Optional[AnalysisLookup] = field(
default=None, metadata={"serialize": lambda x: None, "deserialize": lambda x: None}
Expand Down Expand Up @@ -911,7 +910,7 @@ def resolve_source(
current_project: str,
node_package: str,
) -> MaybeParsedSource:
search_name = f'{target_source_name}.{target_table_name}'
search_name = f"{target_source_name}.{target_table_name}"
candidates = _search_packages(current_project, node_package)

source: Optional[ParsedSourceDefinition] = None
Expand All @@ -924,7 +923,7 @@ def resolve_source(

if disabled is None:
disabled = self.disabled_lookup.find(
f'{target_source_name}.{target_table_name}', pkg
f"{target_source_name}.{target_table_name}", pkg
)

if disabled:
Expand Down
6 changes: 4 additions & 2 deletions core/dbt/parser/partial.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,10 @@ def remove_node_in_saved(self, source_file, unique_id):
# delete node in saved
node = self.saved_manifest.nodes.pop(unique_id)
self.deleted_manifest.nodes[unique_id] = node
elif (source_file.file_id in self.disabled_by_file_id and
unique_id in self.saved_manifest.disabled):
elif (
source_file.file_id in self.disabled_by_file_id
and unique_id in self.saved_manifest.disabled
):
# This node is disabled. Find the node and remove it from disabled dictionary.
for dis_index, dis_node in enumerate(self.saved_manifest.disabled[unique_id]):
if dis_node.file_id == source_file.file_id:
Expand Down

0 comments on commit 2005971

Please sign in to comment.