from tarfile import ReadError
-from typing import Optional
+from typing import Optional, TypeVar
from teuthology.util.compat import urljoin, urlopen, HTTPError
return config_dict
-def merge_configs(config_paths):
+def merge_configs(config_paths) -> dict:
""" Takes one or many paths to yaml config files and merges them
together, returning the result.
"""
continue
else:
with open(conf_path) as partial_file:
- partial_dict = yaml.safe_load(partial_file)
+ partial_dict: dict = yaml.safe_load(partial_file)
try:
conf_dict = deep_merge(conf_dict, partial_dict)
except Exception:
return norm_config
-def deep_merge(a, b):
+DeepMerge = TypeVar('DeepMerge')
+def deep_merge(a: DeepMerge, b: DeepMerge) -> DeepMerge:
"""
Deep Merge. If a and b are both lists, all elements in b are
added into a. If a and b are both dictionaries, elements in b are
elif isinstance(b, dict) or isinstance(b, list):
return deep_merge(b.__class__(), b)
elif isinstance(b, MappingProxyType):
- return deep_merge(dict(), b)
+ return dict() | b
else:
return b