Flask Framework - user sign in
There are a few things bothering me in one version or an other:


the error=error or None is unnecessary as error is either assigned 'Invalid Email or Password' or  None, stick to the simpler error=error;
the ): on its own line in the third version is more than disturbing, it feels like a syntax error and force the reader to go through the code again to understand what is going on. Instead, put it at the end of the previous line and include more indentation to distinguish the condition from the rest.;
each version seem to consider the success case as an error of the error case, that is the flow of reading the code does not feel as if it's a signin function (this seems to be the bad outcome) but rather a deny_access function;
the third version seems to accept invalid password and deny entry on successful passwords.


Instead, I would test each failing condition and bail out with a specific error message at that point rather than making the error case the "natural" exit point of the function:

@app.route('/signin', methods=['POST'])
@public
def do_signin():
    user = get_user_by_email([request.form.get('email')])
    if user is None:
        return render_template('signin.html', error='Invalid Email')

    if not bcrypt.checkpw(
            request.form.get('password').encode('utf-8'),
            user['password'].encode('utf-8')):
        return render_template('signin.html', error='Invalid Password')

    session[SESSION_TOKEN] = add_token(user['id'])
    return redirect(url_for('index'))