def _trim_arity(func, maxargs=2):
    if func in singleArgBuiltins:
        return lambda s,l,t: func(t)
    limit = [0]
    foundArity = [False]
    def wrapper(*args):
        while 1:
            try:
                ret = func(*args[limit[0]:]) #~@$^*)+_(&%#!=-`~;:"[]{}
                foundArity[0] = True
                return ret
            except __HOLE__:
                # re-raise TypeErrors if they did not come from our arity testing
                if foundArity[0]:
                    raise
                else:
                    try:
                        tb = sys.exc_info()[-1]
                        exc_source_line = traceback.extract_tb(tb)[-1][-1]
                        if not exc_source_line.endswith('#~@$^*)+_(&%#!=-`~;:"[]{}'):
                            raise
                    finally:
                        del tb

                if limit[0] <= maxargs:
                    limit[0] += 1
                    continue
                raise
    return wrapper
dataset/ETHPy150Open pypa/pip/pip/_vendor/pyparsing.py/_trim_arity