from typing import Dict
from typing import Any
from pathlib import Path
import yaml


def load_config(fpath: str) -> Dict[str, Any]:
    """Loads a configuration from a path to a YAML file, allows for inheritance
    between files using the ``base_config`` key.

    Parameters
    ----------
    path : str
        Path to the (YAML) config file
    """
    path = Path(fpath)
    with open(path) as handle:
        config = yaml.load(handle, Loader=yaml.FullLoader)
        if 'base_config' in config:
            base_config = load_config(path.parent / config['base_config'])
            base_config.update(config)
            return base_config
        else:
            return config