From 2a71d65a946ac4d8da2955a8e9009bf76652d2e7 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Fri, 21 Feb 2025 19:27:28 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- .secrets.baseline | 4 ++-- authentication/pipeline/user.py | 6 ++++-- authentication/pipeline/user_test.py | 16 +++++++++++----- 3 files changed, 17 insertions(+), 9 deletions(-) diff --git a/.secrets.baseline b/.secrets.baseline index 3c62e2505..c706aff3a 100644 --- a/.secrets.baseline +++ b/.secrets.baseline @@ -193,7 +193,7 @@ "filename": "main/settings.py", "hashed_secret": "09edaaba587f94f60fbb5cee2234507bcb883cc2", "is_verified": false, - "line_number": 954 + "line_number": 955 } ], "pants": [ @@ -240,5 +240,5 @@ } ] }, - "generated_at": "2025-01-22T20:35:24Z" + "generated_at": "2025-02-21T19:27:26Z" } diff --git a/authentication/pipeline/user.py b/authentication/pipeline/user.py index 8e770167f..b0ea554ab 100644 --- a/authentication/pipeline/user.py +++ b/authentication/pipeline/user.py @@ -9,7 +9,6 @@ from social_core.pipeline.partial import partial from social_django.models import UserSocialAuth - from authentication.exceptions import ( EmailBlockedException, InvalidPasswordException, @@ -82,7 +81,10 @@ def limit_one_auth_per_backend(strategy, backend, user, uid, **kwargs): # pylin # if there's at least one social auth and any of them don't match the incoming uid # we have or are trying to add multiple accounts if social_auths and any(auth.uid != uid for auth in social_auths): - raise AuthException(backend.name, "Another account is already linked to your MITxOnline account.") + raise AuthException( + backend.name, + "Another account is already linked to your MITxOnline account.", + ) return {} diff --git a/authentication/pipeline/user_test.py b/authentication/pipeline/user_test.py index 0513dd023..2b5b4cc6e 100644 --- a/authentication/pipeline/user_test.py +++ b/authentication/pipeline/user_test.py @@ -8,11 +8,9 @@ from django.db import IntegrityError from rest_framework import status from social_core.backends.email import EmailAuth -from social_django.utils import load_backend, load_strategy from social_core.exceptions import AuthException from social_django.models import UserSocialAuth - - +from social_django.utils import load_backend, load_strategy from authentication.exceptions import ( EmailBlockedException, @@ -550,7 +548,13 @@ def test_limit_one_auth_per_backend_no_user(mocker): """limit_one_auth_per_backend should not error if the user doesn't exist""" mock_strategy = mocker.Mock() mock_backend = mocker.Mock() - assert user_actions.limit_one_auth_per_backend(strategy=mock_strategy, backend=mock_backend, user=None, uid=None) == {} + assert ( + user_actions.limit_one_auth_per_backend( + strategy=mock_strategy, backend=mock_backend, user=None, uid=None + ) + == {} + ) + @pytest.mark.django_db def test_limit_one_auth_per_backend_conflicting_auth(mocker, user): @@ -563,4 +567,6 @@ def test_limit_one_auth_per_backend_conflicting_auth(mocker, user): assert UserSocialAuth.filter(user=user, provider=mock_backend.name).count() == 1 with pytest.raises(AuthException): - user_actions.limit_one_auth_per_backend(backend=mock_backend, user=user, strategy=mock_strategy, uid="non-matching") + user_actions.limit_one_auth_per_backend( + backend=mock_backend, user=user, strategy=mock_strategy, uid="non-matching" + )