def METHOD_NAME(priority_override: Optional[int], has_quota: bool) -> Callable[[Optional[int], int], int]:
    if priority_override is not None:
        priority = lambda _, __: priority_override
    elif has_quota:
        priority = lambda previous_jobs, job_index: max(9999 - previous_jobs - job_index, 0)
    else:
        priority = lambda _, __: 0
    return priority