human
I wrote the below code

    keys = set()
    num_args = 0
    def next_char(i):
        i += 1
        if (i == len(format_string)):
            raise IncompleteFormatString
        return (i, format_string[i])
    i = 0
    while (i < len(format_string)):
        char = format_string[i]
        if (char == '%'):
            (i, char) = next_char(i)
            key = None
            if (char == '('):
                depth = 1
                (i, char) = next_char(i)
                key_start = i
                while (depth != 0):
                    if (char == '('):
                        depth += 1
                    elif (char == ')'):
                        depth -= 1
                    (i, char) = next_char(i)
                key_end = (i - 1)
                key = format_string[key_start:key_end]
            while (char in '#0-    +'):
                (i, char) = next_char(i)
            if (char == '*'):
                num_args += 1
                (i, char) = next_char(i)
            else:
                while (char in string.digits):
                    (i, char) = next_char(i)
            if (char == '.'):
                (i, char) = next_char(i)
                if (char == '*'):
                    num_args += 1
                    (i, char) = next_char(i)
                else:
                    while (char in string.digits):
                        (i, char) = next_char(i)
            if (char in 'hlL'):
                (i, char) = next_char(i)
            if PY3K:
                flags = 'diouxXeEfFgGcrs%a'
            else:
                flags = 'diouxXeEfFgGcrs%'
            if (char not in flags):
                raise UnsupportedFormatCharacter(i)
            if key:
                keys.add(key)
            elif (char != '%'):
                num_args += 1
        i += 1
    return (keys, num_args)

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

def parse_format_string(format_string):