from typing import Union
from pathlib import Path
from typing import Dict
from typing import Any
import json


def load_config(file_path: Union[str, Path]) -> Dict[str, Any]:
    """
    Load a (JSON) configuration file.

    Args:
        file_path: Path to the JSON file containing the configuration
            to be loaded.

    Returns:
        A dictionary containing configuration.
    """

    # Make sure that the file_path is an instance of Path
    if not isinstance(file_path, Path):
        file_path = Path(file_path)

    # Double-check that the target file exists
    if not file_path.exists():
        raise FileNotFoundError(f'{file_path} does not exist!')

    # Load the config file into a dict
    with open(file_path, 'r') as json_file:
        config: Dict[str, Any] = json.load(json_file)

    return config