def METHOD_NAME(tar_info: tarfile.TarInfo, mode: int) -> t.Optional[tarfile.TarInfo]:
    """
    Apply the specified permissions to the given file.
    Existing file type bits are preserved.
    """
    tar_info.mode &= ~(stat.S_IRWXU | stat.S_IRWXG | stat.S_IRWXO)
    tar_info.mode |= mode
    return tar_info