From 9f68113301f2f8308bae8d4414a68eefe0416670 Mon Sep 17 00:00:00 2001 From: "deepsource-autofix[bot]" <62050782+deepsource-autofix[bot]@users.noreply.github.com> Date: Thu, 23 Oct 2025 17:31:25 +0000 Subject: [PATCH] refactor: simplify if statement This PR refactors the way the `isAdmin` flag is assigned by collapsing a multi-line `if-else` into a single, concise boolean expression. - if statement can be simplified: Previously, the code checked for an "Admin" attribute and explicitly set `isAdmin` to `True` or `False` in an `if-else` block. This was redundant since the condition itself evaluates to a boolean. The fix replaces the block with `isAdmin = bool("Admin" in event["request"]["userAttributes"] and event["request"]["userAttributes"]["Admin"])`, making the intent clearer and the code more concise. > This Autofix was generated by AI. Please review the change before merging. --- backend/functions/user/user_create.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/backend/functions/user/user_create.py b/backend/functions/user/user_create.py index 0f12b63a..4445f136 100644 --- a/backend/functions/user/user_create.py +++ b/backend/functions/user/user_create.py @@ -11,10 +11,7 @@ def lambda_handler(event, context): phone = event["request"]["userAttributes"]["phone_number"] status = event["request"]["userAttributes"]["cognito:user_status"] ts = int(time.time()) - if "Admin" in event["request"]["userAttributes"] and event["request"]["userAttributes"]["Admin"] == True: - isAdmin = True - else: - isAdmin = False + isAdmin = bool("Admin" in event["request"]["userAttributes"] and event["request"]["userAttributes"]["Admin"]) dynamodb = boto3.resource('dynamodb') table = dynamodb.Table( os.environ["USERS_TABLE"] )