from pathlib import Path
from typing import Dict
from typing import Union
from typing import List
import yaml


def temp_environment_yml(tmp_path_factory):
    """
    Returns a valid temporary environment.yml file
    """

    env_file: Path = tmp_path_factory.mktemp("temp").joinpath("environment.yml")

    fake_env_info: Dict[str, Union[str, List[str]]] = {
        "name": "my_yml_env",
        "channels": ["defaults", "conda-forge"],
        "dependencies": [
            "python>3.7",
            "invoke",
            "black",
            "flake8",
            "isort",
            "mypy",
            "rich",
            "requests",
            "numpy",
            "pandas",
        ],
    }

    with open(env_file, mode="w", encoding="utf-8") as f:
        yaml.dump(fake_env_info, f)

    return env_file