A few pylint fixes
This commit is contained in:
parent
0dfb1fcd4e
commit
b94a3d2ae4
4 changed files with 8 additions and 10 deletions
|
@ -9,7 +9,9 @@ from os import makedirs
|
|||
import flask
|
||||
from werkzeug.middleware.proxy_fix import ProxyFix
|
||||
|
||||
from . import const
|
||||
from . import const, models
|
||||
from .api import api
|
||||
from .views import views
|
||||
|
||||
__version__: str = "3.1.2-nyx"
|
||||
|
||||
|
@ -28,9 +30,6 @@ def create_app(db: str = "sqlite:///imag.db") -> t.Tuple[flask.Flask, t.Optional
|
|||
app.config["PREFERRED_URL_SCHEME"] = "https"
|
||||
|
||||
app.config["SECRET_KEY"] = secrets.SystemRandom().randbytes(1024 * 16)
|
||||
|
||||
from . import models
|
||||
|
||||
models.limiter.init_app(app)
|
||||
models.db.init_app(app)
|
||||
|
||||
|
@ -77,9 +76,6 @@ def create_app(db: str = "sqlite:///imag.db") -> t.Tuple[flask.Flask, t.Optional
|
|||
|
||||
return response
|
||||
|
||||
from .api import api
|
||||
from .views import views
|
||||
|
||||
app.register_blueprint(api, url_prefix="/api/")
|
||||
app.register_blueprint(views, url_prefix="/")
|
||||
|
||||
|
|
|
@ -10,6 +10,7 @@ from .util import make_api
|
|||
|
||||
|
||||
class Bp(Blueprint):
|
||||
"""app routing helper"""
|
||||
def get(self, rule: str, **kwargs: Any) -> Any:
|
||||
"""wrapper for GET"""
|
||||
return self.route(rule=rule, methods=("GET",), **kwargs)
|
||||
|
|
|
@ -48,8 +48,7 @@ def with_access(
|
|||
|
||||
if access and (access.access_level.value >= access_level.value): # type: ignore
|
||||
return fn(*args, **kwargs) # type: ignore
|
||||
else:
|
||||
flask.abort(403)
|
||||
flask.abort(403)
|
||||
|
||||
return decorator
|
||||
|
||||
|
|
|
@ -82,8 +82,10 @@ def image(iid: int) -> flask.Response:
|
|||
with open(os.path.join(const.IMAGE_DIR, str(iid)), "rb") as fp:
|
||||
file: bytes = fp.read()
|
||||
return flask.Response(file, mimetype=magic.from_buffer(file, mime=True)) # type: ignore
|
||||
except Exception:
|
||||
except FileNotFoundError:
|
||||
flask.abort(404)
|
||||
except Exception:
|
||||
flask.abort(500)
|
||||
|
||||
|
||||
@views.post("/edit/<int:iid>")
|
||||
|
|
Loading…
Add table
Reference in a new issue