From 97119ced54f85444de8d092f6f886bba91c235e9 Mon Sep 17 00:00:00 2001 From: Fluffy-Bean Date: Tue, 4 Apr 2023 14:00:00 +0000 Subject: [PATCH] Linting --- gallery/__init__.py | 29 +++++++++++++++++++++++------ gallery/auth.py | 10 +++++----- gallery/db.py | 3 +-- setup/runner.py | 2 +- 4 files changed, 30 insertions(+), 14 deletions(-) diff --git a/gallery/__init__.py b/gallery/__init__.py index 280e6ba..99d6b5b 100644 --- a/gallery/__init__.py +++ b/gallery/__init__.py @@ -76,13 +76,30 @@ def create_app(test_config=None): @login_manager.unauthorized_handler def unauthorized(): - return render_template('error.html', error=401, - msg='You are not authorized to view this page!!!!'), 401 + error = 401 + msg = 'You are not authorized to view this page!!!!' + return render_template('error.html', error=error, msg=msg), error - # Load JS assets - assets.register('js_pre', Bundle('js/pre/*.js', output='gen/pre_packed.js', depends='js/pre/*.js')) - assets.register('js_post', Bundle('js/post/*.js', output='gen/post_packed.js', depends='js/pre/*.js')) - assets.register('styles', Bundle('sass/*.sass', filters='libsass', output='gen/styles.css', depends='sass/**/*.sass')) + js_pre = Bundle( + 'js/pre/*.js', + output='gen/pre_packed.js', + depends='js/pre/*.js' + ) + js_post = Bundle( + 'js/post/*.js', + output='gen/post_packed.js', + depends='js/post/*.js' + ) + styles = Bundle( + 'sass/*.sass', + filters='libsass', + output='gen/styles.css', + depends='sass/**/*.sass' + ) + + assets.register('js_pre', js_pre) + assets.register('js_post', js_post) + assets.register('styles', styles) # Error handlers, if the error is not a HTTP error, return 500 @app.errorhandler(Exception) diff --git a/gallery/auth.py b/gallery/auth.py index bc2d117..7121d66 100644 --- a/gallery/auth.py +++ b/gallery/auth.py @@ -7,7 +7,7 @@ from uuid import uuid4 import logging from datetime import datetime as dt -from flask import Blueprint, flash, redirect, request, url_for, abort, jsonify, session +from flask import Blueprint, flash, redirect, request, url_for, abort, jsonify from werkzeug.security import check_password_hash, generate_password_hash from flask_login import login_user, logout_user, login_required @@ -27,14 +27,14 @@ def login(): Log in a registered user by adding the user id to the session """ error = [] - + username = request.form['username'].strip() password = request.form['password'].strip() user = db_session.query(db.Users).filter_by(username=username).first() if not user and not check_password_hash(user.password, password): - logging.error('Login attempt from %s', username, request.remote_addr) + logging.error('Login attempt from %s', request.remote_addr) error.append('Username or Password is incorrect!') if error: @@ -53,7 +53,7 @@ def register(): Register a new user """ error = [] - + # Thanks Fennec for reminding me to strip out the whitespace lol username = request.form['username'].strip() email = request.form['email'].strip() @@ -79,7 +79,7 @@ def register(): error.append('Enter password again!') elif password_repeat != password: error.append('Passwords do not match!') - + user_exists = db_session.query(db.Users).filter_by(username=username).first() if user_exists: error.append('User already exists!') diff --git a/gallery/db.py b/gallery/db.py index f3ff844..a41db1b 100644 --- a/gallery/db.py +++ b/gallery/db.py @@ -4,8 +4,7 @@ OnlyLegs - Database models and functions for SQLAlchemy import os import platformdirs -from sqlalchemy import ( - create_engine, Column, Integer, String, Boolean, DateTime, ForeignKey, PickleType) +from sqlalchemy import create_engine, Column, Integer, String, DateTime, ForeignKey, PickleType from sqlalchemy.orm import declarative_base, relationship from flask_login import UserMixin diff --git a/setup/runner.py b/setup/runner.py index 84c0f9f..20496d2 100644 --- a/setup/runner.py +++ b/setup/runner.py @@ -26,7 +26,7 @@ class OnlyLegs(Application): return cfg @staticmethod - def prog(self): # pylint: disable=C0116, E0202 + def prog(): # pylint: disable=C0116, E0202 return 'OnlyLegs' def load(self):