human
Here's a good function header given the following:
I wrote the below code

    internal_keys = (internal_keys or [])
    _verify_query_segregation(query)
    valid_keys = inspect.getargspec(db_func)[0]
    internal_timestamp_keys = ['end_timestamp', 'start_timestamp', 'end_timestamp_op', 'start_timestamp_op']
    if ('start_timestamp' in valid_keys):
        internal_keys += internal_timestamp_keys
        valid_keys += ['timestamp', 'search_offset']
    internal_keys.append('self')
    internal_keys.append('metaquery')
    valid_keys = (set(valid_keys) - set(internal_keys))
    translation = {'user_id': 'user', 'project_id': 'project', 'resource_id': 'resource'}
    has_timestamp_query = _validate_timestamp_fields(query, 'timestamp', ('lt', 'le', 'gt', 'ge'), allow_timestamps)
    has_search_offset_query = _validate_timestamp_fields(query, 'search_offset', 'eq', allow_timestamps)
    if (has_search_offset_query and (not has_timestamp_query)):
        raise wsme.exc.InvalidInput('field', 'search_offset', ('search_offset    cannot    be    used    without    ' + 'timestamp'))
    def _is_field_metadata(field):
        return (field.startswith('metadata.') or field.startswith('resource_metadata.'))
    for i in query:
        if (i.field not in ('timestamp', 'search_offset')):
            key = translation.get(i.field, i.field)
            operator = i.op
            if ((key in valid_keys) or _is_field_metadata(i.field)):
                if (operator == 'eq'):
                    if (key == 'enabled'):
                        i._get_value_as_type('boolean')
                    elif _is_field_metadata(key):
                        i._get_value_as_type()
                else:
                    raise wsme.exc.InvalidInput('op', i.op, ('unimplemented    operator    for    %s' % i.field))
            else:
                msg = ('unrecognized    field    in    query:    %s,    valid    keys:    %s' % (query, sorted(valid_keys)))
                raise wsme.exc.UnknownArgument(key, msg)

What's a good function header?
assistant
#Here's a good function header.

def validate_query(query, db_func, internal_keys=None, allow_timestamps=True):