def funccall(self, kids): kids = self._convert_children(kids) arglist = [k for k in kids[1:] if not isinstance(k, s_ast.CallKwarg)] args = s_ast.CallArgs(kids=arglist) kwarglist = [k for k in kids[1:] if isinstance(k, s_ast.CallKwarg)] kwargs = s_ast.CallKwargs(kids=kwarglist) return s_ast.FuncCall(kids=[kids[0], args, kwargs])
def funccall(self, kids, meta): kids = self._convert_children(kids) argkids = [] kwargkids = [] kwnames = set() for kid in kids[1:]: if isinstance(kid, s_ast.CallKwarg): name = kid.kids[0].valu if name in kwnames: mesg = f"Duplicate keyword argument '{name}' in function call" raise s_exc.BadSyntax(mesg=mesg, at=meta.start_pos) kwnames.add(name) kwargkids.append(kid) else: if kwargkids: mesg = 'Positional argument follows keyword argument in function call' raise s_exc.BadSyntax(mesg=mesg, at=meta.start_pos) argkids.append(kid) args = s_ast.CallArgs(kids=argkids) kwargs = s_ast.CallKwargs(kids=kwargkids) return s_ast.FuncCall(kids=[kids[0], args, kwargs])