def merge_configs(defaults: OptionValues, vals: OptionValues) -> OptionValues: return { k: (merge_dicts(v, vals.get(k, {})) if isinstance(v, dict) else vals.get(k, v)) for k, v in defaults.items() }
def merge_configs(defaults: Dict, vals: Dict) -> Dict: ans = {} for k, v in defaults.items(): if isinstance(v, dict): newvals = vals.get(k, {}) ans[k] = merge_dicts(v, newvals) else: ans[k] = vals.get(k, v) return ans
def merge_result_dicts(defaults: typing.Dict[str, typing.Any], vals: typing.Dict[str, typing.Any]) -> typing.Dict[str, typing.Any]: ans = {} for k, v in defaults.items(): if isinstance(v, dict): ans[k] = merge_dicts(v, vals.get(k, {})) elif k in actions: ans[k] = v + vals.get(k, []) else: ans[k] = vals.get(k, v) return ans