From 0bfe62b75edc05b173539d38825629e4eba5d0f6 Mon Sep 17 00:00:00 2001 From: claravox Date: Mon, 11 Dec 2023 13:46:17 +0100 Subject: [PATCH] Linting, copying yoda-portal linting style --- setup.cfg | 2 +- yoda_eus/app.py | 25 ++++++++++++++++++++----- 2 files changed, 21 insertions(+), 6 deletions(-) diff --git a/setup.cfg b/setup.cfg index 66c2fe2..5a52900 100644 --- a/setup.cfg +++ b/setup.cfg @@ -1,5 +1,5 @@ [flake8] -ignore=E501 +ignore=E221,E241,E402,W503,W605,F403,F405 import-order-style=smarkets strictness=short docstring_style=sphinx diff --git a/yoda_eus/app.py b/yoda_eus/app.py index 8030c4c..3974cb0 100644 --- a/yoda_eus/app.py +++ b/yoda_eus/app.py @@ -351,7 +351,10 @@ def process_forgot_password() -> Response: return response if (not is_email_valid(username) and app.config.get("MAIL_ONLY_TO_VALID_ADDRESS").lower() == "true"): - errors = {"errors": ["Unable to send password reset email, because your user name ('{}') is not a valid email address.".format(username)]} + errors = { + "errors": ["Unable to send password reset email, " + "because your user name ('{}') is not a valid email address.".format(username)] + } response = make_response(render_template('forgot-password.html', **errors)) response.status_code = 404 return response @@ -558,10 +561,14 @@ def refuse_api_requests() -> Response: The EUS presents two web interfaces (vhosts) on two different TCP ports. One of these does not have the API available, so that API access can be restricted on a TCP level (e.g. in firewalls). - If this instance does not have the API enabled, access to API functions is intercepted and blocked by this function. + If this instance does not have the API enabled, access to API functions is intercepted + and blocked by this function. """ if request.path.startswith("/api/"): - abort(make_response(jsonify({'status': 'error', 'message': 'The EUS API has been disabled on this interface.'}), 403)) + abort(make_response(jsonify({ + 'status': 'error', + 'message': 'The EUS API has been disabled on this interface.' + }), 403)) @app.before_request def check_api_secret() -> Response: @@ -576,7 +583,10 @@ def check_api_secret() -> Response: elif secret_header in request.headers and request.headers[secret_header] == app.config.get("API_SECRET"): return else: - abort(make_response(jsonify({'status': 'error', 'message': 'EUS secret header not present or does not match.'}), 403)) + abort(make_response(jsonify({ + 'status': 'error', + 'message': 'EUS secret header not present or does not match.' + }), 403)) @app.before_request def static_loader() -> Optional[Response]: @@ -590,7 +600,12 @@ def static_loader() -> Optional[Response]: :returns: Static file """ - result = get_validated_static_path(request.full_path, request.path, app.config.get('YODA_THEME_PATH'), app.config.get('YODA_THEME')) + result = get_validated_static_path( + request.full_path, + request.path, + app.config.get('YODA_THEME_PATH'), + app.config.get('YODA_THEME') + ) if result is not None: static_dir, asset_name = result return send_from_directory(static_dir, asset_name)