def METHOD_NAME(
        xc: XPathContext,
        p: FormulaToken,
        op: str,
        a1: ContextItem,
        a2: ContextItem,
) -> None:
    if (isinstance(a1,ModelValue.DateTime) and isinstance(a2,ModelValue.DateTime)):
        if a1.dateOnly == a2.dateOnly:
            return # can't interoperate between date and datetime
    elif isinstance(a1, bool) != isinstance(a2, bool):
        pass # fail if one arg is bool and the other is not (don't le t bool be subclass of num types)
    elif ((type(a1) == type(a2)) or
          (isinstance(a1, Number) and isinstance(a2, Number)) or
          (isinstance(a1, str) and isinstance(a2, str))):
        return
    elif op in ('+','-'):
        if ((isinstance(a1,ModelValue.DateTime) and isinstance(a2,(ModelValue.YearMonthDuration,datetime.timedelta))) or
            ((isinstance(a1,datetime.date) and isinstance(a2,datetime.timedelta)))):
            return
    else:
        if (isinstance(a1,datetime.date) and isinstance(a2,datetime.date)):
            return
    raise XPathException(p, 'err:XPTY0004', _('Value operation {0} incompatible arguments {1} ({2}) and {3} ({4})')
                                            .format(op, a1, pyTypeName(a1), a2, pyTypeName(a2)))