from typing import Union
from pathlib import Path


def add_extension(filename: Union[Path, str],
                  extension: str) -> str:
    """
    Adds an extension to filename.
    :param filename: original filename.
    :param extension: extension to add.
    """
    # set name
    name: str = str(filename)
    # set extension
    if extension.startswith('.'):
        ext = extension
    else:
        ext = '.' + extension
    if name.endswith(ext):  # check name
        return name
    else:
        return name + ext