from typing import Union
from typing import Dict
from typing import Any
import yaml


def _from_yaml(filename: str) -> Union[Dict[str, Any], None]:
    """
    Converts a YAML file into a Python dict

    :param filename:
    :return:
    """
    if not filename.endswith(".yml"):
        raise ValueError("YAML config files should end with '.yml' extension (RTFMG).")

    with open(filename) as f:
        obj = yaml.load(f, Loader=yaml.FullLoader)

    return obj or None