from typing import Tuple


def _mk_ne_isin_condition(values: Tuple[int, ...],
                          var_name: str = 'a',
                          invert: bool = False) -> str:
    """
    Produce numexpr expression equivalent to numpys `.isin`

     - ((a==v1)|(a==v2)|..|a==vn)   when invert=False
     - ((a!=v1)&(a!=v2)&..&a!=vn)   when invert=True
    """
    op1, op2 = ('!=', '&') if invert else ('==', '|')
    parts = [f'({var_name}{op1}{val})' for val in values]
    return f'({op2.join(parts)})'