Store the paths from which config data is read on the created options object

This commit is contained in:
Kovid Goyal
2021-06-05 12:55:00 +05:30
parent 33e63f000a
commit a1b87f445b
6 changed files with 256 additions and 123 deletions

View File

@@ -212,8 +212,9 @@ def load_config(
merge_configs: Callable[[Dict, Dict], Dict],
*paths: str,
overrides: Optional[Iterable[str]] = None
) -> Dict[str, Any]:
) -> Tuple[Dict[str, Any], Tuple[str, ...]]:
ans = defaults._asdict()
found_paths = []
for path in paths:
if not path:
continue
@@ -222,11 +223,12 @@ def load_config(
vals = parse_config(f)
except (FileNotFoundError, PermissionError):
continue
found_paths.append(path)
ans = merge_configs(ans, vals)
if overrides is not None:
vals = parse_config(overrides)
ans = merge_configs(ans, vals)
return ans
return ans, tuple(found_paths)
def key_func() -> Tuple[Callable[..., Callable], Dict[str, Callable]]: