Skip to content
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

update_values() -> update_from() #578

Merged
merged 4 commits into from
Aug 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/uwtools/config/formats/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -234,10 +234,10 @@ def parse_include(self, ref_dict: Optional[dict] = None) -> None:
elif isinstance(value, str):
if m := re.match(r"^\s*%s\s+(.*)" % INCLUDE_TAG, value):
filepaths = yaml.safe_load(m[1])
self.update_values(self._load_paths(filepaths))
self.update_from(self._load_paths(filepaths))
del ref_dict[key]

def update_values(self, src: Union[dict, Config]) -> None:
def update_from(self, src: Union[dict, Config]) -> None:
"""
Updates a config.

Expand Down
2 changes: 1 addition & 1 deletion src/uwtools/config/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -246,7 +246,7 @@ def _realize_config_update(
log.debug("Initial input config depth: %s", input_obj.depth)
log.debug("Update config depth: %s", update_obj.depth)
config_check_depths_update(update_obj, input_obj.get_format())
input_obj.update_values(update_obj)
input_obj.update_from(update_obj)
log.debug("Final input config depth: %s", input_obj.depth)
return input_obj

Expand Down
2 changes: 1 addition & 1 deletion src/uwtools/drivers/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -139,7 +139,7 @@ def _create_user_updated_config(
user_values = config_values.get(STR.updatevalues, {})
if base_file := config_values.get(STR.basefile):
cfgobj = config_class(base_file)
cfgobj.update_values(user_values)
cfgobj.update_from(user_values)
cfgobj.dereference()
config = cfgobj.data
dump = partial(cfgobj.dump, path)
Expand Down
2 changes: 1 addition & 1 deletion src/uwtools/tests/config/formats/test_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,7 +201,7 @@ def test_parse_include(config):
assert len(config["config"]) == 2


def test_update_values(config):
def test_update_from(config):
"""
Test that a config object can be updated.
"""
Expand Down
2 changes: 1 addition & 1 deletion src/uwtools/tests/config/test_tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ def help_realize_config_fmt2fmt(input_file, input_format, update_file, update_fo
)
cfgclass = tools.format_to_config(input_format)
cfgobj = cfgclass(input_file)
cfgobj.update_values(cfgclass(update_file))
cfgobj.update_from(cfgclass(update_file))
reference = tmpdir / f"expected{ext}"
cfgobj.dump(reference)
assert compare_files(reference, output_file)
Expand Down
Loading