From d04ce483a2b4f65488aa160cda2904c0b84ded5c Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Wed, 12 Jun 2024 00:41:59 +0000 Subject: [PATCH] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- rest_framework_simplejwt/serializers.py | 8 ++++++-- tests/test_serializers.py | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/rest_framework_simplejwt/serializers.py b/rest_framework_simplejwt/serializers.py index d7c1d99dd..b0394e44d 100644 --- a/rest_framework_simplejwt/serializers.py +++ b/rest_framework_simplejwt/serializers.py @@ -5,7 +5,7 @@ from django.contrib.auth.models import AbstractBaseUser, update_last_login from django.utils.translation import gettext_lazy as _ from rest_framework import exceptions, serializers -from rest_framework.exceptions import ValidationError, AuthenticationFailed +from rest_framework.exceptions import AuthenticationFailed, ValidationError from .models import TokenUser from .settings import api_settings @@ -112,7 +112,11 @@ def validate(self, attrs: Dict[str, Any]) -> Dict[str, str]: refresh = self.token_class(attrs["refresh"]) user_id = refresh.payload.get(api_settings.USER_ID_CLAIM, None) - if user_id and (user := get_user_model().objects.get(**{api_settings.USER_ID_FIELD: user_id})): + if user_id and ( + user := get_user_model().objects.get( + **{api_settings.USER_ID_FIELD: user_id} + ) + ): if not api_settings.USER_AUTHENTICATION_RULE(user): raise AuthenticationFailed( self.error_messages["no_active_account"], diff --git a/tests/test_serializers.py b/tests/test_serializers.py index d8bd3df4f..56523365b 100644 --- a/tests/test_serializers.py +++ b/tests/test_serializers.py @@ -262,7 +262,7 @@ def test_it_should_raise_error_for_inactive_users(self): self.user.save() s = TokenRefreshSerializer(data={"refresh": str(refresh)}) - + with self.assertRaises(drf_exceptions.AuthenticationFailed) as e: s.is_valid()