From 1345b92f8540c06dafd1a2fbf649f39522a490dc Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Wed, 7 Oct 2020 05:35:16 +0530 Subject: [PATCH] chore: Refactor unnecessary `else` / `elif` when `if` block has a `return` statement (#7332) Co-authored-by: deepsource-autofix[bot] <62050782+deepsource-autofix[bot]@users.noreply.github.com> --- app/api/helpers/payment.py | 23 +++++++++++------------ app/api/users.py | 3 +-- app/views/healthcheck.py | 3 +-- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/app/api/helpers/payment.py b/app/api/helpers/payment.py index b57c733a57..5a15b1c8e4 100644 --- a/app/api/helpers/payment.py +++ b/app/api/helpers/payment.py @@ -55,19 +55,18 @@ def get_credentials(event=None): 'PUBLISHABLE_KEY': settings["stripe_publishable_key"], } return None + if represents_int(event): + authorization = StripeAuthorization.query.filter_by( + event_id=event + ).first() else: - if represents_int(event): - authorization = StripeAuthorization.query.filter_by( - event_id=event - ).first() - else: - authorization = event.stripe_authorization - if authorization: - return { - 'SECRET_KEY': authorization.stripe_secret_key, - 'PUBLISHABLE_KEY': authorization.stripe_publishable_key, - } - return None + authorization = event.stripe_authorization + if authorization: + return { + 'SECRET_KEY': authorization.stripe_secret_key, + 'PUBLISHABLE_KEY': authorization.stripe_publishable_key, + } + return None @staticmethod def get_event_organizer_credentials_from_stripe(stripe_auth_code): diff --git a/app/api/users.py b/app/api/users.py index 3607bab587..48bd74430c 100644 --- a/app/api/users.py +++ b/app/api/users.py @@ -400,8 +400,7 @@ def is_email_available(): if get_count(db.session.query(User).filter_by(email=email)): return jsonify(result="False") return jsonify(result="True") - else: - abort(make_response(jsonify(error="Email field missing"), 422)) + abort(make_response(jsonify(error="Email field missing"), 422)) def start_image_resizing_tasks(user, original_image_url): diff --git a/app/views/healthcheck.py b/app/views/healthcheck.py index f6074ead62..860c1e90df 100644 --- a/app/views/healthcheck.py +++ b/app/views/healthcheck.py @@ -88,5 +88,4 @@ def health_check_migrations(): return True, result[1] # the exception will be caught in check_migrations function, so no need for sentry catching exception here return False, result[1] - else: - return False, 'The health_check_migration test is still running' + return False, 'The health_check_migration test is still running'