summaryrefslogtreecommitdiff
path: root/django/contrib/auth
diff options
context:
space:
mode:
authorTim Graham <timograham@gmail.com>2015-02-09 13:19:34 -0500
committerTim Graham <timograham@gmail.com>2015-02-09 14:24:06 -0500
commita8b70d251d238b4e6cfc7bb4296da15494f8dff3 (patch)
tree94ef5bc53e59131906aecfcf792eeac86242aa62 /django/contrib/auth
parenteb406aa686ff1809903366ef6896037af2f1f69b (diff)
[1.8.x] Sorted imports with isort; refs #23860.
Backport of 0ed7d155635da9f79d4dd67e4889087d3673c6da from master
Diffstat (limited to 'django/contrib/auth')
-rw-r--r--django/contrib/auth/admin.py16
-rw-r--r--django/contrib/auth/apps.py2
-rw-r--r--django/contrib/auth/backends.py1
-rw-r--r--django/contrib/auth/decorators.py3
-rw-r--r--django/contrib/auth/forms.py13
-rw-r--r--django/contrib/auth/handlers/modwsgi.py2
-rw-r--r--django/contrib/auth/hashers.py14
-rw-r--r--django/contrib/auth/migrations/0001_initial.py4
-rw-r--r--django/contrib/auth/migrations/0002_alter_permission_name_max_length.py2
-rw-r--r--django/contrib/auth/migrations/0003_alter_user_email_max_length.py2
-rw-r--r--django/contrib/auth/migrations/0004_alter_user_username_opts.py2
-rw-r--r--django/contrib/auth/migrations/0005_alter_user_last_login_null.py2
-rw-r--r--django/contrib/auth/models.py19
-rw-r--r--django/contrib/auth/tests/backend_alias.py4
-rw-r--r--django/contrib/auth/tests/custom_user.py11
-rw-r--r--django/contrib/auth/tests/settings.py1
-rw-r--r--django/contrib/auth/tests/test_auth_backends.py11
-rw-r--r--django/contrib/auth/tests/test_basic.py2
-rw-r--r--django/contrib/auth/tests/test_context_processors.py4
-rw-r--r--django/contrib/auth/tests/test_forms.py12
-rw-r--r--django/contrib/auth/tests/test_handlers.py9
-rw-r--r--django/contrib/auth/tests/test_hashers.py10
-rw-r--r--django/contrib/auth/tests/test_management.py17
-rw-r--r--django/contrib/auth/tests/test_models.py4
-rw-r--r--django/contrib/auth/tests/test_signals.py3
-rw-r--r--django/contrib/auth/tests/test_templates.py7
-rw-r--r--django/contrib/auth/tests/test_tokens.py4
-rw-r--r--django/contrib/auth/tests/test_views.py23
-rw-r--r--django/contrib/auth/tests/urls.py10
-rw-r--r--django/contrib/auth/tests/urls_admin.py4
-rw-r--r--django/contrib/auth/tokens.py5
-rw-r--r--django/contrib/auth/views.py25
32 files changed, 131 insertions, 117 deletions
diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py
index 2df33c3c86..928236914a 100644
--- a/django/contrib/auth/admin.py
+++ b/django/contrib/auth/admin.py
@@ -1,19 +1,19 @@
-from django.db import transaction
from django.conf import settings
from django.conf.urls import url
-from django.contrib import admin
+from django.contrib import admin, messages
from django.contrib.admin.options import IS_POPUP_VAR
from django.contrib.auth import update_session_auth_hash
-from django.contrib.auth.forms import (UserCreationForm, UserChangeForm,
- AdminPasswordChangeForm)
-from django.contrib.auth.models import User, Group
-from django.contrib import messages
+from django.contrib.auth.forms import (
+ AdminPasswordChangeForm, UserChangeForm, UserCreationForm,
+)
+from django.contrib.auth.models import Group, User
from django.core.exceptions import PermissionDenied
-from django.http import HttpResponseRedirect, Http404
+from django.db import transaction
+from django.http import Http404, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.template.response import TemplateResponse
-from django.utils.html import escape
from django.utils.decorators import method_decorator
+from django.utils.html import escape
from django.utils.translation import ugettext, ugettext_lazy as _
from django.views.decorators.csrf import csrf_protect
from django.views.decorators.debug import sensitive_post_parameters
diff --git a/django/contrib/auth/apps.py b/django/contrib/auth/apps.py
index bbfcb7dbd1..109a34dff6 100644
--- a/django/contrib/auth/apps.py
+++ b/django/contrib/auth/apps.py
@@ -1,6 +1,6 @@
from django.apps import AppConfig
-from django.core import checks
from django.contrib.auth.checks import check_user_model
+from django.core import checks
from django.db.models.signals import post_migrate
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py
index 00a772fd4f..9f08259038 100644
--- a/django/contrib/auth/backends.py
+++ b/django/contrib/auth/backends.py
@@ -1,4 +1,5 @@
from __future__ import unicode_literals
+
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Permission
diff --git a/django/contrib/auth/decorators.py b/django/contrib/auth/decorators.py
index 99e2983e63..9b2504b33c 100644
--- a/django/contrib/auth/decorators.py
+++ b/django/contrib/auth/decorators.py
@@ -1,10 +1,11 @@
from functools import wraps
+
from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.core.exceptions import PermissionDenied
+from django.shortcuts import resolve_url
from django.utils.decorators import available_attrs
from django.utils.six.moves.urllib.parse import urlparse
-from django.shortcuts import resolve_url
def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index 3d19b2247e..cc3be5ba0b 100644
--- a/django/contrib/auth/forms.py
+++ b/django/contrib/auth/forms.py
@@ -3,6 +3,13 @@ from __future__ import unicode_literals
from collections import OrderedDict
from django import forms
+from django.contrib.auth import authenticate, get_user_model
+from django.contrib.auth.hashers import (
+ UNUSABLE_PASSWORD_PREFIX, identify_hasher,
+)
+from django.contrib.auth.models import User
+from django.contrib.auth.tokens import default_token_generator
+from django.contrib.sites.shortcuts import get_current_site
from django.core.mail import EmailMultiAlternatives
from django.forms.utils import flatatt
from django.template import loader
@@ -13,12 +20,6 @@ from django.utils.safestring import mark_safe
from django.utils.text import capfirst
from django.utils.translation import ugettext, ugettext_lazy as _
-from django.contrib.auth import authenticate, get_user_model
-from django.contrib.auth.models import User
-from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX, identify_hasher
-from django.contrib.auth.tokens import default_token_generator
-from django.contrib.sites.shortcuts import get_current_site
-
class ReadOnlyPasswordHashWidget(forms.Widget):
def render(self, name, value, attrs):
diff --git a/django/contrib/auth/handlers/modwsgi.py b/django/contrib/auth/handlers/modwsgi.py
index 8ada9750f1..6b91ed9c6e 100644
--- a/django/contrib/auth/handlers/modwsgi.py
+++ b/django/contrib/auth/handlers/modwsgi.py
@@ -1,5 +1,5 @@
-from django.contrib import auth
from django import db
+from django.contrib import auth
from django.utils.encoding import force_bytes
diff --git a/django/contrib/auth/hashers.py b/django/contrib/auth/hashers.py
index 9a85ebbbad..f7f143b78f 100644
--- a/django/contrib/auth/hashers.py
+++ b/django/contrib/auth/hashers.py
@@ -2,22 +2,22 @@ from __future__ import unicode_literals
import base64
import binascii
-from collections import OrderedDict
import hashlib
import importlib
+from collections import OrderedDict
-from django.dispatch import receiver
from django.conf import settings
-from django.core.signals import setting_changed
-from django.utils.encoding import force_bytes, force_str, force_text
from django.core.exceptions import ImproperlyConfigured
-from django.utils.crypto import (
- pbkdf2, constant_time_compare, get_random_string)
+from django.core.signals import setting_changed
+from django.dispatch import receiver
from django.utils import lru_cache
+from django.utils.crypto import (
+ constant_time_compare, get_random_string, pbkdf2,
+)
+from django.utils.encoding import force_bytes, force_str, force_text
from django.utils.module_loading import import_string
from django.utils.translation import ugettext_noop as _
-
UNUSABLE_PASSWORD_PREFIX = '!' # This will never be a valid encoded hash
UNUSABLE_PASSWORD_SUFFIX_LENGTH = 40 # number of random chars to add after UNUSABLE_PASSWORD_PREFIX
diff --git a/django/contrib/auth/migrations/0001_initial.py b/django/contrib/auth/migrations/0001_initial.py
index 33c8e00153..a58f73ab1a 100644
--- a/django/contrib/auth/migrations/0001_initial.py
+++ b/django/contrib/auth/migrations/0001_initial.py
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
+import django.contrib.auth.models
from django.core import validators
-from django.db import models, migrations
+from django.db import migrations, models
from django.utils import timezone
-import django.contrib.auth.models
class Migration(migrations.Migration):
diff --git a/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py b/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py
index 8e82223237..8b58e7814b 100644
--- a/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py
+++ b/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/auth/migrations/0003_alter_user_email_max_length.py b/django/contrib/auth/migrations/0003_alter_user_email_max_length.py
index a9b8058089..0a082f2656 100644
--- a/django/contrib/auth/migrations/0003_alter_user_email_max_length.py
+++ b/django/contrib/auth/migrations/0003_alter_user_email_max_length.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/auth/migrations/0004_alter_user_username_opts.py b/django/contrib/auth/migrations/0004_alter_user_username_opts.py
index 80a156e001..0f7bfdf3a7 100644
--- a/django/contrib/auth/migrations/0004_alter_user_username_opts.py
+++ b/django/contrib/auth/migrations/0004_alter_user_username_opts.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
import django.core.validators
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/auth/migrations/0005_alter_user_last_login_null.py b/django/contrib/auth/migrations/0005_alter_user_last_login_null.py
index 128a4e4962..b8b9289787 100644
--- a/django/contrib/auth/migrations/0005_alter_user_last_login_null.py
+++ b/django/contrib/auth/migrations/0005_alter_user_last_login_null.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
index 89b3054b70..4dc49c2d0c 100644
--- a/django/contrib/auth/models.py
+++ b/django/contrib/auth/models.py
@@ -1,21 +1,20 @@
from __future__ import unicode_literals
+from django.contrib import auth
+from django.contrib.auth.hashers import (
+ check_password, is_password_usable, make_password,
+)
+from django.contrib.auth.signals import user_logged_in
+from django.contrib.contenttypes.models import ContentType
+from django.core import validators
from django.core.exceptions import PermissionDenied
from django.core.mail import send_mail
-from django.core import validators
from django.db import models
from django.db.models.manager import EmptyManager
+from django.utils import six, timezone
from django.utils.crypto import get_random_string, salted_hmac
-from django.utils import six
-from django.utils.translation import ugettext_lazy as _
-from django.utils import timezone
-
-from django.contrib import auth
-from django.contrib.auth.hashers import (
- check_password, make_password, is_password_usable)
-from django.contrib.auth.signals import user_logged_in
-from django.contrib.contenttypes.models import ContentType
from django.utils.encoding import python_2_unicode_compatible
+from django.utils.translation import ugettext_lazy as _
def update_last_login(sender, user, **kwargs):
diff --git a/django/contrib/auth/tests/backend_alias.py b/django/contrib/auth/tests/backend_alias.py
index 1f31f7a16a..ae14d1538c 100644
--- a/django/contrib/auth/tests/backend_alias.py
+++ b/django/contrib/auth/tests/backend_alias.py
@@ -1,2 +1,4 @@
# For testing that auth backends can be referenced using a convenience import
-from django.contrib.auth.tests.test_auth_backends import ImportedModelBackend # NOQA
+from .test_auth_backends import ImportedModelBackend
+
+__all__ = ['ImportedModelBackend']
diff --git a/django/contrib/auth/tests/custom_user.py b/django/contrib/auth/tests/custom_user.py
index c856431bba..e7ce6162e9 100644
--- a/django/contrib/auth/tests/custom_user.py
+++ b/django/contrib/auth/tests/custom_user.py
@@ -1,13 +1,8 @@
-from django.db import models
from django.contrib.auth.models import (
- BaseUserManager,
- AbstractBaseUser,
- AbstractUser,
- UserManager,
- PermissionsMixin,
- Group,
- Permission,
+ AbstractBaseUser, AbstractUser, BaseUserManager, Group, Permission,
+ PermissionsMixin, UserManager,
)
+from django.db import models
# The custom User uses email as the unique identifier, and requires
diff --git a/django/contrib/auth/tests/settings.py b/django/contrib/auth/tests/settings.py
index ce2aa7d152..6fd02261de 100644
--- a/django/contrib/auth/tests/settings.py
+++ b/django/contrib/auth/tests/settings.py
@@ -2,7 +2,6 @@ import os
from django.utils._os import upath
-
AUTH_MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
diff --git a/django/contrib/auth/tests/test_auth_backends.py b/django/contrib/auth/tests/test_auth_backends.py
index d3b6c5de0c..8ccb6287e8 100644
--- a/django/contrib/auth/tests/test_auth_backends.py
+++ b/django/contrib/auth/tests/test_auth_backends.py
@@ -1,17 +1,20 @@
from __future__ import unicode_literals
+
from datetime import date
from django.conf import settings
+from django.contrib.auth import BACKEND_SESSION_KEY, authenticate, get_user
from django.contrib.auth.backends import ModelBackend
-from django.contrib.auth.models import User, Group, Permission, AnonymousUser
+from django.contrib.auth.hashers import MD5PasswordHasher
+from django.contrib.auth.models import AnonymousUser, Group, Permission, User
+from django.contrib.auth.tests.custom_user import (
+ CustomPermissionsUser, CustomUser, ExtensionUser,
+)
from django.contrib.auth.tests.utils import skipIfCustomUser
-from django.contrib.auth.tests.custom_user import ExtensionUser, CustomPermissionsUser, CustomUser
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
-from django.contrib.auth import authenticate, BACKEND_SESSION_KEY, get_user
from django.http import HttpRequest
from django.test import TestCase, override_settings
-from django.contrib.auth.hashers import MD5PasswordHasher
class CountingMD5PasswordHasher(MD5PasswordHasher):
diff --git a/django/contrib/auth/tests/test_basic.py b/django/contrib/auth/tests/test_basic.py
index fed94db82f..ca7db755e6 100644
--- a/django/contrib/auth/tests/test_basic.py
+++ b/django/contrib/auth/tests/test_basic.py
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
from django.apps import apps
from django.contrib.auth import get_user_model
-from django.contrib.auth.models import User, AnonymousUser
+from django.contrib.auth.models import AnonymousUser, User
from django.contrib.auth.tests.custom_user import CustomUser
from django.contrib.auth.tests.utils import skipIfCustomUser
from django.core.exceptions import ImproperlyConfigured
diff --git a/django/contrib/auth/tests/test_context_processors.py b/django/contrib/auth/tests/test_context_processors.py
index f96eac9db7..bb3c1820f6 100644
--- a/django/contrib/auth/tests/test_context_processors.py
+++ b/django/contrib/auth/tests/test_context_processors.py
@@ -1,7 +1,7 @@
from django.contrib.auth import authenticate
-from django.contrib.auth.models import User, Permission
+from django.contrib.auth.context_processors import PermLookupDict, PermWrapper
+from django.contrib.auth.models import Permission, User
from django.contrib.contenttypes.models import ContentType
-from django.contrib.auth.context_processors import PermWrapper, PermLookupDict
from django.db.models import Q
from django.test import TestCase, override_settings
diff --git a/django/contrib/auth/tests/test_forms.py b/django/contrib/auth/tests/test_forms.py
index 93ce9ad073..4628840400 100644
--- a/django/contrib/auth/tests/test_forms.py
+++ b/django/contrib/auth/tests/test_forms.py
@@ -3,16 +3,18 @@ from __future__ import unicode_literals
import re
from django import forms
+from django.contrib.auth.forms import (
+ AuthenticationForm, PasswordChangeForm, PasswordResetForm,
+ ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget, SetPasswordForm,
+ UserChangeForm, UserCreationForm,
+)
from django.contrib.auth.models import User
-from django.contrib.auth.forms import (UserCreationForm, AuthenticationForm,
- PasswordChangeForm, SetPasswordForm, UserChangeForm, PasswordResetForm,
- ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget)
from django.core import mail
from django.core.mail import EmailMultiAlternatives
-from django.forms.fields import Field, CharField
+from django.forms.fields import CharField, Field
from django.test import TestCase, override_settings
-from django.utils.encoding import force_text
from django.utils import translation
+from django.utils.encoding import force_text
from django.utils.text import capfirst
from django.utils.translation import ugettext as _
diff --git a/django/contrib/auth/tests/test_handlers.py b/django/contrib/auth/tests/test_handlers.py
index f4fa3030de..a6a4f9cd06 100644
--- a/django/contrib/auth/tests/test_handlers.py
+++ b/django/contrib/auth/tests/test_handlers.py
@@ -1,11 +1,12 @@
from __future__ import unicode_literals
-from django.contrib.auth.handlers.modwsgi import check_password, groups_for_user
-from django.contrib.auth.models import User, Group
+from django.contrib.auth.handlers.modwsgi import (
+ check_password, groups_for_user,
+)
+from django.contrib.auth.models import Group, User
from django.contrib.auth.tests.custom_user import CustomUser
from django.contrib.auth.tests.utils import skipIfCustomUser
-from django.test import TransactionTestCase
-from django.test import override_settings
+from django.test import TransactionTestCase, override_settings
# This must be a TransactionTestCase because the WSGI auth handler performs
diff --git a/django/contrib/auth/tests/test_hashers.py b/django/contrib/auth/tests/test_hashers.py
index 0c280ae158..de5d9233b3 100644
--- a/django/contrib/auth/tests/test_hashers.py
+++ b/django/contrib/auth/tests/test_hashers.py
@@ -4,14 +4,16 @@ from __future__ import unicode_literals
from unittest import skipUnless
from django.conf.global_settings import PASSWORD_HASHERS
-from django.contrib.auth.hashers import (is_password_usable, BasePasswordHasher,
- check_password, make_password, PBKDF2PasswordHasher, PBKDF2SHA1PasswordHasher,
- get_hasher, identify_hasher, UNUSABLE_PASSWORD_PREFIX, UNUSABLE_PASSWORD_SUFFIX_LENGTH)
+from django.contrib.auth.hashers import (
+ UNUSABLE_PASSWORD_PREFIX, UNUSABLE_PASSWORD_SUFFIX_LENGTH,
+ BasePasswordHasher, PBKDF2PasswordHasher, PBKDF2SHA1PasswordHasher,
+ check_password, get_hasher, identify_hasher, is_password_usable,
+ make_password,
+)
from django.test import SimpleTestCase
from django.test.utils import override_settings
from django.utils import six
-
try:
import crypt
except ImportError:
diff --git a/django/contrib/auth/tests/test_management.py b/django/contrib/auth/tests/test_management.py
index 3d2aaceee9..6a395bbe7b 100644
--- a/django/contrib/auth/tests/test_management.py
+++ b/django/contrib/auth/tests/test_management.py
@@ -1,20 +1,23 @@
from __future__ import unicode_literals
-from datetime import date
import locale
import sys
+from datetime import date
from django.apps import apps
-from django.contrib.auth import models, management
+from django.contrib.auth import management, models
from django.contrib.auth.checks import check_user_model
from django.contrib.auth.management import create_permissions
-from django.contrib.auth.management.commands import changepassword, createsuperuser
-from django.contrib.auth.models import User, Group
-from django.contrib.auth.tests.custom_user import CustomUser, CustomUserWithFK, Email
+from django.contrib.auth.management.commands import (
+ changepassword, createsuperuser,
+)
+from django.contrib.auth.models import Group, User
+from django.contrib.auth.tests.custom_user import (
+ CustomUser, CustomUserWithFK, Email,
+)
from django.contrib.auth.tests.utils import skipIfCustomUser
from django.contrib.contenttypes.models import ContentType
-from django.core import checks
-from django.core import exceptions
+from django.core import checks, exceptions
from django.core.management import call_command
from django.core.management.base import CommandError
from django.test import TestCase, override_settings, override_system_checks
diff --git a/django/contrib/auth/tests/test_models.py b/django/contrib/auth/tests/test_models.py
index b0a35a445a..ee51b15a98 100644
--- a/django/contrib/auth/tests/test_models.py
+++ b/django/contrib/auth/tests/test_models.py
@@ -1,5 +1,7 @@
from django.contrib.auth import get_user_model
-from django.contrib.auth.models import AbstractUser, Group, Permission, User, UserManager
+from django.contrib.auth.models import (
+ AbstractUser, Group, Permission, User, UserManager,
+)
from django.contrib.auth.tests.utils import skipIfCustomUser
from django.contrib.contenttypes.models import ContentType
from django.core import mail
diff --git a/django/contrib/auth/tests/test_signals.py b/django/contrib/auth/tests/test_signals.py
index 04c5b89e0b..0f099c53be 100644
--- a/django/contrib/auth/tests/test_signals.py
+++ b/django/contrib/auth/tests/test_signals.py
@@ -1,9 +1,8 @@
from django.contrib.auth import signals
from django.contrib.auth.models import User
from django.contrib.auth.tests.utils import skipIfCustomUser
-from django.test import TestCase
+from django.test import TestCase, override_settings
from django.test.client import RequestFactory
-from django.test import override_settings
@skipIfCustomUser
diff --git a/django/contrib/auth/tests/test_templates.py b/django/contrib/auth/tests/test_templates.py
index e2bb466d68..607db8764e 100644
--- a/django/contrib/auth/tests/test_templates.py
+++ b/django/contrib/auth/tests/test_templates.py
@@ -3,11 +3,10 @@ from django.contrib.auth.models import User
from django.contrib.auth.tests.utils import skipIfCustomUser
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.contrib.auth.views import (
- password_reset, password_reset_done, password_reset_confirm,
- password_reset_complete, password_change, password_change_done,
+ password_change, password_change_done, password_reset,
+ password_reset_complete, password_reset_confirm, password_reset_done,
)
-from django.test import RequestFactory, TestCase
-from django.test import override_settings
+from django.test import RequestFactory, TestCase, override_settings
from django.utils.encoding import force_bytes, force_text
from django.utils.http import urlsafe_base64_encode
diff --git a/django/contrib/auth/tests/test_tokens.py b/django/contrib/auth/tests/test_tokens.py
index 583546ab3a..b9433bdcfa 100644
--- a/django/contrib/auth/tests/test_tokens.py
+++ b/django/contrib/auth/tests/test_tokens.py
@@ -1,11 +1,11 @@
-from datetime import date, timedelta
import sys
import unittest
+from datetime import date, timedelta
from django.conf import settings
from django.contrib.auth.models import User
-from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.contrib.auth.tests.utils import skipIfCustomUser
+from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.test import TestCase
diff --git a/django/contrib/auth/tests/test_views.py b/django/contrib/auth/tests/test_views.py
index e5538517d0..76a97b5623 100644
--- a/django/contrib/auth/tests/test_views.py
+++ b/django/contrib/auth/tests/test_views.py
@@ -1,31 +1,32 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from importlib import import_module
import itertools
import re
+from importlib import import_module
from django.apps import apps
from django.conf import settings
-from django.contrib.sites.requests import RequestSite
from django.contrib.admin.models import LogEntry
-from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME
-from django.contrib.auth.forms import (AuthenticationForm, PasswordChangeForm,
- SetPasswordForm)
+from django.contrib.auth import REDIRECT_FIELD_NAME, SESSION_KEY
+from django.contrib.auth.forms import (
+ AuthenticationForm, PasswordChangeForm, SetPasswordForm,
+)
from django.contrib.auth.models import User
from django.contrib.auth.views import login as login_view, redirect_to_login
+from django.contrib.sessions.middleware import SessionMiddleware
+from django.contrib.sites.requests import RequestSite
from django.core import mail
from django.core.urlresolvers import NoReverseMatch, reverse, reverse_lazy
-from django.http import QueryDict, HttpRequest
+from django.http import HttpRequest, QueryDict
+from django.middleware.csrf import CsrfViewMiddleware
+from django.test import TestCase, ignore_warnings, override_settings
+from django.test.utils import patch_logger
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text
from django.utils.http import urlquote
-from django.utils.six.moves.urllib.parse import urlparse, ParseResult
+from django.utils.six.moves.urllib.parse import ParseResult, urlparse
from django.utils.translation import LANGUAGE_SESSION_KEY
-from django.test import TestCase, ignore_warnings, override_settings
-from django.test.utils import patch_logger
-from django.middleware.csrf import CsrfViewMiddleware
-from django.contrib.sessions.middleware import SessionMiddleware
# Needed so model is installed when tests are run independently:
from .custom_user import CustomUser # NOQA
diff --git a/django/contrib/auth/tests/urls.py b/django/contrib/auth/tests/urls.py
index 41e742a93b..6f83e0f420 100644
--- a/django/contrib/auth/tests/urls.py
+++ b/django/contrib/auth/tests/urls.py
@@ -1,13 +1,13 @@
-from django.conf.urls import url, include
+from django.conf.urls import include, url
from django.contrib import admin
-from django.contrib.auth.forms import AuthenticationForm
-from django.contrib.auth.urls import urlpatterns
from django.contrib.auth import views
from django.contrib.auth.decorators import login_required
+from django.contrib.auth.forms import AuthenticationForm
+from django.contrib.auth.urls import urlpatterns
from django.contrib.messages.api import info
-from django.http import HttpResponse, HttpRequest
+from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
-from django.template import Template, RequestContext
+from django.template import RequestContext, Template
from django.views.decorators.cache import never_cache
diff --git a/django/contrib/auth/tests/urls_admin.py b/django/contrib/auth/tests/urls_admin.py
index 49d6f38447..8d2fe3fd10 100644
--- a/django/contrib/auth/tests/urls_admin.py
+++ b/django/contrib/auth/tests/urls_admin.py
@@ -4,8 +4,8 @@ Test URLs for auth admins.
from django.conf.urls import include, url
from django.contrib import admin
-from django.contrib.auth.admin import UserAdmin, GroupAdmin
-from django.contrib.auth.models import User, Group
+from django.contrib.auth.admin import GroupAdmin, UserAdmin
+from django.contrib.auth.models import Group, User
from django.contrib.auth.urls import urlpatterns
# Create a silo'd admin site for just the user/group admins.
diff --git a/django/contrib/auth/tokens.py b/django/contrib/auth/tokens.py
index 89100daeb2..b925c21eff 100644
--- a/django/contrib/auth/tokens.py
+++ b/django/contrib/auth/tokens.py
@@ -1,8 +1,9 @@
from datetime import date
+
from django.conf import settings
-from django.utils.http import int_to_base36, base36_to_int
-from django.utils.crypto import constant_time_compare, salted_hmac
from django.utils import six
+from django.utils.crypto import constant_time_compare, salted_hmac
+from django.utils.http import base36_to_int, int_to_base36
class PasswordResetTokenGenerator(object):
diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
index 348fca8745..de76157bdc 100644
--- a/django/contrib/auth/views.py
+++ b/django/contrib/auth/views.py
@@ -1,25 +1,28 @@
import warnings
from django.conf import settings
+# Avoid shadowing the login() and logout() views below.
+from django.contrib.auth import (
+ REDIRECT_FIELD_NAME, get_user_model, login as auth_login,
+ logout as auth_logout, update_session_auth_hash,
+)
+from django.contrib.auth.decorators import login_required
+from django.contrib.auth.forms import (
+ AuthenticationForm, PasswordChangeForm, PasswordResetForm, SetPasswordForm,
+)
+from django.contrib.auth.tokens import default_token_generator
+from django.contrib.sites.shortcuts import get_current_site
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, QueryDict
+from django.shortcuts import resolve_url
from django.template.response import TemplateResponse
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.http import is_safe_url, urlsafe_base64_decode
-from django.utils.translation import ugettext as _
from django.utils.six.moves.urllib.parse import urlparse, urlunparse
-from django.shortcuts import resolve_url
-from django.views.decorators.debug import sensitive_post_parameters
+from django.utils.translation import ugettext as _
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_protect
-
-# Avoid shadowing the login() and logout() views below.
-from django.contrib.auth import (REDIRECT_FIELD_NAME, login as auth_login,
- logout as auth_logout, get_user_model, update_session_auth_hash)
-from django.contrib.auth.decorators import login_required
-from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm, SetPasswordForm, PasswordChangeForm
-from django.contrib.auth.tokens import default_token_generator
-from django.contrib.sites.shortcuts import get_current_site
+from django.views.decorators.debug import sensitive_post_parameters
@sensitive_post_parameters()