make format

This commit is contained in:
Suhas 2021-01-24 19:15:04 -05:00
parent 9540d34964
commit c31fa084f3
2 changed files with 5 additions and 6 deletions

View file

@ -3,11 +3,11 @@ def apply_overrides(overrides: dict, base_config: dict) -> dict:
config = base_config.copy()
for k in overrides:
nodes = k.split(".")
config = recursively_apply(config, nodes, overrides[k])
config = _recursively_apply(config, nodes, overrides[k])
return config
def recursively_apply(config: dict, nodes: list, override_value) -> dict:
def _recursively_apply(config: dict, nodes: list, override_value) -> dict:
"""Recurse through configuration and apply overrides at the leaf of the config tree
Credit to iJames on SO: https://stackoverflow.com/a/47276490 for algorithm

View file

@ -1,6 +1,6 @@
import pytest
from jrnl.override import apply_overrides, recursively_apply
from jrnl.override import apply_overrides, _recursively_apply, _get_config_node
@pytest.fixture()
@ -27,10 +27,9 @@ def test_override_dot_notation(minimal_config):
assert cfg["colors"] == {"body": "blue", "date": "green"}
def test_recursive_override(minimal_config):
def test_recursively_apply():
cfg = {"colors": {"body": "red", "title": "green"}}
cfg = recursively_apply(cfg, ["colors", "body"], "blue")
cfg = _recursively_apply(cfg, ["colors", "body"], "blue")
assert cfg["colors"]["body"] == "blue"