# Buggy code
def _get_new_completion(self, before_cursor, under_cursor):
    """Get the completion function based on the current command text.

    Args:
        before_cursor: The command chunks before the cursor.
        under_cursor: The command chunk under the cursor.

    Return:
        A completion model.
    """
    if "--" in before_cursor or under_cursor.startswith("-"):
        # cursor on a flag or after an explicit split (--)
        return None
    log.completion.debug("Before removing flags: {}".format(before_cursor))
    before_cursor = [x for x in before_cursor if not x.startswith("-")]
    log.completion.debug("After removing flags: {}".format(before_cursor))
    if not before_cursor:
        # '|' or 'set|'
        log.completion.debug("Starting command completion")
        return miscmodels.command
    try:
        cmd = cmdutils.cmd_dict[before_cursor[0]]
    except KeyError:
        log.completion.debug(
            "No completion for unknown command: {}".format(before_cursor[0])
        )
        return None
    argpos = len(before_cursor) - 1
    try:
        func = cmd.get_pos_arg_info(argpos).completion
    except IndexError:
        log.completion.debug("No completion in position {}".format(argpos))
        return None
    return func


# Traceback (TypeError)
17:56:49 DEBUG    completion completer:_partition:141 partitioning ['-w', ' open', ' '] around position 8
17:56:49 DEBUG    completion completer:_partition:153 partitioned: ['-w', 'open'] '' []
17:56:49 DEBUG    completion completer:_update_completion:236 Updating completion: ['-w', 'open']  []
17:56:49 DEBUG    completion completer:_get_new_completion:89 Before removing flags: ['-w', 'open']
17:56:49 DEBUG    completion completer:_get_new_completion:91 After removing flags: ['open']
17:56:49 DEBUG    completion debug:__exit__:264 Starting url completion took 6.5e-05 seconds.
17:56:49 ERROR    misc       crashsignal:exception_hook:216 Uncaught exception
Traceback (most recent call last):
File "/home/florian/proj/qutebrowser/git/qutebrowser/completion/completer.py", line 255, in _update_completion
model = func(*args, info=info)
TypeError: url() takes 0 positional arguments but 1 positional argument (and 1 keyword-only argument) were given

# Fixed code
def _get_new_completion(self, before_cursor, under_cursor):
    """Get the completion function based on the current command text.

    Args:
        before_cursor: The command chunks before the cursor.
        under_cursor: The command chunk under the cursor.

    Return:
        A completion model.
    """
    if "--" in before_cursor or under_cursor.startswith("-"):
        # cursor on a flag or after an explicit split (--)
        return None
    log.completion.debug("Before removing flags: {}".format(before_cursor))
    if not before_cursor:
        # '|' or 'set|'
        log.completion.debug("Starting command completion")
        return miscmodels.command
    try:
        cmd = cmdutils.cmd_dict[before_cursor[0]]
    except KeyError:
        log.completion.debug(
            "No completion for unknown command: {}".format(before_cursor[0])
        )
        return None

    before_cursor = [x for x in before_cursor if not x.startswith("-")]
    log.completion.debug("After removing flags: {}".format(before_cursor))
    argpos = len(before_cursor) - 1
    try:
        func = cmd.get_pos_arg_info(argpos).completion
    except IndexError:
        log.completion.debug("No completion in position {}".format(argpos))
        return None
    return func