from typing import Union
from typing import List


def read_file(file_path: str, split: bool = False) -> Union[str, List[str]]:
    """
    Reads a text file.

    >>> from snakypy import helpers
    >>> file = '/tmp/my_file.txt'
    >>> helpers.files.create_file('My content file', file, force=True)
    True
    >>> helpers.files.read_file(file)
    'My content file'

    Args:
        file_path (str): You must receive the full/absolute file path.

        split (bool): If this option is True, a list will be returned where
                                the breaks will be made using line skips. (default: {False})

    Returns:
        [str|list]: By default it returns a string. If the option split=True,
                    a list of line breaks will be returned.
    """
    try:
        with open(file_path) as f:
            if split:
                return f.read().split("\n")
            return f.read()
    except FileNotFoundError as err:
        raise FileNotFoundError(f'>>> File "{file_path}" does not exist. {err}')