def _flatten_args(pairs_in, args_out, prefix, visited_stack):
    'Helper function for flatten_args. See `flatten_args` below for details.'
    for (key, v) in pairs_in:
        if (not isinstance(key, str)):
            raise ValueError(('Keys must be strings. %r' % key))
        flat_key = (((prefix + '.') + key) if prefix else key)
        if (v is None):
            args_out[flat_key] = 'none'
        elif isinstance(v, str):
            args_out[flat_key] = v
        elif isinstance(v, bool):
            args_out[flat_key] = ('true' if v else 'false')
        elif isinstance(v, numbers.Number):
            args_out[flat_key] = str(v)
        elif isinstance(v, Mapping):
            if (not any(((v is entry) for entry in visited_stack))):
                _flatten_args(v.items(), args_out, flat_key, (visited_stack + [v]))
        elif isinstance(v, Sequence):
            if (not any(((v is entry) for entry in visited_stack))):
                _flatten_args(((str((i + 1)), vv) for (i, vv) in enumerate(v)), args_out, flat_key, (visited_stack + [v]))
        else:
            raise ValueError("Value for '{}' cannot be type: '{}'".format(flat_key, str(type(v))))
Helper function for flatten_args. See `flatten_args` below for details.
def _flatten_args(pairs_in, args_out, prefix, visited_stack):
    
    for (key, v) in pairs_in:
        if (not isinstance(key, str)):
            raise ValueError(('Keys must be strings. %r' % key))
        flat_key = (((prefix + '.') + key) if prefix else key)
        if (v is None):
            args_out[flat_key] = 'none'
        elif isinstance(v, str):
            args_out[flat_key] = v
        elif isinstance(v, bool):
            args_out[flat_key] = ('true' if v else 'false')
        elif isinstance(v, numbers.Number):
            args_out[flat_key] = str(v)
        elif isinstance(v, Mapping):
            if (not any(((v is entry) for entry in visited_stack))):
                _flatten_args(v.items(), args_out, flat_key, (visited_stack + [v]))
        elif isinstance(v, Sequence):
            if (not any(((v is entry) for entry in visited_stack))):
                _flatten_args(((str((i + 1)), vv) for (i, vv) in enumerate(v)), args_out, flat_key, (visited_stack + [v]))
        else:
            raise ValueError("Value for '{}' cannot be type: '{}'".format(flat_key, str(type(v))))