formats a list of function arguments prettily but as working code

    (kwargs are tuples (argname, argvalue)
969350
def repr_args(args):
    
    res = []
    for x in args:
        if isinstance(x, tuple) and len(x) == 2:
            key, value = x
            # todo: exclude this key if value is its default
            res += ["%s=%s" % (key, repr_arg(value))]
        else:
            res += [repr_arg(x)]
    return ', '.join(res)
619277
def parse_args_and_kwargs(self, cmdline):
        '''
        
        '''
        # Parse args and kwargs
        args = []
        kwargs = {}

        if len(cmdline) > 1:
            for item in cmdline[1:]:
                if '=' in item:
                    (key, value) = item.split('=', 1)
                    kwargs[key] = value
                else:
                    args.append(item)
        return (args, kwargs)
510215
def _simplify_arguments(arguments):
    
    if len(arguments.args) == 0:
        return arguments.kwargs
    elif len(arguments.kwargs) == 0:
        return arguments.args
    else:
        return arguments
1023467
def _normalize_args(args):
    '''
    
    '''
    if isinstance(args, six.string_types):
        return shlex.split(args)

    if isinstance(args, (tuple, list)):
        return [six.text_type(arg) for arg in args]
    else:
        return [six.text_type(args)]
775461
def visit_arguments(self, node: AST, dfltChaining: bool = True) -> str:
        """"""
        args = node.args
        dflts = node.defaults
        vararg = node.vararg
        kwargs = node.kwonlyargs
        kwdflts = node.kw_defaults
        kwarg = node.kwarg
        self.compact = True
        n_args_without_dflt = len(args) - len(dflts)
        args_src = (arg.arg for arg in args[:n_args_without_dflt])
        dflts_src = (f"{arg.arg}={self.visit(dflt)}"
                     for arg, dflt in zip(args[n_args_without_dflt:], dflts))
        vararg_src = (f"*{vararg.arg}",) if vararg else ()
        kwargs_src = ((f"{kw.arg}={self.visit(dflt)}"
                       if dflt is not None else f"{kw.arg}")
                      for kw, dflt in zip(kwargs, kwdflts))
        kwarg_src = (f"**{kwarg.arg}",) if kwarg else ()
        src = ', '.join(chain(args_src, dflts_src, vararg_src,
                              kwargs_src, kwarg_src))
        self.compact = False
        return src
573087
def fn_kwargs(callable):
    
    fn = get_fn(callable)
    (args, _, _, defaults) = _inspect.getargspec(fn)
    if defaults is None: return { }
    return dict(list(zip(reversed(args), reversed(defaults))))
460696
def parse_args_kwargs(self, *args, **kwargs):
        ''''''
        # unpack the arginfo
        keys, defdict = self.arginfo
        assigned = keys[:len(args)]
        not_assigned = keys[len(args):]

        # validate kwargs
        for key in kwargs:
            assert key not in assigned
            assert key in keys

        # integrate args and kwargs
        knowns = dict(defdict, **kwargs)
        parsed_args = args + tuple([knowns[key] for key in not_assigned])
        return parsed_args
51597
def _list_args_kwargs(self):
        

        params = []
        params.extend(self._positional_args)
        params.extend(['{k}={v}'.format(k=k, v=v) for k, v in
                       self._key_value_args.items()])

        return params
147493
def _represent_arguments(*arguments, **keyword_arguments):
    
    argument_strings = [repr(a) for a in arguments]
    keyword_strings = [
        '='.join((k, repr(v))) for k, v in keyword_arguments.items()]
    return ', '.join(argument_strings + keyword_strings)
988643
def p_ty_funty_complex(self, p):
        ""
        argument_types=p[2]
        return_type=p[5]

        # Check here whether too many kwarg or vararg types are present
        # Each item in the list uses the dictionary encoding of tagged variants
        arg_types = [argty['arg_type'] for argty in argument_types if 'arg_type' in argty]
        vararg_types = [argty['vararg_type'] for argty in argument_types if 'vararg_type' in argty]
        kwarg_types = [argty['kwarg_type'] for argty in argument_types if 'kwarg_type' in argty]

        if len(vararg_types) > 1:
            raise Exception('Argument list with multiple vararg types: %s' % argument_types)

        if len(kwarg_types) > 1:
            raise Exception('Argument list with multiple kwarg types: %s' % argument_types)

        # All the arguments that are not special
        p[0] = Function(arg_types=arg_types,
                            vararg_type=vararg_types[0] if len(vararg_types) > 0 else None,
                            kwarg_type=kwarg_types[0] if len(kwarg_types) > 0 else None,
                            kwonly_arg_types=None,
                            return_type=return_type)
319138
def args_as_tuple(self):
        """"""
        if "," in self.arguments["header-names"]:
            result = tuple(tools.to_list(self.arguments["header-names"]))
        else:
            result = (self.arguments["header-names"].strip('"'),)
        result = result + (self.arguments["match-type"],)
        if "," in self.arguments["key-list"]:
            result = result + tuple(
                tools.to_list(self.arguments["key-list"], unquote=False))
        else:
            result = result + (self.arguments["key-list"].strip('"'),)
        return result
1212437
def _format_args():
        """"""
        if request and request.args.get('prettyprint'):
            return dict(
                indent=2,
                separators=(', ', ': '),
            )
        else:
            return dict(
                indent=None,
                separators=(',', ':'),
            )
757917
def convert_args_to_sets(f):
    
    @wraps(f)
    def wrapper(*args, **kwargs):
        args = (setify(x) for x in args)
        return f(*args, **kwargs)
    return wrapper
787096
def arg(*args, **kwargs):
    
    def _arg(f):
        if not hasattr(f, '_subcommand_args'):
            f._subcommand_args = []
        f._subcommand_args.append((args, kwargs))
        return f
    return _arg
644955
def _parse_codeargs(argstr):
    '''
    
    '''
    args = []
    kwargs = {}
    if isinstance(argstr, str):
        for a in argstr.split():
            if '=' in a:
                k,attr = a.split('=')
                kwargs[k] = attr
            else:
                args.append(a)
    rd = {'args':args, 'kwargs':kwargs}
    return rd
928475
def kwargs_helper(kwargs):
    """"""

    args = []
    for param, value in kwargs.items():
        param = kw_subst.get(param, param)
        args.append((param, value))
    return args
605625
def mk_kwargs(cls, kwargs):
        
        ret = {}
        kws = ['row_factory', 'body', 'parent']
        for k in kws:
            if k in kwargs:
                ret[k] = kwargs.pop(k)

        return ret