-
Notifications
You must be signed in to change notification settings - Fork 17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support for dbt core changes to support mashumaro 3.15 #228
base: main
Are you sure you want to change the base?
Changes from 6 commits
adf0f9d
da68d69
1fc36bb
b511cc0
867bc10
80d3802
bfb08a0
56b3592
2c0e434
c3f3284
b7dd3ae
d77bfa8
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -115,6 +115,28 @@ def same_contents(cls, unrendered: Dict[str, Any], other: Dict[str, Any]) -> boo | |
"object": ["snapshot_meta_column_names"], | ||
} | ||
|
||
@classmethod | ||
def update_from( | ||
cls, dct: Dict[str, Any], data: 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) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. nit: this probably should be cleaned up |
||
|
||
self_merged = cls._merge_dicts(dct, data) | ||
dct.update(self_merged) | ||
|
||
adapter_merged = adapter_config_cls._merge_dicts(dct, data) | ||
dct.update(adapter_merged) | ||
|
||
# any remaining fields must be "clobber" | ||
dct.update(data) | ||
|
||
return dct | ||
|
||
@classmethod | ||
def _merge_dicts(cls, src: Dict[str, Any], data: Dict[str, Any]) -> Dict[str, Any]: | ||
"""Mutate input to return merge results. | ||
|
@@ -150,30 +172,6 @@ def _merge_dicts(cls, src: Dict[str, Any], data: Dict[str, Any]) -> Dict[str, An | |
) | ||
return result | ||
|
||
def update_from( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. there don't appear to be explicit usages of There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The signature change here looks like it will have a very minor impact (just to dbt-core). We could release a dbt-common major version bump for this change since it is technically breaking, but that might be overkill given its low usage. At least a minor bump makes sense to me though. |
||
self: T, data: Dict[str, Any], config_cls: Type[BaseConfig], validate: bool = True | ||
) -> T: | ||
"""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 = self._merge_dicts(dct, data) | ||
dct.update(self_merged) | ||
|
||
adapter_merged = config_cls._merge_dicts(dct, data) | ||
dct.update(adapter_merged) | ||
|
||
# any remaining fields must be "clobber" | ||
dct.update(data) | ||
|
||
# any validation failures must have come from the update | ||
if validate: | ||
self.validate(dct) | ||
return self.from_dict(dct) | ||
|
||
def finalize_and_validate(self: T) -> T: | ||
dct = self.to_dict(omit_none=False) | ||
self.validate(dct) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
naming nit: is there naming here that would better signify the difference between
dct
anddata
?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do you have any suggestions? orig_dict, new_dict?