import pathlib
from typing import Dict
import yaml


def config_parser(file_path: pathlib.Path) -> Dict[int, list]:
    """Opens and parses a `yaml` configuration file.

    Uses [PyYAML](https://pyyaml.org) to parse the configuration file.

    Args:
        file_path (pathlib.Path): The path towards the user's
        configuration file.

    Raises:
        TypeError: Raises a `TypeError` if the parsed object is
            not of type `dict`. It means that the configuration file
            wasn't formatted properly.

    Returns:
        dict: A Python object representation of the `.yaml`
            configuration file.
    """
    with open(file_path) as stream:
        configuration: str = stream.read()

    parsed_file: dict = yaml.safe_load(configuration)

    if not isinstance(parsed_file, dict):
        raise TypeError("Your config is not formatted properly.")

    return parsed_file