From c31fa084f32dc12ef8b545b5af77bdcb44ad0ffc Mon Sep 17 00:00:00 2001 From: Suhas Date: Sun, 24 Jan 2021 19:15:04 -0500 Subject: [PATCH] make format --- jrnl/override.py | 4 ++-- tests/test_override.py | 7 +++---- 2 files changed, 5 insertions(+), 6 deletions(-) diff --git a/jrnl/override.py b/jrnl/override.py index 10ba6c8d..a330b7a9 100644 --- a/jrnl/override.py +++ b/jrnl/override.py @@ -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 diff --git a/tests/test_override.py b/tests/test_override.py index 13f4eb82..c6dc97a3 100644 --- a/tests/test_override.py +++ b/tests/test_override.py @@ -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"