Apply expanduser and expandvars to directory to expand '~' and env vars.

def expand(directory: str) -> str:
    """Apply expanduser and expandvars to directory to expand '~' and env vars."""
    temp1 = os.path.expanduser(directory)
    return os.path.expandvars(temp1)