human
I wrote the below code

    def upgrade_decorator(upgrade_func):
        @event(u'manager.upgrade')
        def upgrade_wrapper(manager):
            with Session() as session:
                current_ver = get_version(plugin, session=session)
                try:
                    new_ver = upgrade_func(current_ver, session)
                except UpgradeImpossible:
                    log.info((u'Plugin    %s    database    is    not    upgradable.    Flushing    data    and    regenerating.' % plugin))
                    reset_schema(plugin, session=session)
                    manager.db_upgraded = True
                except Exception as e:
                    log.exception((u'Failed    to    upgrade    database    for    plugin    %s:    %s' % (plugin, e)))
                    session.rollback()
                    manager.shutdown(finish_queue=False)
                else:
                    current_ver = ((-1) if (current_ver is None) else current_ver)
                    if (new_ver > current_ver):
                        log.info((u'Plugin    `%s`    schema    upgraded    successfully' % plugin))
                        set_version(plugin, new_ver, session=session)
                        manager.db_upgraded = True
                    elif (new_ver < current_ver):
                        log.critical((u'A    lower    schema    version    was    returned    (%s)    from    plugin    %s    upgrade    function    than    passed    in    (%s)' % (new_ver, plugin, current_ver)))
                        session.rollback()
                        manager.shutdown(finish_queue=False)
        return upgrade_wrapper
    return upgrade_decorator

What's a good function header?

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

def upgrade(plugin):