from textwrap import dedent


def reformat(source: str) -> str:
    """
    Formats the source string to strip newlines on both ends and dedents the
    the entire string

    :param source:
        The string to reformat
    """

    value = source if source else ''
    return dedent(value.strip('\n')).strip()