Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
gshank committed Dec 5, 2024
1 parent 80d3802 commit bfb08a0
Showing 1 changed file with 10 additions and 8 deletions.
18 changes: 10 additions & 8 deletions dbt_common/contracts/config/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,25 +117,27 @@ def same_contents(cls, unrendered: Dict[str, Any], other: Dict[str, Any]) -> boo

@classmethod
def update_from(
cls, dct: Dict[str, Any], data: Dict[str, Any], adapter_config_cls: Type[BaseConfig]
cls,
orig_dict: Dict[str, Any],
new_dict: Dict[str, Any],
adapter_config_cls: Type[BaseConfig],
) -> Dict[str, Any]:
"""Update and validate config given a dict.
Given a dict of keys, update the current config from them, validate
it, and return a new config with the updated values
"""
# dct = self.to_dict(omit_none=False)

self_merged = cls._merge_dicts(dct, data)
dct.update(self_merged)
self_merged = cls._merge_dicts(orig_dict, new_dict)
new_dict.update(self_merged)

adapter_merged = adapter_config_cls._merge_dicts(dct, data)
dct.update(adapter_merged)
adapter_merged = adapter_config_cls._merge_dicts(orig_dict, new_dict)
new_dict.update(adapter_merged)

# any remaining fields must be "clobber"
dct.update(data)
orig_dict.update(new_dict)

return dct
return orig_dict

@classmethod
def _merge_dicts(cls, src: Dict[str, Any], data: Dict[str, Any]) -> Dict[str, Any]:
Expand Down

0 comments on commit bfb08a0

Please sign in to comment.