from pathlib import Path


def _check_download_dir(download_dir: str) -> str:
    """
    Check function used by download_dir setter as a callback.

    :param download_dir: directory where downloaded files must be recorded
    :raises NotADirectoryError: when the argument does not point to a valid directory
    :returns: the download_directory unchanged.
    """
    if not Path(download_dir).is_dir():
        raise NotADirectoryError(download_dir)
    return download_dir