diff --git a/demo/requirements.pip b/demo/requirements.pip index c6f5f42..ab0a814 100644 --- a/demo/requirements.pip +++ b/demo/requirements.pip @@ -2,5 +2,4 @@ django>=1.9.0 dj-rest-auth==0.9.5 djangorestframework>=3.7.0 django-allauth>=0.24.1 -six==1.9.0 django-rest-swagger==2.0.7 diff --git a/dj_rest_auth/app_settings.py b/dj_rest_auth/app_settings.py index 9974c2d..7f8094f 100644 --- a/dj_rest_auth/app_settings.py +++ b/dj_rest_auth/app_settings.py @@ -8,44 +8,27 @@ from dj_rest_auth.serializers import ( PasswordResetSerializer as DefaultPasswordResetSerializer, PasswordResetConfirmSerializer as DefaultPasswordResetConfirmSerializer, PasswordChangeSerializer as DefaultPasswordChangeSerializer) -from .utils import import_callable, default_create_token +from .utils import default_create_token -create_token = import_callable( - getattr(settings, 'REST_AUTH_TOKEN_CREATOR', default_create_token)) +create_token = getattr(settings, 'REST_AUTH_TOKEN_CREATOR', default_create_token) serializers = getattr(settings, 'REST_AUTH_SERIALIZERS', {}) -TokenSerializer = import_callable( - serializers.get('TOKEN_SERIALIZER', DefaultTokenSerializer)) +TokenSerializer = serializers.get('TOKEN_SERIALIZER', DefaultTokenSerializer) -JWTSerializer = import_callable( - serializers.get('JWT_SERIALIZER', DefaultJWTSerializer)) +JWTSerializer = serializers.get('JWT_SERIALIZER', DefaultJWTSerializer) -UserDetailsSerializer = import_callable( - serializers.get('USER_DETAILS_SERIALIZER', DefaultUserDetailsSerializer) -) +UserDetailsSerializer = serializers.get('USER_DETAILS_SERIALIZER', DefaultUserDetailsSerializer) -LoginSerializer = import_callable( - serializers.get('LOGIN_SERIALIZER', DefaultLoginSerializer) -) +LoginSerializer = serializers.get('LOGIN_SERIALIZER', DefaultLoginSerializer) -PasswordResetSerializer = import_callable( - serializers.get( +PasswordResetSerializer = serializers.get( 'PASSWORD_RESET_SERIALIZER', DefaultPasswordResetSerializer ) + +PasswordResetConfirmSerializer = serializers.get( + 'PASSWORD_RESET_CONFIRM_SERIALIZER', DefaultPasswordResetConfirmSerializer ) -PasswordResetConfirmSerializer = import_callable( - serializers.get( - 'PASSWORD_RESET_CONFIRM_SERIALIZER', - DefaultPasswordResetConfirmSerializer - ) -) - -PasswordChangeSerializer = import_callable( - serializers.get( - 'PASSWORD_CHANGE_SERIALIZER', - DefaultPasswordChangeSerializer - ) -) +PasswordChangeSerializer = serializers.get('PASSWORD_CHANGE_SERIALIZER', DefaultPasswordChangeSerializer) diff --git a/dj_rest_auth/models.py b/dj_rest_auth/models.py index a132f9c..5f690da 100644 --- a/dj_rest_auth/models.py +++ b/dj_rest_auth/models.py @@ -2,9 +2,7 @@ from django.conf import settings from rest_framework.authtoken.models import Token as DefaultTokenModel -from .utils import import_callable # Register your models here. -TokenModel = import_callable( - getattr(settings, 'REST_AUTH_TOKEN_MODEL', DefaultTokenModel)) +TokenModel = getattr(settings, 'REST_AUTH_TOKEN_MODEL', DefaultTokenModel) diff --git a/dj_rest_auth/registration/app_settings.py b/dj_rest_auth/registration/app_settings.py index c8cd25a..3e6db53 100644 --- a/dj_rest_auth/registration/app_settings.py +++ b/dj_rest_auth/registration/app_settings.py @@ -2,18 +2,17 @@ from django.conf import settings from rest_framework.permissions import AllowAny from rest_auth.registration.serializers import ( - RegisterSerializer as DefaultRegisterSerializer) -from ..utils import import_callable + RegisterSerializer as DefaultRegisterSerializer +) serializers = getattr(settings, 'REST_AUTH_REGISTER_SERIALIZERS', {}) -RegisterSerializer = import_callable( - serializers.get('REGISTER_SERIALIZER', DefaultRegisterSerializer)) +RegisterSerializer = serializers.get('REGISTER_SERIALIZER', DefaultRegisterSerializer) def register_permission_classes(): permission_classes = [AllowAny, ] for klass in getattr(settings, 'REST_AUTH_REGISTER_PERMISSION_CLASSES', tuple()): - permission_classes.append(import_callable(klass)) + permission_classes.append(klass) return tuple(permission_classes) diff --git a/dj_rest_auth/serializers.py b/dj_rest_auth/serializers.py index b645231..da8fef7 100644 --- a/dj_rest_auth/serializers.py +++ b/dj_rest_auth/serializers.py @@ -10,7 +10,6 @@ from rest_framework import serializers, exceptions from rest_framework.exceptions import ValidationError from .models import TokenModel -from .utils import import_callable # Get the UserModel UserModel = get_user_model() @@ -146,9 +145,7 @@ class JWTSerializer(serializers.Serializer): JWTSerializer. Defining it here to avoid circular imports """ rest_auth_serializers = getattr(settings, 'REST_AUTH_SERIALIZERS', {}) - JWTUserDetailsSerializer = import_callable( - rest_auth_serializers.get('USER_DETAILS_SERIALIZER', UserDetailsSerializer) - ) + JWTUserDetailsSerializer = rest_auth_serializers.get('USER_DETAILS_SERIALIZER', UserDetailsSerializer) user_data = JWTUserDetailsSerializer(obj['user'], context=self.context).data return user_data diff --git a/dj_rest_auth/utils.py b/dj_rest_auth/utils.py index 800f184..b69dae0 100644 --- a/dj_rest_auth/utils.py +++ b/dj_rest_auth/utils.py @@ -1,15 +1,3 @@ -from six import string_types -from importlib import import_module - - -def import_callable(path_or_callable): - if hasattr(path_or_callable, '__call__'): - return path_or_callable - else: - assert isinstance(path_or_callable, string_types) - package, attr = path_or_callable.rsplit('.', 1) - return getattr(import_module(package), attr) - def default_create_token(token_model, user, serializer): token, _ = token_model.objects.get_or_create(user=user) diff --git a/setup.py b/setup.py index 472ce6b..a57994e 100644 --- a/setup.py +++ b/setup.py @@ -25,7 +25,6 @@ setup( install_requires=[ 'Django>=1.8.0', 'djangorestframework>=3.1.3', - 'six>=1.9.0', ], extras_require={ 'with_social': ['django-allauth>=0.25.0'],