summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJannis Leidel <jannis@leidel.info>2011-07-13 09:35:51 +0000
committerJannis Leidel <jannis@leidel.info>2011-07-13 09:35:51 +0000
commit24f4764a48e4141923a78c8820e4cd7b411ec0fc (patch)
treeeed2e98eb3aad1e10c7fda902bc8b875e19929e2
parent956da729d19d619c210a2466d4435d4967249e7f (diff)
Fixed #16225 -- Removed unused imports. Many thanks to Aymeric Augustin for the work on the patch and Alex for reviewing.
git-svn-id: http://code.djangoproject.com/svn/django/trunk@16539 bcc190cf-cafb-0310-a4f2-bffc1f526a37
-rw-r--r--django/bin/profiling/gather_profile_stats.py3
-rw-r--r--django/contrib/admin/templatetags/admin_list.py4
-rw-r--r--django/contrib/admin/widgets.py1
-rw-r--r--django/contrib/admindocs/views.py7
-rw-r--r--django/contrib/auth/__init__.py1
-rw-r--r--django/contrib/auth/backends.py1
-rw-r--r--django/contrib/auth/forms.py5
-rw-r--r--django/contrib/auth/management/__init__.py4
-rw-r--r--django/contrib/auth/models.py5
-rw-r--r--django/contrib/auth/tests/auth_backends.py2
-rw-r--r--django/contrib/auth/tests/forms.py1
-rw-r--r--django/contrib/auth/tests/tokens.py2
-rw-r--r--django/contrib/formtools/preview.py6
-rw-r--r--django/contrib/formtools/utils.py1
-rw-r--r--django/contrib/formtools/wizard/storage/session.py1
-rw-r--r--django/contrib/formtools/wizard/tests/namedwizardtests/tests.py3
-rw-r--r--django/contrib/formtools/wizard/views.py1
-rw-r--r--django/contrib/gis/admin/options.py1
-rw-r--r--django/contrib/gis/admin/widgets.py1
-rw-r--r--django/contrib/gis/db/backends/base.py1
-rw-r--r--django/contrib/gis/db/backends/oracle/models.py1
-rw-r--r--django/contrib/gis/db/backends/spatialite/base.py5
-rw-r--r--django/contrib/gis/db/models/__init__.py8
-rw-r--r--django/contrib/gis/db/models/query.py6
-rw-r--r--django/contrib/gis/db/models/sql/aggregates.py1
-rw-r--r--django/contrib/gis/db/models/sql/where.py2
-rw-r--r--django/contrib/gis/feeds.py2
-rw-r--r--django/contrib/gis/gdal/datasource.py2
-rw-r--r--django/contrib/gis/gdal/feature.py1
-rw-r--r--django/contrib/gis/gdal/libgdal.py3
-rw-r--r--django/contrib/gis/gdal/prototypes/ds.py5
-rw-r--r--django/contrib/gis/gdal/prototypes/generation.py6
-rw-r--r--django/contrib/gis/gdal/prototypes/geom.py9
-rw-r--r--django/contrib/gis/gdal/prototypes/srs.py5
-rw-r--r--django/contrib/gis/gdal/srs.py5
-rw-r--r--django/contrib/gis/gdal/tests/test_driver.py2
-rw-r--r--django/contrib/gis/gdal/tests/test_geom.py19
-rw-r--r--django/contrib/gis/geometry/backend/geos.py5
-rw-r--r--django/contrib/gis/geos/base.py2
-rw-r--r--django/contrib/gis/geos/collections.py4
-rw-r--r--django/contrib/gis/geos/geometry.py3
-rw-r--r--django/contrib/gis/geos/libgeos.py4
-rw-r--r--django/contrib/gis/geos/polygon.py1
-rw-r--r--django/contrib/gis/geos/prototypes/__init__.py26
-rw-r--r--django/contrib/gis/geos/prototypes/geom.py8
-rw-r--r--django/contrib/gis/geos/prototypes/topology.py2
-rw-r--r--django/contrib/gis/geos/tests/test_geos.py4
-rw-r--r--django/contrib/gis/geos/tests/test_geos_mutation.py1
-rw-r--r--django/contrib/gis/geos/tests/test_io.py3
-rw-r--r--django/contrib/gis/management/commands/inspectdb.py3
-rw-r--r--django/contrib/gis/management/commands/ogrinspect.py2
-rw-r--r--django/contrib/gis/maps/google/gmap.py9
-rw-r--r--django/contrib/gis/maps/google/zoom.py2
-rw-r--r--django/contrib/gis/shortcuts.py9
-rw-r--r--django/contrib/gis/tests/distapp/tests.py9
-rw-r--r--django/contrib/gis/tests/geo3d/tests.py6
-rw-r--r--django/contrib/gis/tests/geoapp/feeds.py3
-rw-r--r--django/contrib/gis/tests/geoapp/test_regress.py4
-rw-r--r--django/contrib/gis/tests/geoapp/test_sitemaps.py7
-rw-r--r--django/contrib/gis/tests/geoapp/tests.py11
-rw-r--r--django/contrib/gis/tests/geogapp/tests.py1
-rw-r--r--django/contrib/gis/tests/layermap/tests.py8
-rw-r--r--django/contrib/gis/tests/test_geoip.py3
-rw-r--r--django/contrib/gis/tests/test_spatialrefsys.py2
-rw-r--r--django/contrib/gis/utils/geoip.py3
-rw-r--r--django/contrib/gis/utils/layermapping.py9
-rw-r--r--django/contrib/gis/utils/ogrinspect.py2
-rw-r--r--django/contrib/localflavor/ar/forms.py1
-rw-r--r--django/contrib/localflavor/au/models.py1
-rw-r--r--django/contrib/localflavor/be/forms.py4
-rw-r--r--django/contrib/localflavor/jp/forms.py1
-rw-r--r--django/contrib/localflavor/kw/forms.py2
-rw-r--r--django/contrib/localflavor/no/forms.py3
-rw-r--r--django/contrib/localflavor/pt/forms.py4
-rw-r--r--django/contrib/localflavor/ro/forms.py3
-rw-r--r--django/contrib/localflavor/ru/forms.py4
-rw-r--r--django/contrib/localflavor/se/utils.py1
-rw-r--r--django/contrib/localflavor/us/models.py1
-rw-r--r--django/contrib/localflavor/uy/forms.py2
-rw-r--r--django/contrib/messages/api.py1
-rw-r--r--django/contrib/messages/storage/cookie.py1
-rw-r--r--django/contrib/messages/tests/base.py2
-rw-r--r--django/contrib/messages/tests/cookie.py4
-rw-r--r--django/contrib/messages/tests/fallback.py12
-rw-r--r--django/contrib/messages/tests/urls.py1
-rw-r--r--django/contrib/sessions/backends/base.py1
-rw-r--r--django/contrib/sessions/backends/db.py1
-rw-r--r--django/contrib/sessions/models.py3
-rw-r--r--django/contrib/sitemaps/__init__.py2
-rw-r--r--django/contrib/sitemaps/views.py3
-rw-r--r--django/core/cache/backends/base.py1
-rw-r--r--django/core/cache/backends/db.py11
-rw-r--r--django/core/cache/backends/memcached.py1
-rw-r--r--django/core/handlers/modpython.py3
-rw-r--r--django/core/handlers/profiler-hotshot.py5
-rw-r--r--django/core/handlers/wsgi.py2
-rw-r--r--django/core/mail/__init__.py10
-rw-r--r--django/core/management/commands/reset.py1
-rw-r--r--django/core/serializers/base.py3
-rw-r--r--django/core/servers/basehttp.py1
-rw-r--r--django/core/servers/fastcgi.py3
-rw-r--r--django/db/__init__.py4
-rw-r--r--django/db/backends/__init__.py1
-rw-r--r--django/db/backends/oracle/base.py8
-rw-r--r--django/db/backends/oracle/creation.py3
-rw-r--r--django/db/backends/postgresql_psycopg2/base.py1
-rw-r--r--django/db/backends/postgresql_psycopg2/operations.py2
-rw-r--r--django/db/backends/sqlite3/base.py3
-rw-r--r--django/db/models/base.py13
-rw-r--r--django/db/models/deletion.py1
-rw-r--r--django/db/models/fields/__init__.py2
-rw-r--r--django/db/models/fields/files.py17
-rw-r--r--django/db/models/fields/related.py6
-rw-r--r--django/db/models/loading.py1
-rw-r--r--django/db/models/manager.py1
-rw-r--r--django/db/models/query.py3
-rw-r--r--django/db/models/query_utils.py1
-rw-r--r--django/db/models/sql/compiler.py4
-rw-r--r--django/db/models/sql/subqueries.py2
-rw-r--r--django/db/models/sql/where.py1
-rw-r--r--django/db/transaction.py2
-rw-r--r--django/dispatch/saferef.py3
-rw-r--r--django/forms/extras/widgets.py1
-rw-r--r--django/forms/models.py6
-rw-r--r--django/middleware/http.py1
-rw-r--r--django/template/base.py2
-rw-r--r--django/template/context.py1
-rw-r--r--django/template/debug.py1
-rw-r--r--django/template/defaulttags.py10
-rw-r--r--django/template/loader_tags.py6
-rw-r--r--django/template/loaders/cached.py2
-rw-r--r--django/template/smartif.py1
-rw-r--r--django/templatetags/cache.py1
-rw-r--r--django/templatetags/future.py7
-rw-r--r--django/templatetags/l10n.py1
-rw-r--r--django/test/client.py4
-rw-r--r--django/test/testcases.py2
-rw-r--r--django/test/utils.py4
-rw-r--r--django/utils/cache.py1
-rw-r--r--django/utils/log.py1
-rw-r--r--django/utils/text.py15
-rw-r--r--django/utils/timesince.py1
-rw-r--r--django/utils/translation/trans_null.py1
-rw-r--r--django/utils/translation/trans_real.py7
-rw-r--r--django/utils/version.py1
-rw-r--r--django/views/debug.py1
-rw-r--r--django/views/decorators/http.py1
-rw-r--r--django/views/generic/base.py1
-rw-r--r--django/views/generic/detail.py2
-rw-r--r--django/views/generic/list.py2
-rw-r--r--tests/modeltests/basic/models.py2
-rw-r--r--tests/modeltests/basic/tests.py1
-rw-r--r--tests/modeltests/custom_pk/models.py3
-rw-r--r--tests/modeltests/custom_pk/tests.py3
-rw-r--r--tests/modeltests/delete/models.py2
-rw-r--r--tests/modeltests/field_subclassing/fields.py1
-rw-r--r--tests/modeltests/field_subclassing/models.py2
-rw-r--r--tests/modeltests/files/models.py1
-rw-r--r--tests/modeltests/files/tests.py1
-rw-r--r--tests/modeltests/fixtures/models.py3
-rw-r--r--tests/modeltests/fixtures/tests.py5
-rw-r--r--tests/modeltests/fixtures_model_package/models/__init__.py1
-rw-r--r--tests/modeltests/force_insert_update/models.py2
-rw-r--r--tests/modeltests/get_object_or_404/models.py2
-rw-r--r--tests/modeltests/get_or_create/models.py2
-rw-r--r--tests/modeltests/lookup/models.py3
-rw-r--r--tests/modeltests/lookup/tests.py1
-rw-r--r--tests/modeltests/m2m_through/tests.py4
-rw-r--r--tests/modeltests/many_to_one/tests.py2
-rw-r--r--tests/modeltests/model_forms/models.py1
-rw-r--r--tests/modeltests/model_formsets/tests.py2
-rw-r--r--tests/modeltests/mutually_referential/tests.py2
-rw-r--r--tests/modeltests/one_to_one/models.py2
-rw-r--r--tests/modeltests/pagination/tests.py1
-rw-r--r--tests/modeltests/proxy_model_inheritance/tests.py2
-rw-r--r--tests/modeltests/proxy_models/models.py3
-rw-r--r--tests/modeltests/serializers/tests.py4
-rw-r--r--tests/modeltests/transactions/models.py2
-rw-r--r--tests/modeltests/transactions/tests.py5
-rw-r--r--tests/modeltests/unmanaged_models/tests.py3
-rw-r--r--tests/modeltests/validation/models.py1
-rw-r--r--tests/modeltests/validation/test_unique.py2
-rw-r--r--tests/modeltests/validation/validators.py2
-rw-r--r--tests/regressiontests/admin_filters/tests.py2
-rw-r--r--tests/regressiontests/admin_validation/tests.py7
-rw-r--r--tests/regressiontests/bash_completion/management/commands/test_command.py3
-rw-r--r--tests/regressiontests/cache/tests.py1
-rw-r--r--tests/regressiontests/comment_tests/models.py2
-rw-r--r--tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py10
-rw-r--r--tests/regressiontests/comment_tests/tests/feed_tests.py4
-rw-r--r--tests/regressiontests/comment_tests/tests/templatetag_tests.py1
-rw-r--r--tests/regressiontests/csrf_tests/tests.py1
-rw-r--r--tests/regressiontests/datatypes/tests.py2
-rw-r--r--tests/regressiontests/defer_regress/models.py4
-rw-r--r--tests/regressiontests/defer_regress/tests.py2
-rw-r--r--tests/regressiontests/delete_regress/tests.py4
-rw-r--r--tests/regressiontests/expressions_regress/tests.py3
-rw-r--r--tests/regressiontests/extra_regress/tests.py3
-rw-r--r--tests/regressiontests/file_storage/tests.py2
-rw-r--r--tests/regressiontests/file_uploads/tests.py2
-rw-r--r--tests/regressiontests/fixtures_regress/models.py3
-rw-r--r--tests/regressiontests/fixtures_regress/tests.py5
-rw-r--r--tests/regressiontests/forms/localflavor/cl.py1
-rw-r--r--tests/regressiontests/forms/localflavor/in_.py2
-rw-r--r--tests/regressiontests/forms/tests/fields.py1
-rw-r--r--tests/regressiontests/forms/tests/forms.py3
-rw-r--r--tests/regressiontests/forms/tests/media.py1
-rw-r--r--tests/regressiontests/forms/tests/models.py3
-rw-r--r--tests/regressiontests/forms/tests/widgets.py3
-rw-r--r--tests/regressiontests/generic_relations_regress/tests.py1
-rw-r--r--tests/regressiontests/generic_views/base.py1
-rw-r--r--tests/regressiontests/generic_views/dates.py1
-rw-r--r--tests/regressiontests/generic_views/list.py1
-rw-r--r--tests/regressiontests/i18n/forms.py3
-rw-r--r--tests/regressiontests/i18n/patterns/urls/namespace.py2
-rw-r--r--tests/regressiontests/i18n/patterns/urls/wrong.py2
-rw-r--r--tests/regressiontests/i18n/patterns/urls/wrong_namespace.py2
-rw-r--r--tests/regressiontests/introspection/tests.py3
-rw-r--r--tests/regressiontests/localflavor/tests.py4
-rw-r--r--tests/regressiontests/m2m_through_regress/models.py4
-rw-r--r--tests/regressiontests/max_lengths/tests.py2
-rw-r--r--tests/regressiontests/middleware_exceptions/models.py1
-rw-r--r--tests/regressiontests/model_fields/imagefield.py5
-rw-r--r--tests/regressiontests/model_fields/tests.py12
-rw-r--r--tests/regressiontests/model_forms_regress/tests.py4
-rw-r--r--tests/regressiontests/modeladmin/models.py2
-rw-r--r--tests/regressiontests/multiple_database/models.py1
-rw-r--r--tests/regressiontests/select_related_onetoone/tests.py2
-rw-r--r--tests/regressiontests/serializers_regress/tests.py5
-rw-r--r--tests/regressiontests/signals_regress/tests.py2
-rw-r--r--tests/regressiontests/syndication/tests.py2
-rw-r--r--tests/regressiontests/templates/custom.py2
-rw-r--r--tests/regressiontests/templates/loaders.py2
-rw-r--r--tests/regressiontests/templates/response.py2
-rw-r--r--tests/regressiontests/templates/smartif.py2
-rw-r--r--tests/regressiontests/templates/tests.py6
-rw-r--r--tests/regressiontests/test_utils/tests.py4
-rw-r--r--tests/regressiontests/urlpatterns_reverse/middleware.py2
-rw-r--r--tests/regressiontests/urlpatterns_reverse/tests.py5
-rw-r--r--tests/regressiontests/utils/jslex.py1
-rw-r--r--tests/regressiontests/views/tests/debug.py1
-rw-r--r--tests/regressiontests/views/tests/defaults.py3
242 files changed, 307 insertions, 484 deletions
diff --git a/django/bin/profiling/gather_profile_stats.py b/django/bin/profiling/gather_profile_stats.py
index 0fd2b7fca9..2274eadee9 100644
--- a/django/bin/profiling/gather_profile_stats.py
+++ b/django/bin/profiling/gather_profile_stats.py
@@ -8,8 +8,9 @@ hotshot.stats (the formats are incompatible)
"""
from hotshot import stats
+import os
import pstats
-import sys, os
+import sys
def gather_stats(p):
profiles = {}
diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
index 8efd06d497..7a3a9b826a 100644
--- a/django/contrib/admin/templatetags/admin_list.py
+++ b/django/contrib/admin/templatetags/admin_list.py
@@ -1,14 +1,12 @@
import datetime
-from django.conf import settings
from django.contrib.admin.util import lookup_field, display_for_field, label_for_field
from django.contrib.admin.views.main import (ALL_VAR, EMPTY_CHANGELIST_VALUE,
- ORDER_VAR, ORDER_TYPE_VAR, PAGE_VAR, SEARCH_VAR)
+ ORDER_VAR, PAGE_VAR, SEARCH_VAR)
from django.core.exceptions import ObjectDoesNotExist
from django.db import models
from django.templatetags.static import static
from django.utils import formats
-from django.utils.datastructures import SortedDict
from django.utils.html import escape, conditional_escape
from django.utils.safestring import mark_safe
from django.utils.text import capfirst
diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
index bf48f16e20..1f672954e4 100644
--- a/django/contrib/admin/widgets.py
+++ b/django/contrib/admin/widgets.py
@@ -4,7 +4,6 @@ Form Widget classes specific to the Django admin site.
import copy
from django import forms
-from django.conf import settings
from django.core.urlresolvers import reverse, NoReverseMatch
from django.forms.widgets import RadioFieldRenderer
from django.forms.util import flatatt
diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py
index 079f7ab2da..1f57900488 100644
--- a/django/contrib/admindocs/views.py
+++ b/django/contrib/admindocs/views.py
@@ -1,4 +1,8 @@
-from django import template, templatetags
+import inspect
+import os
+import re
+
+from django import template
from django.template import RequestContext
from django.conf import settings
from django.contrib.admin.views.decorators import staff_member_required
@@ -12,7 +16,6 @@ from django.contrib.sites.models import Site
from django.utils.importlib import import_module
from django.utils.translation import ugettext as _
from django.utils.safestring import mark_safe
-import inspect, os, re
# Exclude methods starting with these strings from documentation
MODEL_METHODS_EXCLUDE = ('_', 'add_', 'delete', 'save', 'set_')
diff --git a/django/contrib/auth/__init__.py b/django/contrib/auth/__init__.py
index f11f8308e3..141cac7371 100644
--- a/django/contrib/auth/__init__.py
+++ b/django/contrib/auth/__init__.py
@@ -1,4 +1,3 @@
-import datetime
from warnings import warn
from django.core.exceptions import ImproperlyConfigured
from django.utils.importlib import import_module
diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py
index d8c81406b3..fc751c756d 100644
--- a/django/contrib/auth/backends.py
+++ b/django/contrib/auth/backends.py
@@ -1,4 +1,3 @@
-from django.db import connection
from django.contrib.auth.models import User, Permission
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index 763983c978..9602d55736 100644
--- a/django/contrib/auth/forms.py
+++ b/django/contrib/auth/forms.py
@@ -1,10 +1,11 @@
from django import forms
-from django.template import Context, loader
+from django.template import loader
from django.utils.http import int_to_base36
from django.utils.itercompat import any
from django.utils.translation import ugettext_lazy as _
-from django.contrib.auth.models import User, UNUSABLE_PASSWORD
+from django.contrib.auth.models import User
+from django.contrib.auth.utils import UNUSABLE_PASSWORD
from django.contrib.auth import authenticate
from django.contrib.auth.tokens import default_token_generator
from django.contrib.sites.models import get_current_site
diff --git a/django/contrib/auth/management/__init__.py b/django/contrib/auth/management/__init__.py
index 9966849ca9..f82060e81c 100644
--- a/django/contrib/auth/management/__init__.py
+++ b/django/contrib/auth/management/__init__.py
@@ -102,8 +102,8 @@ def get_default_username(check_db=True):
:returns: The username, or an empty string if no username can be
determined.
"""
- from django.contrib.auth.management.commands.createsuperuser import \
- RE_VALID_USERNAME
+ from django.contrib.auth.management.commands.createsuperuser import (
+ RE_VALID_USERNAME)
default_username = get_system_username()
try:
default_username = unicodedata.normalize('NFKD', default_username)\
diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
index 4656946a9a..5ae4817adf 100644
--- a/django/contrib/auth/models.py
+++ b/django/contrib/auth/models.py
@@ -10,9 +10,10 @@ from django.utils.translation import ugettext_lazy as _
from django.contrib import auth
from django.contrib.auth.signals import user_logged_in
+# UNUSABLE_PASSWORD is still imported here for backwards compatibility
from django.contrib.auth.utils import (get_hexdigest, make_password,
- check_password, is_password_usable,
- get_random_string, UNUSABLE_PASSWORD)
+ check_password, is_password_usable, get_random_string,
+ UNUSABLE_PASSWORD)
from django.contrib.contenttypes.models import ContentType
def update_last_login(sender, user, **kwargs):
diff --git a/django/contrib/auth/tests/auth_backends.py b/django/contrib/auth/tests/auth_backends.py
index 63b65ad521..5163943716 100644
--- a/django/contrib/auth/tests/auth_backends.py
+++ b/django/contrib/auth/tests/auth_backends.py
@@ -1,5 +1,3 @@
-import warnings
-
from django.conf import settings
from django.contrib.auth.models import User, Group, Permission, AnonymousUser
from django.contrib.contenttypes.models import ContentType
diff --git a/django/contrib/auth/tests/forms.py b/django/contrib/auth/tests/forms.py
index 489164abdb..9b557d18bf 100644
--- a/django/contrib/auth/tests/forms.py
+++ b/django/contrib/auth/tests/forms.py
@@ -1,6 +1,5 @@
from __future__ import with_statement
import os
-from django.conf import settings
from django.core import mail
from django.contrib.auth.models import User
from django.contrib.auth.forms import UserCreationForm, AuthenticationForm, PasswordChangeForm, SetPasswordForm, UserChangeForm, PasswordResetForm
diff --git a/django/contrib/auth/tests/tokens.py b/django/contrib/auth/tests/tokens.py
index 9211e062f1..f7fc32e223 100644
--- a/django/contrib/auth/tests/tokens.py
+++ b/django/contrib/auth/tests/tokens.py
@@ -1,7 +1,7 @@
from datetime import date, timedelta
from django.conf import settings
-from django.contrib.auth.models import User, AnonymousUser
+from django.contrib.auth.models import User
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.test import TestCase
diff --git a/django/contrib/formtools/preview.py b/django/contrib/formtools/preview.py
index b4cdeba4de..d2e6987fa0 100644
--- a/django/contrib/formtools/preview.py
+++ b/django/contrib/formtools/preview.py
@@ -2,12 +2,6 @@
Formtools Preview application.
"""
-try:
- import cPickle as pickle
-except ImportError:
- import pickle
-
-from django.conf import settings
from django.http import Http404
from django.shortcuts import render_to_response
from django.template.context import RequestContext
diff --git a/django/contrib/formtools/utils.py b/django/contrib/formtools/utils.py
index 448950649d..3c0f7dba7f 100644
--- a/django/contrib/formtools/utils.py
+++ b/django/contrib/formtools/utils.py
@@ -5,7 +5,6 @@ except ImportError:
import hashlib
from django.conf import settings
-from django.forms import BooleanField
from django.utils.crypto import salted_hmac
diff --git a/django/contrib/formtools/wizard/storage/session.py b/django/contrib/formtools/wizard/storage/session.py
index 84a3848ab7..9cfae50ca0 100644
--- a/django/contrib/formtools/wizard/storage/session.py
+++ b/django/contrib/formtools/wizard/storage/session.py
@@ -1,4 +1,3 @@
-from django.core.files.uploadedfile import UploadedFile
from django.contrib.formtools.wizard import storage
diff --git a/django/contrib/formtools/wizard/tests/namedwizardtests/tests.py b/django/contrib/formtools/wizard/tests/namedwizardtests/tests.py
index 19ac7d6d7b..b3fb290698 100644
--- a/django/contrib/formtools/wizard/tests/namedwizardtests/tests.py
+++ b/django/contrib/formtools/wizard/tests/namedwizardtests/tests.py
@@ -1,9 +1,6 @@
-import os
-
from django.core.urlresolvers import reverse
from django.http import QueryDict
from django.test import TestCase
-from django.conf import settings
from django.contrib.auth.models import User
diff --git a/django/contrib/formtools/wizard/views.py b/django/contrib/formtools/wizard/views.py
index 2dab77d0fe..61ba60ef09 100644
--- a/django/contrib/formtools/wizard/views.py
+++ b/django/contrib/formtools/wizard/views.py
@@ -1,4 +1,3 @@
-import copy
import re
from django import forms
diff --git a/django/contrib/gis/admin/options.py b/django/contrib/gis/admin/options.py
index 8e1faf2374..1014cb31f5 100644
--- a/django/contrib/gis/admin/options.py
+++ b/django/contrib/gis/admin/options.py
@@ -1,4 +1,3 @@
-from django.conf import settings
from django.contrib.admin import ModelAdmin
from django.contrib.gis.admin.widgets import OpenLayersWidget
from django.contrib.gis.gdal import OGRGeomType
diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py
index 49de09511d..6dbbc60d20 100644
--- a/django/contrib/gis/admin/widgets.py
+++ b/django/contrib/gis/admin/widgets.py
@@ -1,4 +1,3 @@
-from django.conf import settings
from django.forms.widgets import Textarea
from django.template import loader, Context
from django.templatetags.static import static
diff --git a/django/contrib/gis/db/backends/base.py b/django/contrib/gis/db/backends/base.py
index 0eaacae63f..2a62d97abf 100644
--- a/django/contrib/gis/db/backends/base.py
+++ b/django/contrib/gis/db/backends/base.py
@@ -3,7 +3,6 @@ Base/mixin classes for the spatial backend database operations and the
`SpatialRefSys` model the backend.
"""
import re
-from django.conf import settings
from django.contrib.gis import gdal
class BaseSpatialOperations(object):
diff --git a/django/contrib/gis/db/backends/oracle/models.py b/django/contrib/gis/db/backends/oracle/models.py
index de757ffbec..ed29f7bb38 100644
--- a/django/contrib/gis/db/backends/oracle/models.py
+++ b/django/contrib/gis/db/backends/oracle/models.py
@@ -8,7 +8,6 @@
model and the `SDO_COORD_REF_SYS` is used for the SpatialRefSys model.
"""
from django.contrib.gis.db import models
-from django.contrib.gis.db.models.fields import GeometryField
from django.contrib.gis.db.backends.base import SpatialRefSysMixin
class GeometryColumns(models.Model):
diff --git a/django/contrib/gis/db/backends/spatialite/base.py b/django/contrib/gis/db/backends/spatialite/base.py
index 729fc152e7..12561747b3 100644
--- a/django/contrib/gis/db/backends/spatialite/base.py
+++ b/django/contrib/gis/db/backends/spatialite/base.py
@@ -3,8 +3,9 @@ from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.db.backends.sqlite3.base import *
-from django.db.backends.sqlite3.base import DatabaseWrapper as SqliteDatabaseWrapper, \
- _sqlite_extract, _sqlite_date_trunc, _sqlite_regexp
+from django.db.backends.sqlite3.base import (
+ _sqlite_extract, _sqlite_date_trunc, _sqlite_regexp,
+ DatabaseWrapper as SqliteDatabaseWrapper)
from django.contrib.gis.db.backends.spatialite.client import SpatiaLiteClient
from django.contrib.gis.db.backends.spatialite.creation import SpatiaLiteCreation
from django.contrib.gis.db.backends.spatialite.introspection import SpatiaLiteIntrospection
diff --git a/django/contrib/gis/db/models/__init__.py b/django/contrib/gis/db/models/__init__.py
index 87e2b683a1..e36aa36fc2 100644
--- a/django/contrib/gis/db/models/__init__.py
+++ b/django/contrib/gis/db/models/__init__.py
@@ -8,7 +8,7 @@ from django.contrib.gis.db.models.aggregates import *
from django.contrib.gis.db.models.manager import GeoManager
# The geographic-enabled fields.
-from django.contrib.gis.db.models.fields import \
- GeometryField, PointField, LineStringField, PolygonField, \
- MultiPointField, MultiLineStringField, MultiPolygonField, \
- GeometryCollectionField
+from django.contrib.gis.db.models.fields import (
+ GeometryField, PointField, LineStringField, PolygonField,
+ MultiPointField, MultiLineStringField, MultiPolygonField,
+ GeometryCollectionField)
diff --git a/django/contrib/gis/db/models/query.py b/django/contrib/gis/db/models/query.py
index 4df1a3ab78..c1e360de27 100644
--- a/django/contrib/gis/db/models/query.py
+++ b/django/contrib/gis/db/models/query.py
@@ -1,9 +1,9 @@
from django.db import connections
-from django.db.models.query import QuerySet, Q, ValuesQuerySet, ValuesListQuerySet
+from django.db.models.query import QuerySet, ValuesQuerySet, ValuesListQuerySet
from django.contrib.gis.db.models import aggregates
-from django.contrib.gis.db.models.fields import get_srid_info, GeometryField, PointField, LineStringField
-from django.contrib.gis.db.models.sql import AreaField, DistanceField, GeomField, GeoQuery, GeoWhereNode
+from django.contrib.gis.db.models.fields import get_srid_info, PointField, LineStringField
+from django.contrib.gis.db.models.sql import AreaField, DistanceField, GeomField, GeoQuery
from django.contrib.gis.geometry.backend import Geometry
from django.contrib.gis.measure import Area, Distance
diff --git a/django/contrib/gis/db/models/sql/aggregates.py b/django/contrib/gis/db/models/sql/aggregates.py
index fed2a2ea4d..9fcbb516d6 100644
--- a/django/contrib/gis/db/models/sql/aggregates.py
+++ b/django/contrib/gis/db/models/sql/aggregates.py
@@ -1,6 +1,5 @@
from django.db.models.sql.aggregates import *
from django.contrib.gis.db.models.fields import GeometryField
-from django.contrib.gis.db.models.sql.conversion import GeomField
class GeoAggregate(Aggregate):
# Default SQL template for spatial aggregates.
diff --git a/django/contrib/gis/db/models/sql/where.py b/django/contrib/gis/db/models/sql/where.py
index 17c210bafb..0e152221ac 100644
--- a/django/contrib/gis/db/models/sql/where.py
+++ b/django/contrib/gis/db/models/sql/where.py
@@ -1,4 +1,4 @@
-from django.db.models.fields import Field, FieldDoesNotExist
+from django.db.models.fields import FieldDoesNotExist
from django.db.models.sql.constants import LOOKUP_SEP
from django.db.models.sql.expressions import SQLEvaluator
from django.db.models.sql.where import Constraint, WhereNode
diff --git a/django/contrib/gis/feeds.py b/django/contrib/gis/feeds.py
index 4105ef740b..c14fb858a5 100644
--- a/django/contrib/gis/feeds.py
+++ b/django/contrib/gis/feeds.py
@@ -1,4 +1,4 @@
-from django.contrib.syndication.feeds import Feed as BaseFeed, FeedDoesNotExist
+from django.contrib.syndication.views import Feed as BaseFeed
from django.utils.feedgenerator import Atom1Feed, Rss201rev2Feed
class GeoFeedMixin(object):
diff --git a/django/contrib/gis/gdal/datasource.py b/django/contrib/gis/gdal/datasource.py
index 7db5fd9ce3..e5f3602ddb 100644
--- a/django/contrib/gis/gdal/datasource.py
+++ b/django/contrib/gis/gdal/datasource.py
@@ -34,7 +34,7 @@
val = field.value
"""
# ctypes prerequisites.
-from ctypes import byref, c_void_p
+from ctypes import byref
# The GDAL C library, OGR exceptions, and the Layer object.
from django.contrib.gis.gdal.base import GDALBase
diff --git a/django/contrib/gis/gdal/feature.py b/django/contrib/gis/gdal/feature.py
index b5c173a240..47fd9e522e 100644
--- a/django/contrib/gis/gdal/feature.py
+++ b/django/contrib/gis/gdal/feature.py
@@ -3,7 +3,6 @@ from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.error import OGRException, OGRIndexError
from django.contrib.gis.gdal.field import Field
from django.contrib.gis.gdal.geometries import OGRGeometry, OGRGeomType
-from django.contrib.gis.gdal.srs import SpatialReference
# ctypes function prototypes
from django.contrib.gis.gdal.prototypes import ds as capi, geom as geom_api
diff --git a/django/contrib/gis/gdal/libgdal.py b/django/contrib/gis/gdal/libgdal.py
index dda9c64eb1..f991388835 100644
--- a/django/contrib/gis/gdal/libgdal.py
+++ b/django/contrib/gis/gdal/libgdal.py
@@ -1,4 +1,5 @@
-import os, re, sys
+import os
+import re
from ctypes import c_char_p, CDLL
from ctypes.util import find_library
from django.contrib.gis.gdal.error import OGRException
diff --git a/django/contrib/gis/gdal/prototypes/ds.py b/django/contrib/gis/gdal/prototypes/ds.py
index 44828ee5f9..d8537bcaa4 100644
--- a/django/contrib/gis/gdal/prototypes/ds.py
+++ b/django/contrib/gis/gdal/prototypes/ds.py
@@ -6,9 +6,8 @@
from ctypes import c_char_p, c_double, c_int, c_long, c_void_p, POINTER
from django.contrib.gis.gdal.envelope import OGREnvelope
from django.contrib.gis.gdal.libgdal import lgdal
-from django.contrib.gis.gdal.prototypes.generation import \
- const_string_output, double_output, geom_output, int_output, \
- srs_output, void_output, voidptr_output
+from django.contrib.gis.gdal.prototypes.generation import (const_string_output,
+ double_output, geom_output, int_output, srs_output, void_output, voidptr_output)
c_int_p = POINTER(c_int) # shortcut type
diff --git a/django/contrib/gis/gdal/prototypes/generation.py b/django/contrib/gis/gdal/prototypes/generation.py
index 1303532372..45cffd645a 100644
--- a/django/contrib/gis/gdal/prototypes/generation.py
+++ b/django/contrib/gis/gdal/prototypes/generation.py
@@ -4,9 +4,9 @@
"""
from ctypes import c_char_p, c_double, c_int, c_void_p
-from django.contrib.gis.gdal.prototypes.errcheck import \
- check_arg_errcode, check_errcode, check_geom, check_geom_offset, \
- check_pointer, check_srs, check_str_arg, check_string, check_const_string
+from django.contrib.gis.gdal.prototypes.errcheck import (
+ check_arg_errcode, check_errcode, check_geom, check_geom_offset,
+ check_pointer, check_srs, check_str_arg, check_string, check_const_string)
class gdal_char_p(c_char_p):
pass
diff --git a/django/contrib/gis/gdal/prototypes/geom.py b/django/contrib/gis/gdal/prototypes/geom.py
index e002590e31..7fa83910c7 100644
--- a/django/contrib/gis/gdal/prototypes/geom.py
+++ b/django/contrib/gis/gdal/prototypes/geom.py
@@ -1,12 +1,9 @@
-import re
-from datetime import date
-from ctypes import c_char, c_char_p, c_double, c_int, c_ubyte, c_void_p, POINTER
+from ctypes import c_char_p, c_double, c_int, c_void_p, POINTER
from django.contrib.gis.gdal.envelope import OGREnvelope
from django.contrib.gis.gdal.libgdal import lgdal, GEOJSON
from django.contrib.gis.gdal.prototypes.errcheck import check_bool, check_envelope
-from django.contrib.gis.gdal.prototypes.generation import \
- const_string_output, double_output, geom_output, int_output, \
- srs_output, string_output, void_output
+from django.contrib.gis.gdal.prototypes.generation import (const_string_output,
+ double_output, geom_output, int_output, srs_output, string_output, void_output)
### Generation routines specific to this module ###
def env_func(f, argtypes):
diff --git a/django/contrib/gis/gdal/prototypes/srs.py b/django/contrib/gis/gdal/prototypes/srs.py
index 411cec903c..66cf84c34f 100644
--- a/django/contrib/gis/gdal/prototypes/srs.py
+++ b/django/contrib/gis/gdal/prototypes/srs.py
@@ -1,8 +1,7 @@
from ctypes import c_char_p, c_int, c_void_p, POINTER
from django.contrib.gis.gdal.libgdal import lgdal, std_call
-from django.contrib.gis.gdal.prototypes.generation import \
- const_string_output, double_output, int_output, \
- srs_output, string_output, void_output
+from django.contrib.gis.gdal.prototypes.generation import (const_string_output,
+ double_output, int_output, srs_output, string_output, void_output)
## Shortcut generation for routines with known parameters.
def srs_double(f):
diff --git a/django/contrib/gis/gdal/srs.py b/django/contrib/gis/gdal/srs.py
index 95e71f1e31..e211bace91 100644
--- a/django/contrib/gis/gdal/srs.py
+++ b/django/contrib/gis/gdal/srs.py
@@ -26,12 +26,11 @@
>>> print srs.name
NAD83 / Texas South Central
"""
-import re
-from ctypes import byref, c_char_p, c_int, c_void_p
+from ctypes import byref, c_char_p, c_int
# Getting the error checking routine and exceptions
from django.contrib.gis.gdal.base import GDALBase
-from django.contrib.gis.gdal.error import OGRException, SRSException
+from django.contrib.gis.gdal.error import SRSException
from django.contrib.gis.gdal.prototypes import srs as capi
#### Spatial Reference class. ####
diff --git a/django/contrib/gis/gdal/tests/test_driver.py b/django/contrib/gis/gdal/tests/test_driver.py
index 1ff65ac31b..06ec93f936 100644
--- a/django/contrib/gis/gdal/tests/test_driver.py
+++ b/django/contrib/gis/gdal/tests/test_driver.py
@@ -1,4 +1,4 @@
-import os, os.path, unittest
+import unittest
from django.contrib.gis.gdal import Driver, OGRException
valid_drivers = ('ESRI Shapefile', 'MapInfo File', 'TIGER', 'S57', 'DGN',
diff --git a/django/contrib/gis/gdal/tests/test_geom.py b/django/contrib/gis/gdal/tests/test_geom.py
index 7d4a1ffcee..656901b55e 100644
--- a/django/contrib/gis/gdal/tests/test_geom.py
+++ b/django/contrib/gis/gdal/tests/test_geom.py
@@ -1,8 +1,14 @@
-from django.contrib.gis.gdal import OGRGeometry, OGRGeomType, \
- OGRException, OGRIndexError, SpatialReference, CoordTransform, \
- GDAL_VERSION
-from django.utils import unittest
+from binascii import b2a_hex
+try:
+ import cPickle as pickle
+except ImportError:
+ import pickle
+
+from django.contrib.gis.gdal import (OGRGeometry, OGRGeomType, OGRException,
+ OGRIndexError, SpatialReference, CoordTransform, GDAL_VERSION)
+from django.contrib.gis.gdal.prototypes.geom import GEOJSON
from django.contrib.gis.geometry.test_data import TestDataMixin
+from django.utils import unittest
class OGRGeomTest(unittest.TestCase, TestDataMixin):
"This tests the OGR Geometry."
@@ -92,7 +98,6 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
def test01d_wkb(self):
"Testing WKB input/output."
- from binascii import b2a_hex
for g in self.geometries.hex_wkt:
geom1 = OGRGeometry(g.wkt)
wkb = geom1.wkb
@@ -103,7 +108,6 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
def test01e_json(self):
"Testing GeoJSON input/output."
- from django.contrib.gis.gdal.prototypes.geom import GEOJSON
if not GEOJSON: return
for g in self.geometries.json_geoms:
geom = OGRGeometry(g.wkt)
@@ -446,9 +450,8 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
def test17_pickle(self):
"Testing pickle support."
- import cPickle
g1 = OGRGeometry('LINESTRING(1 1 1,2 2 2,3 3 3)', 'WGS84')
- g2 = cPickle.loads(cPickle.dumps(g1))
+ g2 = pickle.loads(pickle.dumps(g1))
self.assertEqual(g1, g2)
self.assertEqual(4326, g2.srs.srid)
self.assertEqual(g1.srs.wkt, g2.srs.wkt)
diff --git a/django/contrib/gis/geometry/backend/geos.py b/django/contrib/gis/geometry/backend/geos.py
index a1ac096b63..cdc40ed93f 100644
--- a/django/contrib/gis/geometry/backend/geos.py
+++ b/django/contrib/gis/geometry/backend/geos.py
@@ -1,3 +1,2 @@
-from django.contrib.gis.geos import \
- GEOSGeometry as Geometry, \
- GEOSException as GeometryException
+from django.contrib.gis.geos import (
+ GEOSGeometry as Geometry, GEOSException as GeometryException)
diff --git a/django/contrib/gis/geos/base.py b/django/contrib/gis/geos/base.py
index 34c03c8d66..b3012dd930 100644
--- a/django/contrib/gis/geos/base.py
+++ b/django/contrib/gis/geos/base.py
@@ -1,6 +1,6 @@
from ctypes import c_void_p
from types import NoneType
-from django.contrib.gis.geos.error import GEOSException, GEOSIndexError
+from django.contrib.gis.geos.error import GEOSException
# Trying to import GDAL libraries, if available. Have to place in
# try/except since this package may be used outside GeoDjango.
diff --git a/django/contrib/gis/geos/collections.py b/django/contrib/gis/geos/collections.py
index 515f80e3eb..8b0edf5985 100644
--- a/django/contrib/gis/geos/collections.py
+++ b/django/contrib/gis/geos/collections.py
@@ -3,9 +3,9 @@
GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
"""
from ctypes import c_int, c_uint, byref
-from django.contrib.gis.geos.error import GEOSException, GEOSIndexError
+from django.contrib.gis.geos.error import GEOSException
from django.contrib.gis.geos.geometry import GEOSGeometry
-from django.contrib.gis.geos.libgeos import get_pointer_arr, GEOM_PTR, GEOS_PREPARE
+from django.contrib.gis.geos.libgeos import get_pointer_arr, GEOS_PREPARE
from django.contrib.gis.geos.linestring import LineString, LinearRing
from django.contrib.gis.geos.point import Point
from django.contrib.gis.geos.polygon import Polygon
diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py
index a9d126481a..c56eeb345b 100644
--- a/django/contrib/gis/geos/geometry.py
+++ b/django/contrib/gis/geos/geometry.py
@@ -3,9 +3,8 @@
inherit from this object.
"""
# Python, ctypes and types dependencies.
-import re
import warnings
-from ctypes import addressof, byref, c_double, c_size_t
+from ctypes import addressof, byref, c_double
# super-class for mutable list behavior
from django.contrib.gis.geos.mutable_list import ListMixin
diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py
index 7e1dfa0dc5..e73fcdb4d9 100644
--- a/django/contrib/gis/geos/libgeos.py
+++ b/django/contrib/gis/geos/libgeos.py
@@ -6,7 +6,9 @@
This module also houses GEOS Pointer utilities, including
get_pointer_arr(), and GEOM_PTR.
"""
-import os, re, sys
+import os
+import re
+import sys
from ctypes import c_char_p, Structure, CDLL, CFUNCTYPE, POINTER
from ctypes.util import find_library
from django.contrib.gis.geos.error import GEOSException
diff --git a/django/contrib/gis/geos/polygon.py b/django/contrib/gis/geos/polygon.py
index 92b2e4ce71..77ce60cf16 100644
--- a/django/contrib/gis/geos/polygon.py
+++ b/django/contrib/gis/geos/polygon.py
@@ -1,5 +1,4 @@
from ctypes import c_uint, byref
-from django.contrib.gis.geos.error import GEOSIndexError
from django.contrib.gis.geos.geometry import GEOSGeometry
from django.contrib.gis.geos.libgeos import get_pointer_arr, GEOM_PTR
from django.contrib.gis.geos.linestring import LinearRing
diff --git a/django/contrib/gis/geos/prototypes/__init__.py b/django/contrib/gis/geos/prototypes/__init__.py
index 23735f5e9b..89b96c0ecf 100644
--- a/django/contrib/gis/geos/prototypes/__init__.py
+++ b/django/contrib/gis/geos/prototypes/__init__.py
@@ -5,26 +5,26 @@
"""
# Coordinate sequence routines.
-from django.contrib.gis.geos.prototypes.coordseq import create_cs, get_cs, \
- cs_clone, cs_getordinate, cs_setordinate, cs_getx, cs_gety, cs_getz, \
- cs_setx, cs_sety, cs_setz, cs_getsize, cs_getdims
+from django.contrib.gis.geos.prototypes.coordseq import (create_cs, get_cs,
+ cs_clone, cs_getordinate, cs_setordinate, cs_getx, cs_gety, cs_getz,
+ cs_setx, cs_sety, cs_setz, cs_getsize, cs_getdims)
# Geometry routines.
-from django.contrib.gis.geos.prototypes.geom import from_hex, from_wkb, from_wkt, \
- create_point, create_linestring, create_linearring, create_polygon, create_collection, \
- destroy_geom, get_extring, get_intring, get_nrings, get_geomn, geom_clone, \
- geos_normalize, geos_type, geos_typeid, geos_get_srid, geos_set_srid, \
- get_dims, get_num_coords, get_num_geoms, \
- to_hex, to_wkb, to_wkt
+from django.contrib.gis.geos.prototypes.geom import (from_hex, from_wkb, from_wkt,
+ create_point, create_linestring, create_linearring, create_polygon, create_collection,
+ destroy_geom, get_extring, get_intring, get_nrings, get_geomn, geom_clone,
+ geos_normalize, geos_type, geos_typeid, geos_get_srid, geos_set_srid,
+ get_dims, get_num_coords, get_num_geoms,
+ to_hex, to_wkb, to_wkt)
# Miscellaneous routines.
from django.contrib.gis.geos.prototypes.misc import *
# Predicates
-from django.contrib.gis.geos.prototypes.predicates import geos_hasz, geos_isempty, \
- geos_isring, geos_issimple, geos_isvalid, geos_contains, geos_crosses, \
- geos_disjoint, geos_equals, geos_equalsexact, geos_intersects, \
- geos_intersects, geos_overlaps, geos_relatepattern, geos_touches, geos_within
+from django.contrib.gis.geos.prototypes.predicates import (geos_hasz, geos_isempty,
+ geos_isring, geos_issimple, geos_isvalid, geos_contains, geos_crosses,
+ geos_disjoint, geos_equals, geos_equalsexact, geos_intersects,
+ geos_intersects, geos_overlaps, geos_relatepattern, geos_touches, geos_within)
# Topology routines
from django.contrib.gis.geos.prototypes.topology import *
diff --git a/django/contrib/gis/geos/prototypes/geom.py b/django/contrib/gis/geos/prototypes/geom.py
index 03f98978e3..5a614fe5f0 100644
--- a/django/contrib/gis/geos/prototypes/geom.py
+++ b/django/contrib/gis/geos/prototypes/geom.py
@@ -1,7 +1,7 @@
-from ctypes import c_char_p, c_int, c_size_t, c_ubyte, c_uint, POINTER
-from django.contrib.gis.geos.libgeos import CS_PTR, GEOM_PTR, PREPGEOM_PTR, GEOS_PREPARE
-from django.contrib.gis.geos.prototypes.errcheck import \
- check_geom, check_minus_one, check_sized_string, check_string, check_zero
+from ctypes import c_char_p, c_int, c_size_t, c_ubyte, POINTER
+from django.contrib.gis.geos.libgeos import CS_PTR, GEOM_PTR
+from django.contrib.gis.geos.prototypes.errcheck import (
+ check_geom, check_minus_one, check_sized_string, check_string, check_zero)
from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
# This is the return type used by binary output (WKB, HEX) routines.
diff --git a/django/contrib/gis/geos/prototypes/topology.py b/django/contrib/gis/geos/prototypes/topology.py
index 50817f9e38..cc5734b5e4 100644
--- a/django/contrib/gis/geos/prototypes/topology.py
+++ b/django/contrib/gis/geos/prototypes/topology.py
@@ -7,7 +7,7 @@ __all__ = ['geos_boundary', 'geos_buffer', 'geos_centroid', 'geos_convexhull',
'geos_linemerge', 'geos_pointonsurface', 'geos_preservesimplify',
'geos_simplify', 'geos_symdifference', 'geos_union', 'geos_relate']
-from ctypes import c_char_p, c_double, c_int
+from ctypes import c_double, c_int
from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOS_PREPARE
from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_string
from django.contrib.gis.geos.prototypes.geom import geos_char_p
diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py
index 4620a9fb52..f611dd4d1a 100644
--- a/django/contrib/gis/geos/tests/test_geos.py
+++ b/django/contrib/gis/geos/tests/test_geos.py
@@ -1,4 +1,6 @@
-import ctypes, random, unittest, sys
+import ctypes
+import random
+import unittest
from django.contrib.gis.geos import *
from django.contrib.gis.geos.base import gdal, numpy, GEOSBase
from django.contrib.gis.geos.libgeos import GEOS_PREPARE
diff --git a/django/contrib/gis/geos/tests/test_geos_mutation.py b/django/contrib/gis/geos/tests/test_geos_mutation.py
index c8f7e658ad..0c69b2bf4f 100644
--- a/django/contrib/gis/geos/tests/test_geos_mutation.py
+++ b/django/contrib/gis/geos/tests/test_geos_mutation.py
@@ -2,7 +2,6 @@
# Modified from original contribution by Aryeh Leib Taurog, which was
# released under the New BSD license.
-import copy
from django.contrib.gis.geos import *
from django.contrib.gis.geos.error import GEOSIndexError
from django.utils import unittest
diff --git a/django/contrib/gis/geos/tests/test_io.py b/django/contrib/gis/geos/tests/test_io.py
index cc0f1ed1c0..50c36684a0 100644
--- a/django/contrib/gis/geos/tests/test_io.py
+++ b/django/contrib/gis/geos/tests/test_io.py
@@ -1,4 +1,5 @@
-import binascii, ctypes, unittest
+import binascii
+import unittest
from django.contrib.gis.geos import GEOSGeometry, WKTReader, WKTWriter, WKBReader, WKBWriter, geos_version_info
class GEOSIOTest(unittest.TestCase):
diff --git a/django/contrib/gis/management/commands/inspectdb.py b/django/contrib/gis/management/commands/inspectdb.py
index 937bb8eb33..bbf40e1baa 100644
--- a/django/contrib/gis/management/commands/inspectdb.py
+++ b/django/contrib/gis/management/commands/inspectdb.py
@@ -1,6 +1,3 @@
-from optparse import make_option
-
-from django.core.management.base import CommandError
from django.core.management.commands.inspectdb import Command as InspectDBCommand
class Command(InspectDBCommand):
diff --git a/django/contrib/gis/management/commands/ogrinspect.py b/django/contrib/gis/management/commands/ogrinspect.py
index a4957870ea..13f1c0a8c5 100644
--- a/django/contrib/gis/management/commands/ogrinspect.py
+++ b/django/contrib/gis/management/commands/ogrinspect.py
@@ -1,4 +1,4 @@
-import os, sys
+import os
from optparse import make_option
from django.contrib.gis import gdal
from django.contrib.gis.management.base import ArgsCommand, CommandError
diff --git a/django/contrib/gis/maps/google/gmap.py b/django/contrib/gis/maps/google/gmap.py
index cca5dc941f..f0e8d73399 100644
--- a/django/contrib/gis/maps/google/gmap.py
+++ b/django/contrib/gis/maps/google/gmap.py
@@ -1,15 +1,18 @@
from django.conf import settings
-from django.contrib.gis import geos
from django.template.loader import render_to_string
from django.utils.safestring import mark_safe
-class GoogleMapException(Exception): pass
-from django.contrib.gis.maps.google.overlays import GPolygon, GPolyline, GMarker, GIcon
+from django.contrib.gis.maps.google.overlays import GPolygon, GPolyline, GMarker
+
+class GoogleMapException(Exception):
+ pass
+
# The default Google Maps URL (for the API javascript)
# TODO: Internationalize for Japan, UK, etc.
GOOGLE_MAPS_URL='http://maps.google.com/maps?file=api&amp;v=%s&amp;key='
+
class GoogleMap(object):
"A class for generating Google Maps JavaScript."
diff --git a/django/contrib/gis/maps/google/zoom.py b/django/contrib/gis/maps/google/zoom.py
index abc3fbf9d5..7e7219f132 100644
--- a/django/contrib/gis/maps/google/zoom.py
+++ b/django/contrib/gis/maps/google/zoom.py
@@ -1,6 +1,6 @@
from django.contrib.gis.geos import GEOSGeometry, LinearRing, Polygon, Point
from django.contrib.gis.maps.google.gmap import GoogleMapException
-from math import pi, sin, cos, log, exp, atan
+from math import pi, sin, log, exp, atan
# Constants used for degree to radian conversion, and vice-versa.
DTOR = pi / 180.
diff --git a/django/contrib/gis/shortcuts.py b/django/contrib/gis/shortcuts.py
index a6fb8927d0..9a80f4df29 100644
--- a/django/contrib/gis/shortcuts.py
+++ b/django/contrib/gis/shortcuts.py
@@ -1,11 +1,16 @@
-import cStringIO, zipfile
+try:
+ from cStringIO import StringIO
+except ImportError:
+ from StringIO import StringIO
+import zipfile
+
from django.conf import settings
from django.http import HttpResponse
from django.template import loader
def compress_kml(kml):
"Returns compressed KMZ from the given KML string."
- kmz = cStringIO.StringIO()
+ kmz = StringIO()
zf = zipfile.ZipFile(kmz, 'a', zipfile.ZIP_DEFLATED)
zf.writestr('doc.kml', kml.encode(settings.DEFAULT_CHARSET))
zf.close()
diff --git a/django/contrib/gis/tests/distapp/tests.py b/django/contrib/gis/tests/distapp/tests.py
index 4f81a91d00..4961a02264 100644
--- a/django/contrib/gis/tests/distapp/tests.py
+++ b/django/contrib/gis/tests/distapp/tests.py
@@ -1,15 +1,12 @@
-import os
-from decimal import Decimal
-
from django.db import connection
from django.db.models import Q
-from django.contrib.gis.geos import GEOSGeometry, Point, LineString
+from django.contrib.gis.geos import GEOSGeometry, LineString
from django.contrib.gis.measure import D # alias for Distance
from django.contrib.gis.tests.utils import oracle, postgis, spatialite, no_oracle, no_spatialite
from django.test import TestCase
-from models import AustraliaCity, Interstate, SouthTexasInterstate, \
- SouthTexasCity, SouthTexasCityFt, CensusZipcode, SouthTexasZipcode
+from models import (AustraliaCity, Interstate, SouthTexasInterstate,
+ SouthTexasCity, SouthTexasCityFt, CensusZipcode, SouthTexasZipcode)
class DistanceTest(TestCase):
diff --git a/django/contrib/gis/tests/geo3d/tests.py b/django/contrib/gis/tests/geo3d/tests.py
index 324002e1d7..be059646ef 100644
--- a/django/contrib/gis/tests/geo3d/tests.py
+++ b/django/contrib/gis/tests/geo3d/tests.py
@@ -5,9 +5,9 @@ from django.contrib.gis.db.models import Union, Extent3D
from django.contrib.gis.geos import GEOSGeometry, Point, Polygon
from django.contrib.gis.utils import LayerMapping, LayerMapError
-from models import City3D, Interstate2D, Interstate3D, \
- InterstateProj2D, InterstateProj3D, \
- Point2D, Point3D, MultiPoint3D, Polygon2D, Polygon3D
+from models import (City3D, Interstate2D, Interstate3D,
+ InterstateProj2D, InterstateProj3D,
+ Point2D, Point3D, MultiPoint3D, Polygon2D, Polygon3D)
data_path = os.path.realpath(os.path.join(os.path.dirname(__file__), '..', 'data'))
city_file = os.path.join(data_path, 'cities', 'cities.shp')
diff --git a/django/contrib/gis/tests/geoapp/feeds.py b/django/contrib/gis/tests/geoapp/feeds.py
index 942b1405f9..f2e8f73051 100644
--- a/django/contrib/gis/tests/geoapp/feeds.py
+++ b/django/contrib/gis/tests/geoapp/feeds.py
@@ -1,6 +1,5 @@
from django.contrib.gis import feeds
-from django.contrib.gis.tests.utils import mysql
-from models import City, Country
+from models import City
class TestGeoRSS1(feeds.Feed):
link = '/city/'
diff --git a/django/contrib/gis/tests/geoapp/test_regress.py b/django/contrib/gis/tests/geoapp/test_regress.py
index 029552643e..6b914da019 100644
--- a/django/contrib/gis/tests/geoapp/test_regress.py
+++ b/django/contrib/gis/tests/geoapp/test_regress.py
@@ -1,5 +1,5 @@
-import os, unittest
-from django.contrib.gis.tests.utils import no_mysql, no_oracle, no_postgis, no_spatialite
+import unittest
+from django.contrib.gis.tests.utils import no_mysql, no_spatialite
from django.contrib.gis.shortcuts import render_to_kmz
from models import City
diff --git a/django/contrib/gis/tests/geoapp/test_sitemaps.py b/django/contrib/gis/tests/geoapp/test_sitemaps.py
index 16e04337c6..a6f0c9b1d1 100644
--- a/django/contrib/gis/tests/geoapp/test_sitemaps.py
+++ b/django/contrib/gis/tests/geoapp/test_sitemaps.py
@@ -1,4 +1,7 @@
-import cStringIO
+try:
+ from cStringIO import StringIO
+except ImportError:
+ from StringIO import StringIO
from xml.dom import minidom
import zipfile
from django.conf import settings
@@ -60,7 +63,7 @@ class GeoSitemapTest(TestCase):
kml_doc = minidom.parseString(self.client.get(kml_url).content)
elif kml_type == 'kmz':
# Have to decompress KMZ before parsing.
- buf = cStringIO.StringIO(self.client.get(kml_url).content)
+ buf = StringIO(self.client.get(kml_url).content)
zf = zipfile.ZipFile(buf)
self.assertEqual(1, len(zf.filelist))
self.assertEqual('doc.kml', zf.filelist[0].filename)
diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py
index 296f128834..2960aee55b 100644
--- a/django/contrib/gis/tests/geoapp/tests.py
+++ b/django/contrib/gis/tests/geoapp/tests.py
@@ -1,12 +1,11 @@
import re
from django.db import connection
from django.contrib.gis import gdal
-from django.contrib.gis.geos import fromstr, GEOSGeometry, \
- Point, LineString, LinearRing, Polygon, GeometryCollection
-from django.contrib.gis.measure import Distance
-from django.contrib.gis.tests.utils import \
- no_mysql, no_oracle, no_spatialite, \
- mysql, oracle, postgis, spatialite
+from django.contrib.gis.geos import (fromstr, GEOSGeometry,
+ Point, LineString, LinearRing, Polygon, GeometryCollection)
+from django.contrib.gis.tests.utils import (
+ no_mysql, no_oracle, no_spatialite,
+ mysql, oracle, postgis, spatialite)
from django.test import TestCase
from models import Country, City, PennsylvaniaCity, State, Track
diff --git a/django/contrib/gis/tests/geogapp/tests.py b/django/contrib/gis/tests/geogapp/tests.py
index cb69ce94e1..b3a86cd21f 100644
--- a/django/contrib/gis/tests/geogapp/tests.py
+++ b/django/contrib/gis/tests/geogapp/tests.py
@@ -79,7 +79,6 @@ class GeographyTest(TestCase):
def test06_geography_area(self):
"Testing that Area calculations work on geography columns."
- from django.contrib.gis.measure import A
# SELECT ST_Area(poly) FROM geogapp_zipcode WHERE code='77002';
ref_area = 5439084.70637573
tol = 5
diff --git a/django/contrib/gis/tests/layermap/tests.py b/django/contrib/gis/tests/layermap/tests.py
index 22148409f6..0480e43dc8 100644
--- a/django/contrib/gis/tests/layermap/tests.py
+++ b/django/contrib/gis/tests/layermap/tests.py
@@ -4,13 +4,13 @@ from decimal import Decimal
from django.utils.unittest import TestCase
-from django.contrib.gis.gdal import DataSource, OGRException
+from django.contrib.gis.gdal import DataSource
from django.contrib.gis.tests.utils import mysql
from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError, InvalidDecimal, MissingForeignKey
-from models import \
- City, County, CountyFeat, Interstate, ICity1, ICity2, Invalid, State, \
- city_mapping, co_mapping, cofeat_mapping, inter_mapping
+from models import (
+ City, County, CountyFeat, Interstate, ICity1, ICity2, Invalid, State,
+ city_mapping, co_mapping, cofeat_mapping, inter_mapping)
shp_path = os.path.realpath(os.path.join(os.path.dirname(__file__), os.pardir, 'data'))
city_shp = os.path.join(shp_path, 'cities', 'cities.shp')
diff --git a/django/contrib/gis/tests/test_geoip.py b/django/contrib/gis/tests/test_geoip.py
index a9ab6a6ab4..c0924377b9 100644
--- a/django/contrib/gis/tests/test_geoip.py
+++ b/django/contrib/gis/tests/test_geoip.py
@@ -1,4 +1,5 @@
-import os, unittest
+import os
+import unittest
from django.db import settings
from django.contrib.gis.geos import GEOSGeometry
from django.contrib.gis.utils import GeoIP, GeoIPException
diff --git a/django/contrib/gis/tests/test_spatialrefsys.py b/django/contrib/gis/tests/test_spatialrefsys.py
index d9c8c38d60..608f6453c2 100644
--- a/django/contrib/gis/tests/test_spatialrefsys.py
+++ b/django/contrib/gis/tests/test_spatialrefsys.py
@@ -1,6 +1,6 @@
from django.db import connection
from django.contrib.gis.gdal import GDAL_VERSION
-from django.contrib.gis.tests.utils import mysql, no_mysql, oracle, postgis, spatialite
+from django.contrib.gis.tests.utils import no_mysql, oracle, postgis, spatialite
from django.utils import unittest
diff --git a/django/contrib/gis/utils/geoip.py b/django/contrib/gis/utils/geoip.py
index eedaef95dd..29b949fc10 100644
--- a/django/contrib/gis/utils/geoip.py
+++ b/django/contrib/gis/utils/geoip.py
@@ -38,7 +38,8 @@
>>> g.geos('24.124.1.80').wkt
'POINT (-95.2087020874023438 39.0392990112304688)'
"""
-import os, re
+import os
+import re
from ctypes import c_char_p, c_float, c_int, Structure, CDLL, POINTER
from ctypes.util import find_library
from django.conf import settings
diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py
index a970b077c7..d36811228a 100644
--- a/django/contrib/gis/utils/layermapping.py
+++ b/django/contrib/gis/utils/layermapping.py
@@ -7,15 +7,14 @@
http://geodjango.org/docs/layermapping.html
"""
import sys
-from datetime import date, datetime
from decimal import Decimal
from django.core.exceptions import ObjectDoesNotExist
from django.db import connections, DEFAULT_DB_ALIAS
from django.contrib.gis.db.models import GeometryField
-from django.contrib.gis.gdal import CoordTransform, DataSource, \
- OGRException, OGRGeometry, OGRGeomType, SpatialReference
-from django.contrib.gis.gdal.field import \
- OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime
+from django.contrib.gis.gdal import (CoordTransform, DataSource,
+ OGRException, OGRGeometry, OGRGeomType, SpatialReference)
+from django.contrib.gis.gdal.field import (
+ OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime)
from django.db import models, transaction
from django.contrib.localflavor.us.models import USStateField
diff --git a/django/contrib/gis/utils/ogrinspect.py b/django/contrib/gis/utils/ogrinspect.py
index 145bd221bb..fe4443cb44 100644
--- a/django/contrib/gis/utils/ogrinspect.py
+++ b/django/contrib/gis/utils/ogrinspect.py
@@ -8,7 +8,7 @@ Author: Travis Pinney, Dane Springmeyer, & Justin Bronn
from itertools import izip
# Requires GDAL to use.
from django.contrib.gis.gdal import DataSource
-from django.contrib.gis.gdal.field import OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime
+from django.contrib.gis.gdal.field import OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString
def mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False):
"""
diff --git a/django/contrib/localflavor/ar/forms.py b/django/contrib/localflavor/ar/forms.py
index 57b5f8b6eb..36b7530e4c 100644
--- a/django/contrib/localflavor/ar/forms.py
+++ b/django/contrib/localflavor/ar/forms.py
@@ -6,7 +6,6 @@ AR-specific Form helpers.
from django.forms import ValidationError
from django.core.validators import EMPTY_VALUES
from django.forms.fields import RegexField, CharField, Select
-from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
class ARProvinceSelect(Select):
diff --git a/django/contrib/localflavor/au/models.py b/django/contrib/localflavor/au/models.py
index e2b897e4df..ce4f120f77 100644
--- a/django/contrib/localflavor/au/models.py
+++ b/django/contrib/localflavor/au/models.py
@@ -1,4 +1,3 @@
-from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django.db.models.fields import CharField
diff --git a/django/contrib/localflavor/be/forms.py b/django/contrib/localflavor/be/forms.py
index 6715e8755e..4e86d7e735 100644
--- a/django/contrib/localflavor/be/forms.py
+++ b/django/contrib/localflavor/be/forms.py
@@ -1,10 +1,6 @@
"""
Belgium-specific Form helpers
"""
-import re
-
-from django.core.validators import EMPTY_VALUES
-from django.forms import ValidationError
from django.forms.fields import RegexField, Select
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/localflavor/jp/forms.py b/django/contrib/localflavor/jp/forms.py
index 248a93819e..11dc6e81c0 100644
--- a/django/contrib/localflavor/jp/forms.py
+++ b/django/contrib/localflavor/jp/forms.py
@@ -2,7 +2,6 @@
JP-specific Form helpers
"""
-from django.forms import ValidationError
from django.utils.translation import ugettext_lazy as _
from django.forms.fields import RegexField, Select
diff --git a/django/contrib/localflavor/kw/forms.py b/django/contrib/localflavor/kw/forms.py
index 94296255d6..e671408ec8 100644
--- a/django/contrib/localflavor/kw/forms.py
+++ b/django/contrib/localflavor/kw/forms.py
@@ -6,7 +6,7 @@ from datetime import date
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
-from django.forms.fields import Field, RegexField
+from django.forms.fields import Field
from django.utils.translation import gettext as _
id_re = re.compile(r'^(?P<initial>\d{1})(?P<yy>\d\d)(?P<mm>\d\d)(?P<dd>\d\d)(?P<mid>\d{4})(?P<checksum>\d{1})')
diff --git a/django/contrib/localflavor/no/forms.py b/django/contrib/localflavor/no/forms.py
index abe3b80bec..930cc176d6 100644
--- a/django/contrib/localflavor/no/forms.py
+++ b/django/contrib/localflavor/no/forms.py
@@ -2,7 +2,8 @@
Norwegian-specific Form helpers
"""
-import re, datetime
+import re
+import datetime
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
from django.forms.fields import Field, RegexField, Select
diff --git a/django/contrib/localflavor/pt/forms.py b/django/contrib/localflavor/pt/forms.py
index 2a563cf99b..3de7376eac 100644
--- a/django/contrib/localflavor/pt/forms.py
+++ b/django/contrib/localflavor/pt/forms.py
@@ -1,13 +1,13 @@
"""
PT-specific Form helpers
"""
+import re
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError
-from django.forms.fields import Field, RegexField, Select
+from django.forms.fields import Field, RegexField
from django.utils.encoding import smart_unicode
from django.utils.translation import ugettext_lazy as _
-import re
phone_digits_re = re.compile(r'^(\d{9}|(00|\+)\d*)$')
diff --git a/django/contrib/localflavor/ro/forms.py b/django/contrib/localflavor/ro/forms.py
index 3bfb0fab0d..1121f8ea04 100644
--- a/django/contrib/localflavor/ro/forms.py
+++ b/django/contrib/localflavor/ro/forms.py
@@ -2,9 +2,6 @@
"""
Romanian specific form helpers.
"""
-
-import re
-
from django.core.validators import EMPTY_VALUES
from django.forms import ValidationError, Field, RegexField, Select
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/localflavor/ru/forms.py b/django/contrib/localflavor/ru/forms.py
index d091eabe4b..a8662b5e47 100644
--- a/django/contrib/localflavor/ru/forms.py
+++ b/django/contrib/localflavor/ru/forms.py
@@ -3,9 +3,7 @@ Russian-specific forms helpers
"""
import re
-from django.core.validators import EMPTY_VALUES
-from django.forms import ValidationError
-from django.forms.fields import CharField, Select, RegexField
+from django.forms.fields import RegexField, Select
from django.utils.translation import ugettext_lazy as _
phone_digits_re = re.compile(r'^(?:[78]-?)?(\d{3})[-\.]?(\d{3})[-\.]?(\d{4})$')
diff --git a/django/contrib/localflavor/se/utils.py b/django/contrib/localflavor/se/utils.py
index 50d8ac1d8e..5f65d8fcb2 100644
--- a/django/contrib/localflavor/se/utils.py
+++ b/django/contrib/localflavor/se/utils.py
@@ -1,4 +1,3 @@
-import re
import datetime
def id_number_checksum(gd):
diff --git a/django/contrib/localflavor/us/models.py b/django/contrib/localflavor/us/models.py
index d5f797665a..7cec205ccc 100644
--- a/django/contrib/localflavor/us/models.py
+++ b/django/contrib/localflavor/us/models.py
@@ -1,4 +1,3 @@
-from django.conf import settings
from django.utils.translation import ugettext_lazy as _
from django.db.models.fields import CharField
from django.contrib.localflavor.us.us_states import STATE_CHOICES
diff --git a/django/contrib/localflavor/uy/forms.py b/django/contrib/localflavor/uy/forms.py
index 3f70cf336a..2d90e52ce6 100644
--- a/django/contrib/localflavor/uy/forms.py
+++ b/django/contrib/localflavor/uy/forms.py
@@ -2,8 +2,6 @@
"""
UY-specific form helpers.
"""
-import re
-
from django.core.validators import EMPTY_VALUES
from django.forms.fields import Select, RegexField
from django.forms import ValidationError
diff --git a/django/contrib/messages/api.py b/django/contrib/messages/api.py
index 9880d7f7db..8e08655aa0 100644
--- a/django/contrib/messages/api.py
+++ b/django/contrib/messages/api.py
@@ -1,6 +1,5 @@
from django.contrib.messages import constants
from django.contrib.messages.storage import default_storage
-from django.utils.functional import lazy, memoize
__all__ = (
'add_message', 'get_messages',
diff --git a/django/contrib/messages/storage/cookie.py b/django/contrib/messages/storage/cookie.py
index 45a20d0f94..c45dff4e43 100644
--- a/django/contrib/messages/storage/cookie.py
+++ b/django/contrib/messages/storage/cookie.py
@@ -1,5 +1,4 @@
from django.conf import settings
-from django.contrib.messages import constants
from django.contrib.messages.storage.base import BaseStorage, Message
from django.http import SimpleCookie
from django.utils import simplejson as json
diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py
index c6886a8cd0..416d16ca15 100644
--- a/django/contrib/messages/tests/base.py
+++ b/django/contrib/messages/tests/base.py
@@ -1,5 +1,3 @@
-import warnings
-
from django import http
from django.test import TestCase
from django.conf import settings
diff --git a/django/contrib/messages/tests/cookie.py b/django/contrib/messages/tests/cookie.py
index 95e1f99c79..f22ed399bc 100644
--- a/django/contrib/messages/tests/cookie.py
+++ b/django/contrib/messages/tests/cookie.py
@@ -1,7 +1,7 @@
from django.contrib.messages import constants
from django.contrib.messages.tests.base import BaseTest
-from django.contrib.messages.storage.cookie import CookieStorage, \
- MessageEncoder, MessageDecoder
+from django.contrib.messages.storage.cookie import (CookieStorage,
+ MessageEncoder, MessageDecoder)
from django.contrib.messages.storage.base import Message
from django.utils import simplejson as json
from django.conf import settings
diff --git a/django/contrib/messages/tests/fallback.py b/django/contrib/messages/tests/fallback.py
index 9e4f657877..0aa65008da 100644
--- a/django/contrib/messages/tests/fallback.py
+++ b/django/contrib/messages/tests/fallback.py
@@ -1,11 +1,11 @@
from django.contrib.messages import constants
-from django.contrib.messages.storage.fallback import FallbackStorage, \
- CookieStorage
+from django.contrib.messages.storage.fallback import (FallbackStorage,
+ CookieStorage)
from django.contrib.messages.tests.base import BaseTest
-from django.contrib.messages.tests.cookie import set_cookie_data, \
- stored_cookie_messages_count
-from django.contrib.messages.tests.session import set_session_data, \
- stored_session_messages_count
+from django.contrib.messages.tests.cookie import (set_cookie_data,
+ stored_cookie_messages_count)
+from django.contrib.messages.tests.session import (set_session_data,
+ stored_session_messages_count)
class FallbackTest(BaseTest):
diff --git a/django/contrib/messages/tests/urls.py b/django/contrib/messages/tests/urls.py
index 5191f34a56..263b0a8a0d 100644
--- a/django/contrib/messages/tests/urls.py
+++ b/django/contrib/messages/tests/urls.py
@@ -2,7 +2,6 @@ from django.conf.urls.defaults import *
from django.contrib import messages
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, HttpResponse
-from django.shortcuts import render_to_response, redirect
from django.template import RequestContext, Template
from django.template.response import TemplateResponse
from django.views.decorators.cache import never_cache
diff --git a/django/contrib/sessions/backends/base.py b/django/contrib/sessions/backends/base.py
index 1c7c188ed5..050ed7b69e 100644
--- a/django/contrib/sessions/backends/base.py
+++ b/django/contrib/sessions/backends/base.py
@@ -2,7 +2,6 @@ import base64
import hashlib
import os
import random
-import sys
import time
from datetime import datetime, timedelta
try:
diff --git a/django/contrib/sessions/backends/db.py b/django/contrib/sessions/backends/db.py
index 9a537905a7..220046fefb 100644
--- a/django/contrib/sessions/backends/db.py
+++ b/django/contrib/sessions/backends/db.py
@@ -1,5 +1,4 @@
import datetime
-from django.conf import settings
from django.contrib.sessions.backends.base import SessionBase, CreateError
from django.core.exceptions import SuspiciousOperation
from django.db import IntegrityError, transaction, router
diff --git a/django/contrib/sessions/models.py b/django/contrib/sessions/models.py
index 1d82a9929b..0179c358b3 100644
--- a/django/contrib/sessions/models.py
+++ b/django/contrib/sessions/models.py
@@ -1,6 +1,3 @@
-import base64
-import cPickle as pickle
-
from django.db import models
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/sitemaps/__init__.py b/django/contrib/sitemaps/__init__.py
index 98ab353606..2ce919f561 100644
--- a/django/contrib/sitemaps/__init__.py
+++ b/django/contrib/sitemaps/__init__.py
@@ -1,4 +1,4 @@
-from django.contrib.sites.models import Site, get_current_site
+from django.contrib.sites.models import Site
from django.core import urlresolvers, paginator
from django.core.exceptions import ImproperlyConfigured
import urllib
diff --git a/django/contrib/sitemaps/views.py b/django/contrib/sitemaps/views.py
index b117b33aab..d82146c0ea 100644
--- a/django/contrib/sitemaps/views.py
+++ b/django/contrib/sitemaps/views.py
@@ -1,8 +1,7 @@
from django.core import urlresolvers
from django.core.paginator import EmptyPage, PageNotAnInteger
-from django.http import HttpResponse, Http404
+from django.http import Http404
from django.template.response import TemplateResponse
-from django.utils.encoding import smart_str
from django.contrib.sites.models import get_current_site
diff --git a/django/core/cache/backends/base.py b/django/core/cache/backends/base.py
index 513adb48fe..f7573b2e31 100644
--- a/django/core/cache/backends/base.py
+++ b/django/core/cache/backends/base.py
@@ -2,7 +2,6 @@
import warnings
-from django.conf import settings
from django.core.exceptions import ImproperlyConfigured, DjangoRuntimeWarning
from django.utils.encoding import smart_str
from django.utils.importlib import import_module
diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py
index 495812a48d..fb05851e4b 100644
--- a/django/core/cache/backends/db.py
+++ b/django/core/cache/backends/db.py
@@ -1,14 +1,17 @@
"Database cache backend."
-
-from django.core.cache.backends.base import BaseCache
-from django.db import connections, router, transaction, DatabaseError
-import base64, time
+import base64
+import time
from datetime import datetime
+
try:
import cPickle as pickle
except ImportError:
import pickle
+from django.core.cache.backends.base import BaseCache
+from django.db import connections, router, transaction, DatabaseError
+
+
class Options(object):
"""A class that will quack like a Django model _meta class.
diff --git a/django/core/cache/backends/memcached.py b/django/core/cache/backends/memcached.py
index e45249874d..1e1d97ed35 100644
--- a/django/core/cache/backends/memcached.py
+++ b/django/core/cache/backends/memcached.py
@@ -4,7 +4,6 @@ import time
from threading import local
from django.core.cache.backends.base import BaseCache, InvalidCacheBackendError
-from django.utils import importlib
class BaseMemcachedCache(BaseCache):
def __init__(self, server, params, library, value_not_found_exception):
diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py
index 5affea45c5..eba9dd39ca 100644
--- a/django/core/handlers/modpython.py
+++ b/django/core/handlers/modpython.py
@@ -1,5 +1,4 @@
import os
-from pprint import pformat
import sys
from warnings import warn
@@ -8,7 +7,7 @@ from django.core import signals
from django.core.handlers.base import BaseHandler
from django.core.urlresolvers import set_script_prefix
from django.utils import datastructures
-from django.utils.encoding import force_unicode, smart_str, iri_to_uri
+from django.utils.encoding import force_unicode, iri_to_uri
from django.utils.log import getLogger
logger = getLogger('django.request')
diff --git a/django/core/handlers/profiler-hotshot.py b/django/core/handlers/profiler-hotshot.py
index 6cf94b0c00..0522de6d84 100644
--- a/django/core/handlers/profiler-hotshot.py
+++ b/django/core/handlers/profiler-hotshot.py
@@ -1,4 +1,7 @@
-import hotshot, time, os
+import hotshot
+import os
+import time
+
from django.core.handlers.modpython import ModPythonHandler
PROFILE_DATA_DIR = "/var/log/cmsprofile"
diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py
index 14420fa760..56d2ba631c 100644
--- a/django/core/handlers/wsgi.py
+++ b/django/core/handlers/wsgi.py
@@ -1,11 +1,9 @@
-from pprint import pformat
import sys
from threading import Lock
try:
from cStringIO import StringIO
except ImportError:
from StringIO import StringIO
-import socket
from django import http
from django.core import signals
diff --git a/django/core/mail/__init__.py b/django/core/mail/__init__.py
index 2c71b11541..f363fc53b2 100644
--- a/django/core/mail/__init__.py
+++ b/django/core/mail/__init__.py
@@ -11,11 +11,11 @@ from django.utils.importlib import import_module
# django/core/mail.py before the introduction of email
# backends and the subsequent reorganization (See #10355)
from django.core.mail.utils import CachedDnsName, DNS_NAME
-from django.core.mail.message import \
- EmailMessage, EmailMultiAlternatives, \
- SafeMIMEText, SafeMIMEMultipart, \
- DEFAULT_ATTACHMENT_MIME_TYPE, make_msgid, \
- BadHeaderError, forbid_multi_line_headers
+from django.core.mail.message import (
+ EmailMessage, EmailMultiAlternatives,
+ SafeMIMEText, SafeMIMEMultipart,
+ DEFAULT_ATTACHMENT_MIME_TYPE, make_msgid,
+ BadHeaderError, forbid_multi_line_headers)
from django.core.mail.backends.smtp import EmailBackend as _SMTPConnection
def get_connection(backend=None, fail_silently=False, **kwds):
diff --git a/django/core/management/commands/reset.py b/django/core/management/commands/reset.py
index 8aa7e88626..9539212f48 100644
--- a/django/core/management/commands/reset.py
+++ b/django/core/management/commands/reset.py
@@ -1,6 +1,5 @@
from optparse import make_option
-from django.conf import settings
from django.core.management.base import AppCommand, CommandError
from django.core.management.color import no_style
from django.core.management.sql import sql_reset
diff --git a/django/core/serializers/base.py b/django/core/serializers/base.py
index 6afaf216a8..ffc869ca01 100644
--- a/django/core/serializers/base.py
+++ b/django/core/serializers/base.py
@@ -5,8 +5,7 @@ Module for abstract serializer/unserializer base classes.
from StringIO import StringIO
from django.db import models
-from django.utils.encoding import smart_str, smart_unicode
-from django.utils import datetime_safe
+from django.utils.encoding import smart_unicode
class SerializerDoesNotExist(KeyError):
"""The requested serializer was not found."""
diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py
index b6c8d55c87..560637fa5c 100644
--- a/django/core/servers/basehttp.py
+++ b/django/core/servers/basehttp.py
@@ -18,7 +18,6 @@ from wsgiref import simple_server
from wsgiref.util import FileWrapper # for backwards compatibility
import django
-from django.core.exceptions import ImproperlyConfigured
from django.core.management.color import color_style
from django.utils._os import safe_join
from django.views import static
diff --git a/django/core/servers/fastcgi.py b/django/core/servers/fastcgi.py
index 7e724c2510..9f80d2ba44 100644
--- a/django/core/servers/fastcgi.py
+++ b/django/core/servers/fastcgi.py
@@ -12,8 +12,9 @@ Run with the extra option "help" for a list of additional options you can
pass to this server.
"""
+import os
+import sys
from django.utils import importlib
-import sys, os
__version__ = "0.1"
__all__ = ["runfastcgi"]
diff --git a/django/db/__init__.py b/django/db/__init__.py
index 2148cf0523..8395468b8c 100644
--- a/django/db/__init__.py
+++ b/django/db/__init__.py
@@ -1,8 +1,8 @@
from django.conf import settings
from django.core import signals
from django.core.exceptions import ImproperlyConfigured
-from django.db.utils import ConnectionHandler, ConnectionRouter, load_backend, DEFAULT_DB_ALIAS, \
- DatabaseError, IntegrityError
+from django.db.utils import (ConnectionHandler, ConnectionRouter,
+ load_backend, DEFAULT_DB_ALIAS, DatabaseError, IntegrityError)
__all__ = ('backend', 'connection', 'connections', 'router', 'DatabaseError',
'IntegrityError', 'DEFAULT_DB_ALIAS')
diff --git a/django/db/backends/__init__.py b/django/db/backends/__init__.py
index b64fb01b03..1c3bc7e919 100644
--- a/django/db/backends/__init__.py
+++ b/django/db/backends/__init__.py
@@ -1,4 +1,3 @@
-import decimal
try:
import thread
except ImportError:
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index 42de0dd07b..930b1bb0f1 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -6,7 +6,7 @@ Requires cx_Oracle: http://cx-oracle.sourceforge.net/
import datetime
-from decimal import Decimal
+import decimal
import sys
@@ -730,7 +730,7 @@ def _rowfactory(row, cursor):
# This will normally be an integer from a sequence,
# but it could be a decimal value.
if '.' in value:
- value = Decimal(value)
+ value = decimal.Decimal(value)
else:
value = int(value)
else:
@@ -743,12 +743,12 @@ def _rowfactory(row, cursor):
if scale == 0:
value = int(value)
else:
- value = Decimal(value)
+ value = decimal.Decimal(value)
elif '.' in value:
# No type information. This normally comes from a
# mathematical expression in the SELECT list. Guess int
# or Decimal based on whether it has a decimal point.
- value = Decimal(value)
+ value = decimal.Decimal(value)
else:
value = int(value)
elif desc[1] in (Database.STRING, Database.FIXED_CHAR,
diff --git a/django/db/backends/oracle/creation.py b/django/db/backends/oracle/creation.py
index 1e95a89f1e..44f8d914fa 100644
--- a/django/db/backends/oracle/creation.py
+++ b/django/db/backends/oracle/creation.py
@@ -1,4 +1,5 @@
-import sys, time
+import sys
+import time
from django.db.backends.creation import BaseDatabaseCreation
TEST_DATABASE_PREFIX = 'test_'
diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py
index d25a2fe1ff..6ed59a66f4 100644
--- a/django/db/backends/postgresql_psycopg2/base.py
+++ b/django/db/backends/postgresql_psycopg2/base.py
@@ -3,7 +3,6 @@ PostgreSQL database backend for Django.
Requires psycopg 2: http://initd.org/projects/psycopg2
"""
-
import sys
from django.db import utils
diff --git a/django/db/backends/postgresql_psycopg2/operations.py b/django/db/backends/postgresql_psycopg2/operations.py
index fe021b5fc6..d535ee316f 100644
--- a/django/db/backends/postgresql_psycopg2/operations.py
+++ b/django/db/backends/postgresql_psycopg2/operations.py
@@ -1,5 +1,3 @@
-import re
-
from django.db.backends import BaseDatabaseOperations
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
index 5b4a1c2415..79c5eded34 100644
--- a/django/db/backends/sqlite3/base.py
+++ b/django/db/backends/sqlite3/base.py
@@ -5,9 +5,10 @@ Works with either the pysqlite2 module or the sqlite3 module in the
standard library.
"""
+import datetime
+import decimal
import re
import sys
-import datetime
from django.db import utils
from django.db.backends import *
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 31310ea0e7..71fd1f78bb 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -1,28 +1,29 @@
import copy
import sys
-import types
from functools import update_wrapper
from itertools import izip
import django.db.models.manager # Imported to register signal handler.
-from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned, FieldError, ValidationError, NON_FIELD_ERRORS
+from django.conf import settings
+from django.core.exceptions import (ObjectDoesNotExist,
+ MultipleObjectsReturned, FieldError, ValidationError, NON_FIELD_ERRORS)
from django.core import validators
from django.db.models.fields import AutoField, FieldDoesNotExist
-from django.db.models.fields.related import (OneToOneRel, ManyToOneRel,
+from django.db.models.fields.related import (ManyToOneRel,
OneToOneField, add_lazy_relation)
+from django.db import (connections, router, transaction, DatabaseError,
+ DEFAULT_DB_ALIAS)
from django.db.models.query import Q
from django.db.models.query_utils import DeferredAttribute
from django.db.models.deletion import Collector
from django.db.models.options import Options
-from django.db import (connections, router, transaction, DatabaseError,
- DEFAULT_DB_ALIAS)
from django.db.models import signals
from django.db.models.loading import register_models, get_model
from django.utils.translation import ugettext_lazy as _
from django.utils.functional import curry
from django.utils.encoding import smart_str, force_unicode
from django.utils.text import get_text_list, capfirst
-from django.conf import settings
+
class ModelBase(type):
"""
diff --git a/django/db/models/deletion.py b/django/db/models/deletion.py
index 310e3af948..e1653462d7 100644
--- a/django/db/models/deletion.py
+++ b/django/db/models/deletion.py
@@ -3,7 +3,6 @@ from operator import attrgetter
from django.db import connections, transaction, IntegrityError
from django.db.models import signals, sql
-from django.db.models.sql.constants import GET_ITERATOR_CHUNK_SIZE
from django.utils.datastructures import SortedDict
diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py
index 91ecbf2e7e..4362c047c3 100644
--- a/django/db/models/fields/__init__.py
+++ b/django/db/models/fields/__init__.py
@@ -17,7 +17,7 @@ from django.utils.text import capfirst
from django.utils.translation import ugettext_lazy as _
from django.utils.encoding import smart_unicode, force_unicode, smart_str
from django.utils import datetime_safe
-from django.utils.ipv6 import clean_ipv6_address, is_valid_ipv6_address
+from django.utils.ipv6 import clean_ipv6_address
class NOT_PROVIDED:
pass
diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py
index 50dc236902..4ecb337b5a 100644
--- a/django/db/models/fields/files.py
+++ b/django/db/models/fields/files.py
@@ -1,18 +1,14 @@
import datetime
import os
-from django.conf import settings
+from django import forms
from django.db.models.fields import Field
-from django.core.files.base import File, ContentFile
+from django.core.files.base import File
from django.core.files.storage import default_storage
-from django.core.files.images import ImageFile, get_image_dimensions
-from django.core.files.uploadedfile import UploadedFile
-from django.utils.functional import curry
+from django.core.files.images import ImageFile
from django.db.models import signals
from django.utils.encoding import force_unicode, smart_str
-from django.utils.translation import ugettext_lazy, ugettext as _
-from django import forms
-from django.db.models.loading import cache
+from django.utils.translation import ugettext_lazy as _
class FieldFile(File):
def __init__(self, instance, field, name):
@@ -215,7 +211,7 @@ class FileField(Field):
# The descriptor to use for accessing the attribute off of the class.
descriptor_class = FileDescriptor
- description = ugettext_lazy("File path")
+ description = _("File path")
def __init__(self, verbose_name=None, name=None, upload_to='', storage=None, **kwargs):
for arg in ('primary_key', 'unique'):
@@ -312,6 +308,7 @@ class ImageFileDescriptor(FileDescriptor):
self.field.update_dimension_fields(instance, force=True)
class ImageFieldFile(ImageFile, FieldFile):
+
def delete(self, save=True):
# Clear the image dimensions cache
if hasattr(self, '_dimensions_cache'):
@@ -321,7 +318,7 @@ class ImageFieldFile(ImageFile, FieldFile):
class ImageField(FileField):
attr_class = ImageFieldFile
descriptor_class = ImageFileDescriptor
- description = ugettext_lazy("File path")
+ description = _("File path")
def __init__(self, verbose_name=None, name=None, width_field=None, height_field=None, **kwargs):
self.width_field, self.height_field = width_field, height_field
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index cedf3088c4..e7f4b9b3de 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -1,5 +1,4 @@
-from django.conf import settings
-from django.db import connection, router, transaction
+from django.db import connection, router
from django.db.backends import util
from django.db.models import signals, get_model
from django.db.models.fields import (AutoField, Field, IntegerField,
@@ -9,8 +8,7 @@ from django.db.models.query import QuerySet
from django.db.models.query_utils import QueryWrapper
from django.db.models.deletion import CASCADE
from django.utils.encoding import smart_unicode
-from django.utils.translation import (ugettext_lazy as _, string_concat,
- ungettext, ugettext)
+from django.utils.translation import ugettext_lazy as _, string_concat
from django.utils.functional import curry
from django.core import exceptions
from django import forms
diff --git a/django/db/models/loading.py b/django/db/models/loading.py
index 2c35fdb1df..03cdcc23e7 100644
--- a/django/db/models/loading.py
+++ b/django/db/models/loading.py
@@ -6,7 +6,6 @@ from django.utils.datastructures import SortedDict
from django.utils.importlib import import_module
from django.utils.module_loading import module_has_submodule
-import imp
import sys
import os
import threading
diff --git a/django/db/models/manager.py b/django/db/models/manager.py
index 4fa4c4a52d..bdd86bbd45 100644
--- a/django/db/models/manager.py
+++ b/django/db/models/manager.py
@@ -1,5 +1,4 @@
import copy
-from django.conf import settings
from django.db import router
from django.db.models.query import QuerySet, EmptyQuerySet, insert_query, RawQuerySet
from django.db.models import signals
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 57288f42dd..af62061e11 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -3,11 +3,8 @@ The main QuerySet implementation. This provides the public API for the ORM.
"""
import copy
-from itertools import izip
from django.db import connections, router, transaction, IntegrityError
-from django.db.models.aggregates import Aggregate
-from django.db.models.fields import DateField
from django.db.models.query_utils import (Q, select_related_descend,
deferred_class_factory, InvalidQuery)
from django.db.models.deletion import Collector
diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py
index 69b19f1806..a56ab5ca80 100644
--- a/django/db/models/query_utils.py
+++ b/django/db/models/query_utils.py
@@ -10,7 +10,6 @@ import weakref
from django.db.backends import util
from django.utils import tree
-from django.utils.datastructures import SortedDict
class InvalidQuery(Exception):
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index b5f170eb49..05c19f33d5 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -5,8 +5,8 @@ from django.db.backends.util import truncate_name
from django.db.models.sql.constants import *
from django.db.models.sql.datastructures import EmptyResultSet
from django.db.models.sql.expressions import SQLEvaluator
-from django.db.models.sql.query import get_proxied_model, get_order_dir, \
- select_related_descend, Query
+from django.db.models.sql.query import (get_proxied_model, get_order_dir,
+ select_related_descend, Query)
from django.db.utils import DatabaseError
class SQLCompiler(object):
diff --git a/django/db/models/sql/subqueries.py b/django/db/models/sql/subqueries.py
index 003bf432c0..ecde857a9b 100644
--- a/django/db/models/sql/subqueries.py
+++ b/django/db/models/sql/subqueries.py
@@ -3,11 +3,9 @@ Query subclasses which provide extra functionality beyond simple data retrieval.
"""
from django.core.exceptions import FieldError
-from django.db import connections
from django.db.models.fields import DateField, FieldDoesNotExist
from django.db.models.sql.constants import *
from django.db.models.sql.datastructures import Date
-from django.db.models.sql.expressions import SQLEvaluator
from django.db.models.sql.query import Query
from django.db.models.sql.where import AND, Constraint
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index 2427a528fb..3e9dbf0527 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -6,7 +6,6 @@ from itertools import repeat
from django.utils import tree
from django.db.models.fields import Field
-from django.db.models.query_utils import QueryWrapper
from datastructures import EmptyResultSet, FullResultSet
# Connection types
diff --git a/django/db/transaction.py b/django/db/transaction.py
index 104243a488..4ecd2d1f08 100644
--- a/django/db/transaction.py
+++ b/django/db/transaction.py
@@ -13,10 +13,8 @@ or implicit commits or rollbacks.
"""
from __future__ import with_statement
-import sys
from functools import wraps
-from django.conf import settings
from django.db import connections, DEFAULT_DB_ALIAS
diff --git a/django/dispatch/saferef.py b/django/dispatch/saferef.py
index f446447b46..1c7d16474f 100644
--- a/django/dispatch/saferef.py
+++ b/django/dispatch/saferef.py
@@ -5,7 +5,8 @@ Provides a way to safely weakref any function, including bound methods (which
aren't handled by the core weakref module).
"""
-import weakref, traceback
+import traceback
+import weakref
def safeRef(target, onDelete = None):
"""Return a *safe* weak reference to a callable target
diff --git a/django/forms/extras/widgets.py b/django/forms/extras/widgets.py
index d75e903f56..51455780f5 100644
--- a/django/forms/extras/widgets.py
+++ b/django/forms/extras/widgets.py
@@ -2,7 +2,6 @@
Extra HTML Widget classes
"""
-import time
import datetime
import re
diff --git a/django/forms/models.py b/django/forms/models.py
index b34f4d03e8..9a985458e9 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -3,14 +3,14 @@ Helper functions for creating Form classes from Django models
and database field objects.
"""
+from django.core.exceptions import ValidationError, NON_FIELD_ERRORS, FieldError
+from django.core.validators import EMPTY_VALUES
+
from django.utils.encoding import smart_unicode, force_unicode
from django.utils.datastructures import SortedDict
from django.utils.text import get_text_list, capfirst
from django.utils.translation import ugettext_lazy as _, ugettext
-from django.core.exceptions import ValidationError, NON_FIELD_ERRORS, \
- FieldError
-from django.core.validators import EMPTY_VALUES
from util import ErrorList
from forms import BaseForm, get_declared_fields
from fields import Field, ChoiceField
diff --git a/django/middleware/http.py b/django/middleware/http.py
index e98858f772..86e46cea82 100644
--- a/django/middleware/http.py
+++ b/django/middleware/http.py
@@ -1,4 +1,3 @@
-from django.core.exceptions import MiddlewareNotUsed
from django.utils.http import http_date, parse_http_date_safe
class ConditionalGetMiddleware(object):
diff --git a/django/template/base.py b/django/template/base.py
index b96e446404..9a7f55f8de 100644
--- a/django/template/base.py
+++ b/django/template/base.py
@@ -1,4 +1,3 @@
-import imp
import re
from functools import partial
from inspect import getargspec
@@ -7,7 +6,6 @@ from django.conf import settings
from django.template.context import Context, RequestContext, ContextPopException
from django.utils.importlib import import_module
from django.utils.itercompat import is_iterable
-from django.utils.functional import Promise
from django.utils.text import smart_split, unescape_string_literal, get_text_list
from django.utils.encoding import smart_unicode, force_unicode, smart_str
from django.utils.translation import ugettext_lazy
diff --git a/django/template/context.py b/django/template/context.py
index cb1c708738..8f70d704e5 100644
--- a/django/template/context.py
+++ b/django/template/context.py
@@ -1,7 +1,6 @@
from copy import copy
from django.core.exceptions import ImproperlyConfigured
from django.utils.importlib import import_module
-from django.http import HttpRequest
# Cache of actual callables.
_standard_context_processors = None
diff --git a/django/template/debug.py b/django/template/debug.py
index a9e3c4f497..bf2a53b90b 100644
--- a/django/template/debug.py
+++ b/django/template/debug.py
@@ -1,4 +1,3 @@
-from django.conf import settings
from django.template.base import Lexer, Parser, tag_re, NodeList, VariableNode, TemplateSyntaxError
from django.utils.encoding import force_unicode
from django.utils.html import escape
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index aa588b815e..41c9abe21e 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -5,12 +5,14 @@ import re
from datetime import datetime
from itertools import groupby, cycle as itertools_cycle
-from django.template.base import Node, NodeList, Template, Context, Variable
-from django.template.base import TemplateSyntaxError, VariableDoesNotExist, BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END, SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END
-from django.template.base import get_library, Library, InvalidTemplateLibrary
+from django.conf import settings
+from django.template.base import (Node, NodeList, Template, Library,
+ TemplateSyntaxError, VariableDoesNotExist, InvalidTemplateLibrary,
+ BLOCK_TAG_START, BLOCK_TAG_END, VARIABLE_TAG_START, VARIABLE_TAG_END,
+ SINGLE_BRACE_START, SINGLE_BRACE_END, COMMENT_TAG_START, COMMENT_TAG_END,
+ get_library)
from django.template.smartif import IfParser, Literal
from django.template.defaultfilters import date
-from django.conf import settings
from django.utils.encoding import smart_str, smart_unicode
from django.utils.safestring import mark_safe
diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py
index f5cac33dc6..8f951edee9 100644
--- a/django/template/loader_tags.py
+++ b/django/template/loader_tags.py
@@ -1,9 +1,7 @@
-from django.template.base import TemplateSyntaxError, TemplateDoesNotExist, Variable
-from django.template.base import Library, Node, TextNode
-from django.template.context import Context
+from django.conf import settings
+from django.template.base import TemplateSyntaxError, Library, Node, TextNode
from django.template.defaulttags import token_kwargs
from django.template.loader import get_template
-from django.conf import settings
from django.utils.safestring import mark_safe
register = Library()
diff --git a/django/template/loaders/cached.py b/django/template/loaders/cached.py
index 5b351ad0aa..3ed9cf3bbf 100644
--- a/django/template/loaders/cached.py
+++ b/django/template/loaders/cached.py
@@ -4,10 +4,8 @@ to load templates from them in order, caching the result.
"""
import hashlib
-from django.core.exceptions import ImproperlyConfigured
from django.template.base import TemplateDoesNotExist
from django.template.loader import BaseLoader, get_template_from_string, find_template_loader, make_origin
-from django.utils.importlib import import_module
class Loader(BaseLoader):
is_usable = True
diff --git a/django/template/smartif.py b/django/template/smartif.py
index e835e0ff70..54d74b4e25 100644
--- a/django/template/smartif.py
+++ b/django/template/smartif.py
@@ -1,7 +1,6 @@
"""
Parser and utilities for the smart 'if' tag
"""
-import operator
# Using a simple top down parser, as described here:
# http://effbot.org/zone/simple-top-down-parsing.htm.
diff --git a/django/templatetags/cache.py b/django/templatetags/cache.py
index 495623deaf..8183452422 100644
--- a/django/templatetags/cache.py
+++ b/django/templatetags/cache.py
@@ -2,7 +2,6 @@ import hashlib
from django.template import Library, Node, TemplateSyntaxError, Variable, VariableDoesNotExist
from django.template import resolve_variable
from django.core.cache import cache
-from django.utils.encoding import force_unicode
from django.utils.http import urlquote
register = Library()
diff --git a/django/templatetags/future.py b/django/templatetags/future.py
index 3d9887939d..14c1ad31ad 100644
--- a/django/templatetags/future.py
+++ b/django/templatetags/future.py
@@ -1,8 +1,5 @@
-from django.conf import settings
-from django.template import Library, Node, Template, TemplateSyntaxError
-from django.template.defaulttags import kwarg_re, include_is_allowed, SsiNode, URLNode
-from django.utils.encoding import smart_str
-
+from django.template import Library, TemplateSyntaxError
+from django.template.defaulttags import kwarg_re, SsiNode, URLNode
register = Library()
diff --git a/django/templatetags/l10n.py b/django/templatetags/l10n.py
index 5191e6936d..12cf136eb9 100644
--- a/django/templatetags/l10n.py
+++ b/django/templatetags/l10n.py
@@ -1,4 +1,3 @@
-from django.conf import settings
from django.template import Node
from django.template import TemplateSyntaxError, Library
from django.utils import formats
diff --git a/django/test/client.py b/django/test/client.py
index 4335f21224..10d87279d0 100644
--- a/django/test/client.py
+++ b/django/test/client.py
@@ -5,7 +5,7 @@ import re
import mimetypes
import warnings
from copy import copy
-from urlparse import urlparse, urlunparse, urlsplit
+from urlparse import urlparse, urlsplit
try:
from cStringIO import StringIO
except ImportError:
@@ -24,7 +24,7 @@ from django.utils.encoding import smart_str
from django.utils.http import urlencode
from django.utils.importlib import import_module
from django.utils.itercompat import is_iterable
-from django.db import transaction, close_connection
+from django.db import close_connection
from django.test.utils import ContextList
__all__ = ('Client', 'RequestFactory', 'encode_file', 'encode_multipart')
diff --git a/django/test/testcases.py b/django/test/testcases.py
index 02717ffaa7..e767712469 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -6,7 +6,7 @@ from functools import wraps
from urlparse import urlsplit, urlunsplit
from xml.dom.minidom import parseString, Node
-from django.conf import settings, UserSettingsHolder
+from django.conf import settings
from django.core import mail
from django.core.management import call_command
from django.core.signals import request_started
diff --git a/django/test/utils.py b/django/test/utils.py
index 7a110da0b3..dbb1c20163 100644
--- a/django/test/utils.py
+++ b/django/test/utils.py
@@ -1,12 +1,8 @@
from __future__ import with_statement
-import sys
-import time
-import os
import warnings
from django.conf import settings, UserSettingsHolder
from django.core import mail
-from django.core.mail.backends import locmem
from django.test.signals import template_rendered, setting_changed
from django.template import Template, loader, TemplateDoesNotExist
from django.template.loaders import cached
diff --git a/django/utils/cache.py b/django/utils/cache.py
index bd23940180..81a8279120 100644
--- a/django/utils/cache.py
+++ b/django/utils/cache.py
@@ -26,7 +26,6 @@ from django.core.cache import get_cache
from django.utils.encoding import smart_str, iri_to_uri
from django.utils.http import http_date
from django.utils.translation import get_language
-from django.http import HttpRequest
cc_delim_re = re.compile(r'\s*,\s*')
diff --git a/django/utils/log.py b/django/utils/log.py
index d0f5109e85..1c3fe70155 100644
--- a/django/utils/log.py
+++ b/django/utils/log.py
@@ -1,5 +1,4 @@
import logging
-import sys
import traceback
from django.conf import settings
diff --git a/django/utils/text.py b/django/utils/text.py
index 00c999c5d5..6c574b4541 100644
--- a/django/utils/text.py
+++ b/django/utils/text.py
@@ -1,8 +1,16 @@
import re
+from gzip import GzipFile
+from htmlentitydefs import name2codepoint
+
+try:
+ from cStringIO import StringIO
+except ImportError:
+ from StringIO import StringIO
+
from django.utils.encoding import force_unicode
from django.utils.functional import allow_lazy
from django.utils.translation import ugettext_lazy, ugettext as _
-from htmlentitydefs import name2codepoint
+
# Capitalizes the first letter of a string.
capfirst = lambda x: x and force_unicode(x)[0].upper() + force_unicode(x)[1:]
@@ -180,9 +188,8 @@ phone2numeric = allow_lazy(phone2numeric)
# From http://www.xhaus.com/alan/python/httpcomp.html#gzip
# Used with permission.
def compress_string(s):
- import cStringIO, gzip
- zbuf = cStringIO.StringIO()
- zfile = gzip.GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
+ zbuf = StringIO()
+ zfile = GzipFile(mode='wb', compresslevel=6, fileobj=zbuf)
zfile.write(s)
zfile.close()
return zbuf.getvalue()
diff --git a/django/utils/timesince.py b/django/utils/timesince.py
index c584ce6981..369a3e2c01 100644
--- a/django/utils/timesince.py
+++ b/django/utils/timesince.py
@@ -1,5 +1,4 @@
import datetime
-import time
from django.utils.tzinfo import LocalTimezone
from django.utils.translation import ungettext, ugettext
diff --git a/django/utils/translation/trans_null.py b/django/utils/translation/trans_null.py
index daee96eb75..5c9edb1dd4 100644
--- a/django/utils/translation/trans_null.py
+++ b/django/utils/translation/trans_null.py
@@ -2,7 +2,6 @@
# that don't actually do anything. This is purely for performance, so that
# settings.USE_I18N = False can use this module rather than trans_real.py.
-import warnings
from django.conf import settings
from django.utils.encoding import force_unicode
from django.utils.safestring import mark_safe, SafeData
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index edecfeca61..71765e74e5 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -4,11 +4,14 @@ import locale
import os
import re
import sys
-import warnings
import gettext as gettext_module
-from cStringIO import StringIO
from threading import local
+try:
+ from cStringIO import StringIO
+except ImportError:
+ from StringIO import StringIO
+
from django.utils.importlib import import_module
from django.utils.safestring import mark_safe, SafeData
diff --git a/django/utils/version.py b/django/utils/version.py
index 557135fc35..cb8623b103 100644
--- a/django/utils/version.py
+++ b/django/utils/version.py
@@ -1,5 +1,4 @@
import django
-import os.path
import re
def get_svn_revision(path=None):
diff --git a/django/views/debug.py b/django/views/debug.py
index 490d4bbecf..58d271b860 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -3,7 +3,6 @@ import os
import re
import sys
import types
-from pprint import pformat
from django.conf import settings
from django.http import (HttpResponse, HttpResponseServerError,
diff --git a/django/views/decorators/http.py b/django/views/decorators/http.py
index 6fc882efa7..495a7b10d5 100644
--- a/django/views/decorators/http.py
+++ b/django/views/decorators/http.py
@@ -3,7 +3,6 @@ Decorators for views based on HTTP headers.
"""
from calendar import timegm
-from datetime import timedelta
from functools import wraps
from django.utils.decorators import decorator_from_middleware, available_attrs
diff --git a/django/views/generic/base.py b/django/views/generic/base.py
index 6b5256779f..f2d495021d 100644
--- a/django/views/generic/base.py
+++ b/django/views/generic/base.py
@@ -1,7 +1,6 @@
from functools import update_wrapper
from django import http
from django.core.exceptions import ImproperlyConfigured
-from django.template import RequestContext, loader
from django.template.response import TemplateResponse
from django.utils.log import getLogger
from django.utils.decorators import classonlymethod
diff --git a/django/views/generic/detail.py b/django/views/generic/detail.py
index 7e9047fcb7..16e2c4844d 100644
--- a/django/views/generic/detail.py
+++ b/django/views/generic/detail.py
@@ -1,5 +1,3 @@
-import re
-
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
from django.http import Http404
from django.utils.encoding import smart_str
diff --git a/django/views/generic/list.py b/django/views/generic/list.py
index 5135763d53..9797356529 100644
--- a/django/views/generic/list.py
+++ b/django/views/generic/list.py
@@ -1,5 +1,3 @@
-import re
-
from django.core.paginator import Paginator, InvalidPage
from django.core.exceptions import ImproperlyConfigured
from django.http import Http404
diff --git a/tests/modeltests/basic/models.py b/tests/modeltests/basic/models.py
index 5f51fd8e11..26fddf0706 100644
--- a/tests/modeltests/basic/models.py
+++ b/tests/modeltests/basic/models.py
@@ -4,7 +4,7 @@
This is a basic model with only two non-primary-key fields.
"""
-from django.db import models, DEFAULT_DB_ALIAS, connection
+from django.db import models
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
diff --git a/tests/modeltests/basic/tests.py b/tests/modeltests/basic/tests.py
index 966798d78b..ff09d9b5a1 100644
--- a/tests/modeltests/basic/tests.py
+++ b/tests/modeltests/basic/tests.py
@@ -1,7 +1,6 @@
from datetime import datetime
from django.core.exceptions import ObjectDoesNotExist
-from django.db import models, DEFAULT_DB_ALIAS, connection
from django.db.models.fields import FieldDoesNotExist
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
diff --git a/tests/modeltests/custom_pk/models.py b/tests/modeltests/custom_pk/models.py
index ff2f2bac1b..c514fd74c3 100644
--- a/tests/modeltests/custom_pk/models.py
+++ b/tests/modeltests/custom_pk/models.py
@@ -6,8 +6,7 @@ By default, Django adds an ``"id"`` field to each model. But you can override
this behavior by explicitly adding ``primary_key=True`` to a field.
"""
-from django.conf import settings
-from django.db import models, transaction, IntegrityError, DEFAULT_DB_ALIAS
+from django.db import models
from fields import MyAutoField
diff --git a/tests/modeltests/custom_pk/tests.py b/tests/modeltests/custom_pk/tests.py
index c410ad17e3..6b94b6d33f 100644
--- a/tests/modeltests/custom_pk/tests.py
+++ b/tests/modeltests/custom_pk/tests.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
-from django.conf import settings
-from django.db import DEFAULT_DB_ALIAS, transaction, IntegrityError
+from django.db import transaction, IntegrityError
from django.test import TestCase, skipIfDBFeature
from models import Employee, Business, Bar, Foo
diff --git a/tests/modeltests/delete/models.py b/tests/modeltests/delete/models.py
index ee9e99975f..f8b78eb7b7 100644
--- a/tests/modeltests/delete/models.py
+++ b/tests/modeltests/delete/models.py
@@ -1,4 +1,4 @@
-from django.db import models, IntegrityError
+from django.db import models
class R(models.Model):
diff --git a/tests/modeltests/field_subclassing/fields.py b/tests/modeltests/field_subclassing/fields.py
index 309648e3fd..d6e4980c90 100644
--- a/tests/modeltests/field_subclassing/fields.py
+++ b/tests/modeltests/field_subclassing/fields.py
@@ -1,4 +1,3 @@
-from django.core.exceptions import FieldError
from django.db import models
from django.utils import simplejson as json
from django.utils.encoding import force_unicode
diff --git a/tests/modeltests/field_subclassing/models.py b/tests/modeltests/field_subclassing/models.py
index b0d83365c5..c59c0d5d2c 100644
--- a/tests/modeltests/field_subclassing/models.py
+++ b/tests/modeltests/field_subclassing/models.py
@@ -5,7 +5,7 @@ Tests for field subclassing.
from django.db import models
from django.utils.encoding import force_unicode
-from fields import Small, SmallField, SmallerField, JSONField
+from fields import SmallField, SmallerField, JSONField
class MyModel(models.Model):
diff --git a/tests/modeltests/files/models.py b/tests/modeltests/files/models.py
index ca8965e15a..4134472748 100644
--- a/tests/modeltests/files/models.py
+++ b/tests/modeltests/files/models.py
@@ -9,7 +9,6 @@ import random
import tempfile
from django.db import models
-from django.core.files.base import ContentFile
from django.core.files.storage import FileSystemStorage
diff --git a/tests/modeltests/files/tests.py b/tests/modeltests/files/tests.py
index 885f787984..e8e7a761f0 100644
--- a/tests/modeltests/files/tests.py
+++ b/tests/modeltests/files/tests.py
@@ -1,7 +1,6 @@
from __future__ import with_statement
import shutil
-import sys
import tempfile
from django.core.cache import cache
diff --git a/tests/modeltests/fixtures/models.py b/tests/modeltests/fixtures/models.py
index c8fd6a6fac..45f1f69d95 100644
--- a/tests/modeltests/fixtures/models.py
+++ b/tests/modeltests/fixtures/models.py
@@ -8,11 +8,10 @@ in the application directory, or in one of the directories named in the
``FIXTURE_DIRS`` setting.
"""
+from django.db import models
from django.contrib.auth.models import Permission
from django.contrib.contenttypes import generic
from django.contrib.contenttypes.models import ContentType
-from django.db import models, DEFAULT_DB_ALIAS
-from django.conf import settings
class Category(models.Model):
diff --git a/tests/modeltests/fixtures/tests.py b/tests/modeltests/fixtures/tests.py
index 31f72f02ca..c335ffbc27 100644
--- a/tests/modeltests/fixtures/tests.py
+++ b/tests/modeltests/fixtures/tests.py
@@ -1,13 +1,10 @@
import StringIO
-import sys
-from django.conf import settings
from django.contrib.sites.models import Site
from django.core import management
-from django.db import DEFAULT_DB_ALIAS
from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
-from models import Article, Blog, Book, Category, Person, Spy, Tag, Visa
+from models import Article, Book, Spy, Tag, Visa
class TestCaseFixtureLoadingTests(TestCase):
diff --git a/tests/modeltests/fixtures_model_package/models/__init__.py b/tests/modeltests/fixtures_model_package/models/__init__.py
index c0450b27bf..5cb0e4a759 100644
--- a/tests/modeltests/fixtures_model_package/models/__init__.py
+++ b/tests/modeltests/fixtures_model_package/models/__init__.py
@@ -1,5 +1,4 @@
from django.db import models
-from django.conf import settings
class Article(models.Model):
headline = models.CharField(max_length=100, default='Default headline')
diff --git a/tests/modeltests/force_insert_update/models.py b/tests/modeltests/force_insert_update/models.py
index 9516be7718..e617aa228a 100644
--- a/tests/modeltests/force_insert_update/models.py
+++ b/tests/modeltests/force_insert_update/models.py
@@ -2,7 +2,7 @@
Tests for forcing insert and update queries (instead of Django's normal
automatic behaviour).
"""
-from django.db import models, transaction, IntegrityError
+from django.db import models
class Counter(models.Model):
name = models.CharField(max_length = 10)
diff --git a/tests/modeltests/get_object_or_404/models.py b/tests/modeltests/get_object_or_404/models.py
index eb3cd8254d..f62dd0cf30 100644
--- a/tests/modeltests/get_object_or_404/models.py
+++ b/tests/modeltests/get_object_or_404/models.py
@@ -11,8 +11,6 @@ performing a ``filter()`` lookup and raising a ``Http404`` exception if a
"""
from django.db import models
-from django.http import Http404
-from django.shortcuts import get_object_or_404, get_list_or_404
class Author(models.Model):
name = models.CharField(max_length=50)
diff --git a/tests/modeltests/get_or_create/models.py b/tests/modeltests/get_or_create/models.py
index db5719b79e..14f55f8d96 100644
--- a/tests/modeltests/get_or_create/models.py
+++ b/tests/modeltests/get_or_create/models.py
@@ -6,7 +6,7 @@ given parameters. If an object isn't found, it creates one with the given
parameters.
"""
-from django.db import models, IntegrityError
+from django.db import models
class Person(models.Model):
first_name = models.CharField(max_length=100)
diff --git a/tests/modeltests/lookup/models.py b/tests/modeltests/lookup/models.py
index d807531850..82434bb81d 100644
--- a/tests/modeltests/lookup/models.py
+++ b/tests/modeltests/lookup/models.py
@@ -4,8 +4,7 @@
This demonstrates features of the database API.
"""
-from django.db import models, DEFAULT_DB_ALIAS, connection
-from django.conf import settings
+from django.db import models
class Author(models.Model):
name = models.CharField(max_length=100)
diff --git a/tests/modeltests/lookup/tests.py b/tests/modeltests/lookup/tests.py
index 3f40bf10f5..b05227c9a1 100644
--- a/tests/modeltests/lookup/tests.py
+++ b/tests/modeltests/lookup/tests.py
@@ -1,7 +1,6 @@
from datetime import datetime
from operator import attrgetter
from django.core.exceptions import FieldError
-from django.db import connection
from django.test import TestCase, skipUnlessDBFeature
from models import Author, Article, Tag
diff --git a/tests/modeltests/m2m_through/tests.py b/tests/modeltests/m2m_through/tests.py
index 807e952949..814e54fc25 100644
--- a/tests/modeltests/m2m_through/tests.py
+++ b/tests/modeltests/m2m_through/tests.py
@@ -3,8 +3,8 @@ from operator import attrgetter
from django.test import TestCase
-from models import Person, Group, Membership, CustomMembership, \
- TestNoDefaultsOrNulls, PersonSelfRefM2M, Friendship
+from models import (Person, Group, Membership, CustomMembership,
+ PersonSelfRefM2M, Friendship)
class M2mThroughTests(TestCase):
diff --git a/tests/modeltests/many_to_one/tests.py b/tests/modeltests/many_to_one/tests.py
index 83e984dc6d..9f60c21f47 100644
--- a/tests/modeltests/many_to_one/tests.py
+++ b/tests/modeltests/many_to_one/tests.py
@@ -2,7 +2,7 @@ from copy import deepcopy
from datetime import datetime
from django.test import TestCase
-from django.core.exceptions import FieldError, MultipleObjectsReturned
+from django.core.exceptions import MultipleObjectsReturned
from models import Article, Reporter
diff --git a/tests/modeltests/model_forms/models.py b/tests/modeltests/model_forms/models.py
index 7204b285b7..5dcc0391ce 100644
--- a/tests/modeltests/model_forms/models.py
+++ b/tests/modeltests/model_forms/models.py
@@ -7,7 +7,6 @@ and the examples are probably a poor fit for the ``ModelForm`` syntax. In other
words, most of these tests should be rewritten.
"""
-import os
import tempfile
from django.db import models
diff --git a/tests/modeltests/model_formsets/tests.py b/tests/modeltests/model_formsets/tests.py
index 6303e6d086..34f8d47755 100644
--- a/tests/modeltests/model_formsets/tests.py
+++ b/tests/modeltests/model_formsets/tests.py
@@ -10,7 +10,7 @@ from django.forms.models import (_get_foreign_key, inlineformset_factory,
from django.test import TestCase, skipUnlessDBFeature
from modeltests.model_formsets.models import (
- Author, BetterAuthor, Book, BookWithCustomPK, Editor,
+ Author, BetterAuthor, Book, BookWithCustomPK,
BookWithOptionalAltEditor, AlternateBook, AuthorMeeting, CustomPrimaryKey,
Place, Owner, Location, OwnerProfile, Restaurant, Product, Price,
MexicanRestaurant, ClassyMexicanRestaurant, Repository, Revision,
diff --git a/tests/modeltests/mutually_referential/tests.py b/tests/modeltests/mutually_referential/tests.py
index 101d67cfa6..365c741ea5 100644
--- a/tests/modeltests/mutually_referential/tests.py
+++ b/tests/modeltests/mutually_referential/tests.py
@@ -1,5 +1,5 @@
from django.test import TestCase
-from models import Parent, Child
+from models import Parent
class MutuallyReferentialTests(TestCase):
diff --git a/tests/modeltests/one_to_one/models.py b/tests/modeltests/one_to_one/models.py
index f2637350ca..246c3fc364 100644
--- a/tests/modeltests/one_to_one/models.py
+++ b/tests/modeltests/one_to_one/models.py
@@ -6,7 +6,7 @@ To define a one-to-one relationship, use ``OneToOneField()``.
In this example, a ``Place`` optionally can be a ``Restaurant``.
"""
-from django.db import models, transaction, IntegrityError
+from django.db import models
class Place(models.Model):
name = models.CharField(max_length=50)
diff --git a/tests/modeltests/pagination/tests.py b/tests/modeltests/pagination/tests.py
index eaee466913..11290521bd 100644
--- a/tests/modeltests/pagination/tests.py
+++ b/tests/modeltests/pagination/tests.py
@@ -1,5 +1,4 @@
from datetime import datetime
-from operator import attrgetter
from django.core.paginator import Paginator, InvalidPage, EmptyPage
from django.test import TestCase
diff --git a/tests/modeltests/proxy_model_inheritance/tests.py b/tests/modeltests/proxy_model_inheritance/tests.py
index 7426f41de5..546c5077e2 100644
--- a/tests/modeltests/proxy_model_inheritance/tests.py
+++ b/tests/modeltests/proxy_model_inheritance/tests.py
@@ -9,7 +9,7 @@ apps and calls syncdb, then verifies that the table has been created.
import os
import sys
-from django.conf import settings, Settings
+from django.conf import settings
from django.core.management import call_command
from django.db.models.loading import load_app
from django.test import TransactionTestCase
diff --git a/tests/modeltests/proxy_models/models.py b/tests/modeltests/proxy_models/models.py
index 90d54d94dd..c033117bf8 100644
--- a/tests/modeltests/proxy_models/models.py
+++ b/tests/modeltests/proxy_models/models.py
@@ -4,11 +4,8 @@ they will take data directly from the table of their base class table rather
than using a new table of their own. This allows them to act as simple proxies,
providing a modified interface to the data from the base class.
"""
-
-from django.contrib.contenttypes.models import ContentType
from django.db import models
-
# A couple of managers for testing managing overriding in proxy model cases.
class PersonManager(models.Manager):
diff --git a/tests/modeltests/serializers/tests.py b/tests/modeltests/serializers/tests.py
index 013438ed29..4a7e0a2086 100644
--- a/tests/modeltests/serializers/tests.py
+++ b/tests/modeltests/serializers/tests.py
@@ -9,8 +9,8 @@ from django.db import transaction
from django.test import TestCase, TransactionTestCase, Approximate
from django.utils import simplejson, unittest
-from models import Category, Author, Article, AuthorProfile, Actor, \
- Movie, Score, Player, Team
+from models import (Category, Author, Article, AuthorProfile,
+ Actor, Movie, Score, Player, Team)
class SerializerRegistrationTests(unittest.TestCase):
def setUp(self):
diff --git a/tests/modeltests/transactions/models.py b/tests/modeltests/transactions/models.py
index d957fe174c..b2ae39648a 100644
--- a/tests/modeltests/transactions/models.py
+++ b/tests/modeltests/transactions/models.py
@@ -7,7 +7,7 @@ commit-on-success behavior. Alternatively, you can manage the transaction
manually.
"""
-from django.db import models, DEFAULT_DB_ALIAS
+from django.db import models
class Reporter(models.Model):
first_name = models.CharField(max_length=30)
diff --git a/tests/modeltests/transactions/tests.py b/tests/modeltests/transactions/tests.py
index db58b80e29..5cebe679a4 100644
--- a/tests/modeltests/transactions/tests.py
+++ b/tests/modeltests/transactions/tests.py
@@ -1,9 +1,6 @@
from __future__ import with_statement
-import sys
-
-from django.db import connection, transaction, IntegrityError, DEFAULT_DB_ALIAS
-from django.conf import settings
+from django.db import connection, transaction, IntegrityError
from django.test import TransactionTestCase, skipUnlessDBFeature
from models import Reporter
diff --git a/tests/modeltests/unmanaged_models/tests.py b/tests/modeltests/unmanaged_models/tests.py
index dee3799234..b9817efc08 100644
--- a/tests/modeltests/unmanaged_models/tests.py
+++ b/tests/modeltests/unmanaged_models/tests.py
@@ -1,7 +1,6 @@
from django.test import TestCase
from django.db import connection
-from models import Unmanaged1, Unmanaged2, Managed1
-from models import A01, A02, B01, B02, C01, C02
+from models import A01, A02, B01, B02, C01, C02, Unmanaged2, Managed1
class SimpleTests(TestCase):
diff --git a/tests/modeltests/validation/models.py b/tests/modeltests/validation/models.py
index b2b3ffcd7c..bf0430f79e 100644
--- a/tests/modeltests/validation/models.py
+++ b/tests/modeltests/validation/models.py
@@ -1,7 +1,6 @@
from datetime import datetime
from django.core.exceptions import ValidationError
from django.db import models
-from django.test import TestCase
def validate_answer_to_universe(value):
diff --git a/tests/modeltests/validation/test_unique.py b/tests/modeltests/validation/test_unique.py
index 176a5dba96..c0a0530d6b 100644
--- a/tests/modeltests/validation/test_unique.py
+++ b/tests/modeltests/validation/test_unique.py
@@ -2,9 +2,7 @@ from __future__ import with_statement
import datetime
-from django.conf import settings
from django.core.exceptions import ValidationError
-from django.db import connection
from django.test import TestCase
from django.utils import unittest
diff --git a/tests/modeltests/validation/validators.py b/tests/modeltests/validation/validators.py
index 6a7d833555..30ce66140f 100644
--- a/tests/modeltests/validation/validators.py
+++ b/tests/modeltests/validation/validators.py
@@ -1,5 +1,3 @@
-from django.utils.unittest import TestCase
-
from modeltests.validation import ValidationTestCase
from models import *
diff --git a/tests/regressiontests/admin_filters/tests.py b/tests/regressiontests/admin_filters/tests.py
index 5095abbb9f..b4c4f34e75 100644
--- a/tests/regressiontests/admin_filters/tests.py
+++ b/tests/regressiontests/admin_filters/tests.py
@@ -1,5 +1,3 @@
-from __future__ import with_statement
-
import datetime
from django.core.exceptions import ImproperlyConfigured
diff --git a/tests/regressiontests/admin_validation/tests.py b/tests/regressiontests/admin_validation/tests.py
index 9e50a8b112..d114414135 100644
--- a/tests/regressiontests/admin_validation/tests.py
+++ b/tests/regressiontests/admin_validation/tests.py
@@ -1,9 +1,10 @@
-from django.contrib import admin
from django import forms
-from django.contrib.admin.validation import validate, validate_inline, \
- ImproperlyConfigured
+from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
+from django.contrib import admin
+from django.contrib.admin.validation import validate, validate_inline
+
from models import Song, Book, Album, TwoAlbumFKAndAnE, State, City
class SongForm(forms.ModelForm):
diff --git a/tests/regressiontests/bash_completion/management/commands/test_command.py b/tests/regressiontests/bash_completion/management/commands/test_command.py
index 5cb8820a8f..0f5750645c 100644
--- a/tests/regressiontests/bash_completion/management/commands/test_command.py
+++ b/tests/regressiontests/bash_completion/management/commands/test_command.py
@@ -1,5 +1,4 @@
-import sys, os
-from optparse import OptionParser, make_option
+from optparse import make_option
from django.core.management.base import BaseCommand
diff --git a/tests/regressiontests/cache/tests.py b/tests/regressiontests/cache/tests.py
index d206b462bc..afb5a15b41 100644
--- a/tests/regressiontests/cache/tests.py
+++ b/tests/regressiontests/cache/tests.py
@@ -2,7 +2,6 @@
# Unit tests for cache framework
# Uses whatever cache backend is set in the test settings file.
-from __future__ import with_statement
import hashlib
import os
diff --git a/tests/regressiontests/comment_tests/models.py b/tests/regressiontests/comment_tests/models.py
index 8877ea1155..dc6c842ab6 100644
--- a/tests/regressiontests/comment_tests/models.py
+++ b/tests/regressiontests/comment_tests/models.py
@@ -30,5 +30,5 @@ class Entry(models.Model):
return self.title
class Book(models.Model):
- dewey_decimal = models.DecimalField(primary_key = True, decimal_places=2, max_digits=5)
+ dewey_decimal = models.DecimalField(primary_key=True, decimal_places=2, max_digits=5)
\ No newline at end of file
diff --git a/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py b/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py
index 4177163f2a..ac9bde6fed 100644
--- a/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py
+++ b/tests/regressiontests/comment_tests/tests/comment_utils_moderators_tests.py
@@ -1,9 +1,11 @@
-from regressiontests.comment_tests.tests import CommentTestCase, CT, Site
-from django.contrib.comments.forms import CommentForm
+from django.core import mail
+
from django.contrib.comments.models import Comment
-from django.contrib.comments.moderation import moderator, CommentModerator, AlreadyModerated
+from django.contrib.comments.moderation import (moderator, CommentModerator,
+ AlreadyModerated)
+
from regressiontests.comment_tests.models import Entry
-from django.core import mail
+from regressiontests.comment_tests.tests import CommentTestCase
class EntryModerator1(CommentModerator):
email_notification = True
diff --git a/tests/regressiontests/comment_tests/tests/feed_tests.py b/tests/regressiontests/comment_tests/tests/feed_tests.py
index 2dccbcd0f7..4497f95c6e 100644
--- a/tests/regressiontests/comment_tests/tests/feed_tests.py
+++ b/tests/regressiontests/comment_tests/tests/feed_tests.py
@@ -1,7 +1,3 @@
-import warnings
-
-from django.test.utils import get_warnings_state, restore_warnings_state
-
from regressiontests.comment_tests.tests import CommentTestCase
diff --git a/tests/regressiontests/comment_tests/tests/templatetag_tests.py b/tests/regressiontests/comment_tests/tests/templatetag_tests.py
index 0ead6c2257..0ee34ac670 100644
--- a/tests/regressiontests/comment_tests/tests/templatetag_tests.py
+++ b/tests/regressiontests/comment_tests/tests/templatetag_tests.py
@@ -1,5 +1,4 @@
from django.contrib.comments.forms import CommentForm
-from django.contrib.comments.models import Comment
from django.contrib.contenttypes.models import ContentType
from django.template import Template, Context
from regressiontests.comment_tests.models import Article, Author
diff --git a/tests/regressiontests/csrf_tests/tests.py b/tests/regressiontests/csrf_tests/tests.py
index b3238a7dd3..c5f9f3632d 100644
--- a/tests/regressiontests/csrf_tests/tests.py
+++ b/tests/regressiontests/csrf_tests/tests.py
@@ -1,6 +1,5 @@
# -*- coding: utf-8 -*-
from __future__ import with_statement
-import warnings
from django.test import TestCase
from django.http import HttpRequest, HttpResponse
diff --git a/tests/regressiontests/datatypes/tests.py b/tests/regressiontests/datatypes/tests.py
index e161be9344..2d40fecfd1 100644
--- a/tests/regressiontests/datatypes/tests.py
+++ b/tests/regressiontests/datatypes/tests.py
@@ -1,7 +1,5 @@
import datetime
-from django.conf import settings
-from django.db import DEFAULT_DB_ALIAS
from django.test import TestCase, skipIfDBFeature
from django.utils import tzinfo
diff --git a/tests/regressiontests/defer_regress/models.py b/tests/regressiontests/defer_regress/models.py
index 4e4ab0a515..1d1a2247de 100644
--- a/tests/regressiontests/defer_regress/models.py
+++ b/tests/regressiontests/defer_regress/models.py
@@ -2,9 +2,7 @@
Regression tests for defer() / only() behavior.
"""
-from django.conf import settings
-from django.contrib.contenttypes.models import ContentType
-from django.db import connection, models
+from django.db import models
class Item(models.Model):
name = models.CharField(max_length=15)
diff --git a/tests/regressiontests/defer_regress/tests.py b/tests/regressiontests/defer_regress/tests.py
index b1d88e3f36..8bd9579ff4 100644
--- a/tests/regressiontests/defer_regress/tests.py
+++ b/tests/regressiontests/defer_regress/tests.py
@@ -1,9 +1,7 @@
from operator import attrgetter
-from django.conf import settings
from django.contrib.contenttypes.models import ContentType
from django.contrib.sessions.backends.db import SessionStore
-from django.db import connection
from django.db.models import Count
from django.db.models.loading import cache
from django.test import TestCase
diff --git a/tests/regressiontests/delete_regress/tests.py b/tests/regressiontests/delete_regress/tests.py
index ec26676f1f..22b4833a8f 100644
--- a/tests/regressiontests/delete_regress/tests.py
+++ b/tests/regressiontests/delete_regress/tests.py
@@ -1,11 +1,11 @@
import datetime
from django.conf import settings
-from django.db import backend, connection, transaction, DEFAULT_DB_ALIAS
+from django.db import backend, transaction, DEFAULT_DB_ALIAS
from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
from models import (Book, Award, AwardNote, Person, Child, Toy, PlayedWith,
- PlayedWithNote, Contact, Email, Researcher, Food, Eaten,
+ PlayedWithNote, Email, Researcher, Food, Eaten,
Policy, Version, Location, Item)
diff --git a/tests/regressiontests/expressions_regress/tests.py b/tests/regressiontests/expressions_regress/tests.py
index a900c6c5fd..497a8439b5 100644
--- a/tests/regressiontests/expressions_regress/tests.py
+++ b/tests/regressiontests/expressions_regress/tests.py
@@ -3,8 +3,7 @@ Spanning tests for all the operations that F() expressions can perform.
"""
import datetime
-from django.conf import settings
-from django.db import models, connection
+from django.db import connection
from django.db.models import F
from django.test import TestCase, Approximate, skipUnlessDBFeature
diff --git a/tests/regressiontests/extra_regress/tests.py b/tests/regressiontests/extra_regress/tests.py
index ef7cbb8b9b..5f779be751 100644
--- a/tests/regressiontests/extra_regress/tests.py
+++ b/tests/regressiontests/extra_regress/tests.py
@@ -3,8 +3,7 @@ from django.test import TestCase
from django.utils.datastructures import SortedDict
from django.contrib.auth.models import User
-from regressiontests.extra_regress.models import TestObject, Order, \
- RevisionableModel
+from regressiontests.extra_regress.models import TestObject, Order, RevisionableModel
import datetime
diff --git a/tests/regressiontests/file_storage/tests.py b/tests/regressiontests/file_storage/tests.py
index 917d2f36fc..40710ebd5d 100644
--- a/tests/regressiontests/file_storage/tests.py
+++ b/tests/regressiontests/file_storage/tests.py
@@ -18,7 +18,7 @@ except ImportError:
from django.conf import settings
from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured
-from django.core.files.base import ContentFile, File
+from django.core.files.base import ContentFile
from django.core.files.images import get_image_dimensions
from django.core.files.storage import FileSystemStorage, get_storage_class
from django.core.files.uploadedfile import UploadedFile
diff --git a/tests/regressiontests/file_uploads/tests.py b/tests/regressiontests/file_uploads/tests.py
index 6d79e2a451..2be423e028 100644
--- a/tests/regressiontests/file_uploads/tests.py
+++ b/tests/regressiontests/file_uploads/tests.py
@@ -9,7 +9,7 @@ from StringIO import StringIO
from django.core.files import temp as tempfile
from django.core.files.uploadedfile import SimpleUploadedFile
-from django.http.multipartparser import MultiPartParser, MultiPartParserError
+from django.http.multipartparser import MultiPartParser
from django.test import TestCase, client
from django.utils import simplejson
from django.utils import unittest
diff --git a/tests/regressiontests/fixtures_regress/models.py b/tests/regressiontests/fixtures_regress/models.py
index 2dfb55035a..b353f80940 100644
--- a/tests/regressiontests/fixtures_regress/models.py
+++ b/tests/regressiontests/fixtures_regress/models.py
@@ -1,6 +1,5 @@
-from django.db import models, DEFAULT_DB_ALIAS, connection
+from django.db import models
from django.contrib.auth.models import User
-from django.conf import settings
class Animal(models.Model):
diff --git a/tests/regressiontests/fixtures_regress/tests.py b/tests/regressiontests/fixtures_regress/tests.py
index 3dc4edee55..a565ec96e0 100644
--- a/tests/regressiontests/fixtures_regress/tests.py
+++ b/tests/regressiontests/fixtures_regress/tests.py
@@ -2,7 +2,6 @@
# Unittests for fixtures.
import os
import re
-import sys
try:
from cStringIO import StringIO
except ImportError:
@@ -13,8 +12,8 @@ from django.core.management.commands.dumpdata import sort_dependencies
from django.core.management.base import CommandError
from django.db.models import signals
from django.db import transaction
-from django.test import TestCase, TransactionTestCase, skipIfDBFeature, \
- skipUnlessDBFeature
+from django.test import (TestCase, TransactionTestCase, skipIfDBFeature,
+ skipUnlessDBFeature)
from models import Animal, Stuff
from models import Absolute, Parent, Child
diff --git a/tests/regressiontests/forms/localflavor/cl.py b/tests/regressiontests/forms/localflavor/cl.py
index b2b4562a53..59e4824db9 100644
--- a/tests/regressiontests/forms/localflavor/cl.py
+++ b/tests/regressiontests/forms/localflavor/cl.py
@@ -1,5 +1,4 @@
from django.contrib.localflavor.cl.forms import CLRutField, CLRegionSelect
-from django.core.exceptions import ValidationError
from utils import LocalFlavorTestCase
diff --git a/tests/regressiontests/forms/localflavor/in_.py b/tests/regressiontests/forms/localflavor/in_.py
index 5a04fd1cf4..583998283d 100644
--- a/tests/regressiontests/forms/localflavor/in_.py
+++ b/tests/regressiontests/forms/localflavor/in_.py
@@ -1,5 +1,3 @@
-import warnings
-
from django.contrib.localflavor.in_.forms import (INZipCodeField,
INStateField, INStateSelect, INPhoneNumberField)
diff --git a/tests/regressiontests/forms/tests/fields.py b/tests/regressiontests/forms/tests/fields.py
index 67804134ac..506844d848 100644
--- a/tests/regressiontests/forms/tests/fields.py
+++ b/tests/regressiontests/forms/tests/fields.py
@@ -33,7 +33,6 @@ from functools import wraps
from django.core.files.uploadedfile import SimpleUploadedFile
from django.forms import *
-from django.forms.widgets import RadioFieldRenderer
from django.utils.unittest import TestCase
diff --git a/tests/regressiontests/forms/tests/forms.py b/tests/regressiontests/forms/tests/forms.py
index 04463cfb2c..ed783af819 100644
--- a/tests/regressiontests/forms/tests/forms.py
+++ b/tests/regressiontests/forms/tests/forms.py
@@ -1,8 +1,5 @@
# -*- coding: utf-8 -*-
import datetime
-from decimal import Decimal
-import re
-import time
from django.core.files.uploadedfile import SimpleUploadedFile
from django.forms import *
from django.http import QueryDict
diff --git a/tests/regressiontests/forms/tests/media.py b/tests/regressiontests/forms/tests/media.py
index bed5a816bf..71dc0a7b03 100644
--- a/tests/regressiontests/forms/tests/media.py
+++ b/tests/regressiontests/forms/tests/media.py
@@ -1,5 +1,4 @@
# -*- coding: utf-8 -*-
-from django.conf import settings
from django.forms import TextInput, Media, TextInput, CharField, Form, MultiWidget
from django.test import TestCase
from django.test.utils import override_settings
diff --git a/tests/regressiontests/forms/tests/models.py b/tests/regressiontests/forms/tests/models.py
index 3f548df982..5e1bd82640 100644
--- a/tests/regressiontests/forms/tests/models.py
+++ b/tests/regressiontests/forms/tests/models.py
@@ -3,7 +3,8 @@ import datetime
from django.core.files.uploadedfile import SimpleUploadedFile
from django.forms import Form, ModelForm, FileField, ModelChoiceField
from django.test import TestCase
-from regressiontests.forms.models import ChoiceModel, ChoiceOptionModel, ChoiceFieldModel, FileModel, Group, BoundaryModel, Defaults
+from regressiontests.forms.models import (ChoiceOptionModel, ChoiceFieldModel,
+ FileModel, Group, BoundaryModel, Defaults)
class ChoiceFieldForm(ModelForm):
diff --git a/tests/regressiontests/forms/tests/widgets.py b/tests/regressiontests/forms/tests/widgets.py
index 0a8a87949c..b4ceb2fcff 100644
--- a/tests/regressiontests/forms/tests/widgets.py
+++ b/tests/regressiontests/forms/tests/widgets.py
@@ -2,9 +2,6 @@
import copy
import datetime
-import re
-import time
-from decimal import Decimal
from django.conf import settings
from django.core.files.uploadedfile import SimpleUploadedFile
from django.forms import *
diff --git a/tests/regressiontests/generic_relations_regress/tests.py b/tests/regressiontests/generic_relations_regress/tests.py
index 45e86746e5..52731a9a43 100644
--- a/tests/regressiontests/generic_relations_regress/tests.py
+++ b/tests/regressiontests/generic_relations_regress/tests.py
@@ -1,5 +1,4 @@
from django.test import TestCase
-from django.contrib.contenttypes.models import ContentType
from django.db.models import Q
from models import *
diff --git a/tests/regressiontests/generic_views/base.py b/tests/regressiontests/generic_views/base.py
index fc5cf62e43..40490a421c 100644
--- a/tests/regressiontests/generic_views/base.py
+++ b/tests/regressiontests/generic_views/base.py
@@ -4,7 +4,6 @@ import unittest
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpResponse
from django.test import TestCase, RequestFactory
-from django.utils import simplejson
from django.views.generic import View, TemplateView, RedirectView
diff --git a/tests/regressiontests/generic_views/dates.py b/tests/regressiontests/generic_views/dates.py
index 5b784f6810..b9608d694f 100644
--- a/tests/regressiontests/generic_views/dates.py
+++ b/tests/regressiontests/generic_views/dates.py
@@ -1,5 +1,4 @@
import datetime
-import random
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
diff --git a/tests/regressiontests/generic_views/list.py b/tests/regressiontests/generic_views/list.py
index c41680c701..f5bf910894 100644
--- a/tests/regressiontests/generic_views/list.py
+++ b/tests/regressiontests/generic_views/list.py
@@ -2,7 +2,6 @@ from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
from regressiontests.generic_views.models import Author, Artist
-from regressiontests.generic_views.views import CustomPaginator
class ListViewTests(TestCase):
fixtures = ['generic-views-test-data.json']
diff --git a/tests/regressiontests/i18n/forms.py b/tests/regressiontests/i18n/forms.py
index 156441c6ab..600f252aa5 100644
--- a/tests/regressiontests/i18n/forms.py
+++ b/tests/regressiontests/i18n/forms.py
@@ -1,5 +1,6 @@
-from django import template, forms
+from django import forms
from django.forms.extras import SelectDateWidget
+
from models import Company
class I18nForm(forms.Form):
diff --git a/tests/regressiontests/i18n/patterns/urls/namespace.py b/tests/regressiontests/i18n/patterns/urls/namespace.py
index 878e08feae..0e703405cb 100644
--- a/tests/regressiontests/i18n/patterns/urls/namespace.py
+++ b/tests/regressiontests/i18n/patterns/urls/namespace.py
@@ -1,4 +1,4 @@
-from django.conf.urls.defaults import patterns, include, url
+from django.conf.urls.defaults import patterns, url
from django.utils.translation import ugettext_lazy as _
from django.views.generic import TemplateView
diff --git a/tests/regressiontests/i18n/patterns/urls/wrong.py b/tests/regressiontests/i18n/patterns/urls/wrong.py
index 3e45743cdf..40302fc98f 100644
--- a/tests/regressiontests/i18n/patterns/urls/wrong.py
+++ b/tests/regressiontests/i18n/patterns/urls/wrong.py
@@ -1,4 +1,4 @@
-from django.conf.urls.defaults import patterns, include, url
+from django.conf.urls.defaults import include, url
from django.conf.urls.i18n import i18n_patterns
from django.utils.translation import ugettext_lazy as _
diff --git a/tests/regressiontests/i18n/patterns/urls/wrong_namespace.py b/tests/regressiontests/i18n/patterns/urls/wrong_namespace.py
index 90ee2a0538..46ecfd0e7a 100644
--- a/tests/regressiontests/i18n/patterns/urls/wrong_namespace.py
+++ b/tests/regressiontests/i18n/patterns/urls/wrong_namespace.py
@@ -1,4 +1,4 @@
-from django.conf.urls.defaults import include, url
+from django.conf.urls.defaults import url
from django.conf.urls.i18n import i18n_patterns
from django.utils.translation import ugettext_lazy as _
from django.views.generic import TemplateView
diff --git a/tests/regressiontests/introspection/tests.py b/tests/regressiontests/introspection/tests.py
index e309a98681..4f5fb09193 100644
--- a/tests/regressiontests/introspection/tests.py
+++ b/tests/regressiontests/introspection/tests.py
@@ -1,6 +1,5 @@
from functools import update_wrapper
-from django.conf import settings
-from django.db import connection, DEFAULT_DB_ALIAS
+from django.db import connection
from django.test import TestCase, skipUnlessDBFeature
from models import Reporter, Article
diff --git a/tests/regressiontests/localflavor/tests.py b/tests/regressiontests/localflavor/tests.py
index 6a02d99004..6a15d463f7 100644
--- a/tests/regressiontests/localflavor/tests.py
+++ b/tests/regressiontests/localflavor/tests.py
@@ -1,7 +1,3 @@
-from django.test import TestCase
-from django.utils import unittest
-
-# just import your tests here
from au.tests import *
from mk.tests import *
from us.tests import *
diff --git a/tests/regressiontests/m2m_through_regress/models.py b/tests/regressiontests/m2m_through_regress/models.py
index 121ef22470..9eea2f4604 100644
--- a/tests/regressiontests/m2m_through_regress/models.py
+++ b/tests/regressiontests/m2m_through_regress/models.py
@@ -1,8 +1,6 @@
-from datetime import datetime
+from django.db import models
from django.contrib.auth.models import User
-from django.core import management
-from django.db import models
# Forward declared intermediate model
diff --git a/tests/regressiontests/max_lengths/tests.py b/tests/regressiontests/max_lengths/tests.py
index 59d98d6b8e..4d1f2bff9a 100644
--- a/tests/regressiontests/max_lengths/tests.py
+++ b/tests/regressiontests/max_lengths/tests.py
@@ -1,5 +1,5 @@
-from django.db import DatabaseError
from django.utils import unittest
+
from regressiontests.max_lengths.models import PersonWithDefaultMaxLengths, PersonWithCustomMaxLengths
class MaxLengthArgumentsTests(unittest.TestCase):
diff --git a/tests/regressiontests/middleware_exceptions/models.py b/tests/regressiontests/middleware_exceptions/models.py
index 137941ffae..e69de29bb2 100644
--- a/tests/regressiontests/middleware_exceptions/models.py
+++ b/tests/regressiontests/middleware_exceptions/models.py
@@ -1 +0,0 @@
-from django.db import models
diff --git a/tests/regressiontests/model_fields/imagefield.py b/tests/regressiontests/model_fields/imagefield.py
index dd79e7aefa..c952aa981a 100644
--- a/tests/regressiontests/model_fields/imagefield.py
+++ b/tests/regressiontests/model_fields/imagefield.py
@@ -2,12 +2,11 @@ import os
import shutil
from django.core.files import File
-from django.core.files.base import ContentFile
from django.core.files.images import ImageFile
from django.test import TestCase
-from models import Image, Person, PersonWithHeight, PersonWithHeightAndWidth, \
- PersonDimensionsFirst, PersonTwoImages, TestImageFieldFile
+from models import (Image, Person, PersonWithHeight, PersonWithHeightAndWidth,
+ PersonDimensionsFirst, PersonTwoImages, TestImageFieldFile)
# If PIL available, do these tests.
diff --git a/tests/regressiontests/model_fields/tests.py b/tests/regressiontests/model_fields/tests.py
index b42c0af784..4944db78e8 100644
--- a/tests/regressiontests/model_fields/tests.py
+++ b/tests/regressiontests/model_fields/tests.py
@@ -12,14 +12,10 @@ from models import Foo, Bar, Whiz, BigD, BigS, Image, BigInt, Post, NullBooleanM
# If PIL available, do these tests.
if Image:
- from imagefield import \
- ImageFieldTests, \
- ImageFieldTwoDimensionsTests, \
- ImageFieldNoDimensionsTests, \
- ImageFieldOneDimensionTests, \
- ImageFieldDimensionsFirstTests, \
- ImageFieldUsingFileTests, \
- TwoImageFieldTests
+ from imagefield import (
+ ImageFieldTests, ImageFieldTwoDimensionsTests, TwoImageFieldTests,
+ ImageFieldNoDimensionsTests, ImageFieldOneDimensionTests,
+ ImageFieldDimensionsFirstTests, ImageFieldUsingFileTests)
class BasicFieldTests(test.TestCase):
diff --git a/tests/regressiontests/model_forms_regress/tests.py b/tests/regressiontests/model_forms_regress/tests.py
index 9817858afc..9860c2e1ad 100644
--- a/tests/regressiontests/model_forms_regress/tests.py
+++ b/tests/regressiontests/model_forms_regress/tests.py
@@ -8,8 +8,8 @@ from django.forms.models import (modelform_factory, ModelChoiceField,
from django.utils import unittest
from django.test import TestCase
-from models import Person, RealPerson, Triple, FilePathModel, Article, \
- Publication, CustomFF, Author, Author1, Homepage, Document, Edition
+from models import (Person, RealPerson, Triple, FilePathModel, Article,
+ Publication, CustomFF, Author, Author1, Homepage, Document, Edition)
class ModelMultipleChoiceFieldTests(TestCase):
diff --git a/tests/regressiontests/modeladmin/models.py b/tests/regressiontests/modeladmin/models.py
index 26eaaae07d..ae180a4936 100644
--- a/tests/regressiontests/modeladmin/models.py
+++ b/tests/regressiontests/modeladmin/models.py
@@ -1,6 +1,4 @@
# coding: utf-8
-from datetime import date
-
from django.db import models
from django.contrib.auth.models import User
diff --git a/tests/regressiontests/multiple_database/models.py b/tests/regressiontests/multiple_database/models.py
index ce71828700..8146c57ccb 100644
--- a/tests/regressiontests/multiple_database/models.py
+++ b/tests/regressiontests/multiple_database/models.py
@@ -1,4 +1,3 @@
-from django.conf import settings
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes import generic
diff --git a/tests/regressiontests/select_related_onetoone/tests.py b/tests/regressiontests/select_related_onetoone/tests.py
index ab35feccf1..3e7023acdf 100644
--- a/tests/regressiontests/select_related_onetoone/tests.py
+++ b/tests/regressiontests/select_related_onetoone/tests.py
@@ -1,5 +1,3 @@
-from django import db
-from django.conf import settings
from django.test import TestCase
from models import (User, UserProfile, UserStat, UserStatResult, StatDetails,
diff --git a/tests/regressiontests/serializers_regress/tests.py b/tests/regressiontests/serializers_regress/tests.py
index 90a438c43a..cd2ce3cc9a 100644
--- a/tests/regressiontests/serializers_regress/tests.py
+++ b/tests/regressiontests/serializers_regress/tests.py
@@ -15,10 +15,9 @@ try:
except ImportError:
from StringIO import StringIO
-from django.conf import settings
-from django.core import serializers, management
+from django.core import serializers
from django.core.serializers import SerializerDoesNotExist
-from django.db import transaction, DEFAULT_DB_ALIAS, connection
+from django.db import connection
from django.test import TestCase
from django.utils.functional import curry
diff --git a/tests/regressiontests/signals_regress/tests.py b/tests/regressiontests/signals_regress/tests.py
index 630b16fda4..332f5d9f5b 100644
--- a/tests/regressiontests/signals_regress/tests.py
+++ b/tests/regressiontests/signals_regress/tests.py
@@ -1,5 +1,3 @@
-import sys
-from StringIO import StringIO
from django.test import TestCase
from django.db import models
diff --git a/tests/regressiontests/syndication/tests.py b/tests/regressiontests/syndication/tests.py
index 2f90dc0348..66432981dd 100644
--- a/tests/regressiontests/syndication/tests.py
+++ b/tests/regressiontests/syndication/tests.py
@@ -1,5 +1,3 @@
-import datetime
-import warnings
from xml.dom import minidom
from django.contrib.syndication import views
diff --git a/tests/regressiontests/templates/custom.py b/tests/regressiontests/templates/custom.py
index 74c39ab7e0..d781874436 100644
--- a/tests/regressiontests/templates/custom.py
+++ b/tests/regressiontests/templates/custom.py
@@ -1,5 +1,3 @@
-from __future__ import with_statement
-
from django import template
from django.utils.unittest import TestCase
from templatetags import custom
diff --git a/tests/regressiontests/templates/loaders.py b/tests/regressiontests/templates/loaders.py
index 1773592521..c2ae0bd1fc 100644
--- a/tests/regressiontests/templates/loaders.py
+++ b/tests/regressiontests/templates/loaders.py
@@ -14,12 +14,10 @@ import pkg_resources
import imp
import StringIO
import os.path
-import warnings
from django.template import TemplateDoesNotExist, Context
from django.template.loaders.eggs import Loader as EggLoader
from django.template import loader
-from django.test.utils import get_warnings_state, restore_warnings_state
from django.utils import unittest
diff --git a/tests/regressiontests/templates/response.py b/tests/regressiontests/templates/response.py
index 6fc2dedcf4..a1257fee23 100644
--- a/tests/regressiontests/templates/response.py
+++ b/tests/regressiontests/templates/response.py
@@ -6,7 +6,7 @@ from django.utils import unittest
from django.test import RequestFactory, TestCase
from django.conf import settings
import django.template.context
-from django.template import Template, Context, RequestContext
+from django.template import Template, Context
from django.template.response import (TemplateResponse, SimpleTemplateResponse,
ContentNotRenderedError)
diff --git a/tests/regressiontests/templates/smartif.py b/tests/regressiontests/templates/smartif.py
index 2ce2df3c91..3a705ca663 100644
--- a/tests/regressiontests/templates/smartif.py
+++ b/tests/regressiontests/templates/smartif.py
@@ -1,4 +1,4 @@
-from django.template.smartif import IfParser, Literal
+from django.template.smartif import IfParser
from django.utils import unittest
class SmartIfTests(unittest.TestCase):
diff --git a/tests/regressiontests/templates/tests.py b/tests/regressiontests/templates/tests.py
index 8ea462e378..2481792db9 100644
--- a/tests/regressiontests/templates/tests.py
+++ b/tests/regressiontests/templates/tests.py
@@ -15,12 +15,12 @@ import warnings
from urlparse import urljoin
from django import template
-from django.template import base as template_base
+from django.template import base as template_base, RequestContext
from django.core import urlresolvers
from django.template import loader
from django.template.loaders import app_directories, filesystem, cached
-from django.test.utils import get_warnings_state, restore_warnings_state,\
- setup_test_template_loader, restore_template_loaders
+from django.test.utils import (get_warnings_state, restore_warnings_state,
+ setup_test_template_loader, restore_template_loaders)
from django.utils import unittest
from django.utils.formats import date_format
from django.utils.translation import activate, deactivate, ugettext as _
diff --git a/tests/regressiontests/test_utils/tests.py b/tests/regressiontests/test_utils/tests.py
index 673295be37..a35b0bcd04 100644
--- a/tests/regressiontests/test_utils/tests.py
+++ b/tests/regressiontests/test_utils/tests.py
@@ -1,8 +1,6 @@
from __future__ import with_statement
-import sys
-
-from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
+from django.test import TestCase, skipUnlessDBFeature
from django.utils.unittest import skip
from models import Person
diff --git a/tests/regressiontests/urlpatterns_reverse/middleware.py b/tests/regressiontests/urlpatterns_reverse/middleware.py
index cd3c045159..7bc42f8df4 100644
--- a/tests/regressiontests/urlpatterns_reverse/middleware.py
+++ b/tests/regressiontests/urlpatterns_reverse/middleware.py
@@ -1,5 +1,3 @@
-from django.core.urlresolvers import set_urlconf
-
import urlconf_inner
class ChangeURLconfMiddleware(object):
diff --git a/tests/regressiontests/urlpatterns_reverse/tests.py b/tests/regressiontests/urlpatterns_reverse/tests.py
index f447adf4cc..63ca6f5140 100644
--- a/tests/regressiontests/urlpatterns_reverse/tests.py
+++ b/tests/regressiontests/urlpatterns_reverse/tests.py
@@ -3,9 +3,8 @@ Unit tests for reverse URL lookups.
"""
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist
-from django.core.urlresolvers import reverse, resolve, NoReverseMatch,\
- Resolver404, ResolverMatch,\
- RegexURLResolver, RegexURLPattern
+from django.core.urlresolvers import (reverse, resolve, NoReverseMatch,
+ Resolver404, ResolverMatch, RegexURLResolver, RegexURLPattern)
from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect
from django.shortcuts import redirect
from django.test import TestCase
diff --git a/tests/regressiontests/utils/jslex.py b/tests/regressiontests/utils/jslex.py
index 08e8386831..7cd93ca36d 100644
--- a/tests/regressiontests/utils/jslex.py
+++ b/tests/regressiontests/utils/jslex.py
@@ -2,7 +2,6 @@
# encoding: utf-8
# originally from https://bitbucket.org/ned/jslex
-import difflib
from django.test import TestCase
from django.utils.jslex import JsLexer, prepare_js_for_gettext
diff --git a/tests/regressiontests/views/tests/debug.py b/tests/regressiontests/views/tests/debug.py
index 79af253d7c..012c1c6f90 100644
--- a/tests/regressiontests/views/tests/debug.py
+++ b/tests/regressiontests/views/tests/debug.py
@@ -9,7 +9,6 @@ from django.test import TestCase, RequestFactory
from django.core.urlresolvers import reverse
from django.template import TemplateSyntaxError
from django.views.debug import ExceptionReporter
-from django.core.exceptions import ImproperlyConfigured
from django.core import mail
from regressiontests.views import BrokenException, except_args
diff --git a/tests/regressiontests/views/tests/defaults.py b/tests/regressiontests/views/tests/defaults.py
index c7c295a642..6378cf9c99 100644
--- a/tests/regressiontests/views/tests/defaults.py
+++ b/tests/regressiontests/views/tests/defaults.py
@@ -1,6 +1,3 @@
-from os import path
-
-from django.conf import settings
from django.test import TestCase
from django.contrib.contenttypes.models import ContentType