summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--django/apps/config.py5
-rw-r--r--django/apps/registry.py2
-rw-r--r--django/conf/project_template/project_name/settings.py3
-rw-r--r--django/conf/project_template/project_name/wsgi.py4
-rw-r--r--django/contrib/admin/actions.py4
-rw-r--r--django/contrib/admin/apps.py2
-rw-r--r--django/contrib/admin/checks.py8
-rw-r--r--django/contrib/admin/filters.py14
-rw-r--r--django/contrib/admin/forms.py1
-rw-r--r--django/contrib/admin/helpers.py11
-rw-r--r--django/contrib/admin/migrations/0001_initial.py4
-rw-r--r--django/contrib/admin/models.py9
-rw-r--r--django/contrib/admin/options.py40
-rw-r--r--django/contrib/admin/sites.py15
-rw-r--r--django/contrib/admin/templatetags/admin_list.py19
-rw-r--r--django/contrib/admin/utils.py2
-rw-r--r--django/contrib/admin/views/main.py26
-rw-r--r--django/contrib/admin/widgets.py12
-rw-r--r--django/contrib/admindocs/apps.py1
-rw-r--r--django/contrib/admindocs/middleware.py2
-rw-r--r--django/contrib/admindocs/utils.py5
-rw-r--r--django/contrib/admindocs/views.py18
-rw-r--r--django/contrib/auth/admin.py16
-rw-r--r--django/contrib/auth/apps.py2
-rw-r--r--django/contrib/auth/backends.py1
-rw-r--r--django/contrib/auth/decorators.py3
-rw-r--r--django/contrib/auth/forms.py13
-rw-r--r--django/contrib/auth/handlers/modwsgi.py2
-rw-r--r--django/contrib/auth/hashers.py14
-rw-r--r--django/contrib/auth/migrations/0001_initial.py4
-rw-r--r--django/contrib/auth/migrations/0002_alter_permission_name_max_length.py2
-rw-r--r--django/contrib/auth/migrations/0003_alter_user_email_max_length.py2
-rw-r--r--django/contrib/auth/migrations/0004_alter_user_username_opts.py2
-rw-r--r--django/contrib/auth/migrations/0005_alter_user_last_login_null.py2
-rw-r--r--django/contrib/auth/models.py19
-rw-r--r--django/contrib/auth/tests/backend_alias.py4
-rw-r--r--django/contrib/auth/tests/custom_user.py11
-rw-r--r--django/contrib/auth/tests/settings.py1
-rw-r--r--django/contrib/auth/tests/test_auth_backends.py11
-rw-r--r--django/contrib/auth/tests/test_basic.py2
-rw-r--r--django/contrib/auth/tests/test_context_processors.py4
-rw-r--r--django/contrib/auth/tests/test_forms.py12
-rw-r--r--django/contrib/auth/tests/test_handlers.py9
-rw-r--r--django/contrib/auth/tests/test_hashers.py10
-rw-r--r--django/contrib/auth/tests/test_management.py21
-rw-r--r--django/contrib/auth/tests/test_models.py4
-rw-r--r--django/contrib/auth/tests/test_signals.py3
-rw-r--r--django/contrib/auth/tests/test_templates.py7
-rw-r--r--django/contrib/auth/tests/test_tokens.py4
-rw-r--r--django/contrib/auth/tests/test_views.py27
-rw-r--r--django/contrib/auth/tests/urls.py10
-rw-r--r--django/contrib/auth/tests/urls_admin.py4
-rw-r--r--django/contrib/auth/tokens.py5
-rw-r--r--django/contrib/auth/views.py24
-rw-r--r--django/contrib/contenttypes/admin.py2
-rw-r--r--django/contrib/contenttypes/checks.py2
-rw-r--r--django/contrib/contenttypes/fields.py9
-rw-r--r--django/contrib/contenttypes/forms.py2
-rw-r--r--django/contrib/contenttypes/migrations/0001_initial.py2
-rw-r--r--django/contrib/contenttypes/migrations/0002_remove_content_type_name.py2
-rw-r--r--django/contrib/contenttypes/models.py2
-rw-r--r--django/contrib/contenttypes/tests/tests.py7
-rw-r--r--django/contrib/flatpages/admin.py2
-rw-r--r--django/contrib/flatpages/apps.py1
-rw-r--r--django/contrib/flatpages/middleware.py2
-rw-r--r--django/contrib/flatpages/migrations/0001_initial.py2
-rw-r--r--django/contrib/flatpages/models.py4
-rw-r--r--django/contrib/flatpages/templatetags/flatpages.py1
-rw-r--r--django/contrib/flatpages/tests/settings.py1
-rw-r--r--django/contrib/flatpages/tests/test_csrf.py3
-rw-r--r--django/contrib/flatpages/tests/test_models.py2
-rw-r--r--django/contrib/flatpages/tests/test_templatetags.py2
-rw-r--r--django/contrib/gis/admin/options.py2
-rw-r--r--django/contrib/gis/admin/widgets.py8
-rw-r--r--django/contrib/gis/apps.py1
-rw-r--r--django/contrib/gis/db/backends/mysql/base.py3
-rw-r--r--django/contrib/gis/db/backends/mysql/features.py3
-rw-r--r--django/contrib/gis/db/backends/mysql/operations.py3
-rw-r--r--django/contrib/gis/db/backends/mysql/schema.py2
-rw-r--r--django/contrib/gis/db/backends/oracle/adapter.py1
-rw-r--r--django/contrib/gis/db/backends/oracle/base.py3
-rw-r--r--django/contrib/gis/db/backends/oracle/features.py3
-rw-r--r--django/contrib/gis/db/backends/oracle/introspection.py4
-rw-r--r--django/contrib/gis/db/backends/oracle/operations.py4
-rw-r--r--django/contrib/gis/db/backends/postgis/base.py5
-rw-r--r--django/contrib/gis/db/backends/postgis/features.py5
-rw-r--r--django/contrib/gis/db/backends/postgis/introspection.py3
-rw-r--r--django/contrib/gis/db/backends/postgis/models.py2
-rw-r--r--django/contrib/gis/db/backends/postgis/operations.py6
-rw-r--r--django/contrib/gis/db/backends/spatialite/adapter.py2
-rw-r--r--django/contrib/gis/db/backends/spatialite/features.py3
-rw-r--r--django/contrib/gis/db/backends/spatialite/introspection.py4
-rw-r--r--django/contrib/gis/db/backends/spatialite/models.py4
-rw-r--r--django/contrib/gis/db/backends/spatialite/operations.py5
-rw-r--r--django/contrib/gis/db/backends/spatialite/schema.py2
-rw-r--r--django/contrib/gis/db/models/aggregates.py2
-rw-r--r--django/contrib/gis/db/models/fields.py6
-rw-r--r--django/contrib/gis/db/models/lookups.py3
-rw-r--r--django/contrib/gis/db/models/manager.py2
-rw-r--r--django/contrib/gis/db/models/query.py12
-rw-r--r--django/contrib/gis/db/models/sql/aggregates.py1
-rw-r--r--django/contrib/gis/forms/fields.py4
-rw-r--r--django/contrib/gis/forms/widgets.py5
-rw-r--r--django/contrib/gis/gdal/datasource.py7
-rw-r--r--django/contrib/gis/gdal/driver.py2
-rw-r--r--django/contrib/gis/gdal/envelope.py1
-rw-r--r--django/contrib/gis/gdal/feature.py6
-rw-r--r--django/contrib/gis/gdal/field.py1
-rw-r--r--django/contrib/gis/gdal/geometries.py20
-rw-r--r--django/contrib/gis/gdal/geomtype.py1
-rw-r--r--django/contrib/gis/gdal/layer.py19
-rw-r--r--django/contrib/gis/gdal/libgdal.py2
-rw-r--r--django/contrib/gis/gdal/prototypes/ds.py9
-rw-r--r--django/contrib/gis/gdal/prototypes/errcheck.py4
-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/raster.py8
-rw-r--r--django/contrib/gis/gdal/prototypes/srs.py9
-rw-r--r--django/contrib/gis/gdal/raster/source.py9
-rw-r--r--django/contrib/gis/gdal/srs.py3
-rw-r--r--django/contrib/gis/gdal/tests/test_ds.py4
-rw-r--r--django/contrib/gis/gdal/tests/test_geom.py12
-rw-r--r--django/contrib/gis/geoip/base.py10
-rw-r--r--django/contrib/gis/geoip/libgeoip.py1
-rw-r--r--django/contrib/gis/geoip/prototypes.py5
-rw-r--r--django/contrib/gis/geoip/tests.py3
-rw-r--r--django/contrib/gis/geometry/backend/geos.py3
-rw-r--r--django/contrib/gis/geometry/test_data.py1
-rw-r--r--django/contrib/gis/geos/collections.py7
-rw-r--r--django/contrib/gis/geos/coordseq.py5
-rw-r--r--django/contrib/gis/geos/factory.py3
-rw-r--r--django/contrib/gis/geos/geometry.py36
-rw-r--r--django/contrib/gis/geos/io.py4
-rw-r--r--django/contrib/gis/geos/libgeos.py2
-rw-r--r--django/contrib/gis/geos/linestring.py2
-rw-r--r--django/contrib/gis/geos/mutable_list.py2
-rw-r--r--django/contrib/gis/geos/point.py3
-rw-r--r--django/contrib/gis/geos/polygon.py7
-rw-r--r--django/contrib/gis/geos/prototypes/coordseq.py9
-rw-r--r--django/contrib/gis/geos/prototypes/errcheck.py2
-rw-r--r--django/contrib/gis/geos/prototypes/geom.py6
-rw-r--r--django/contrib/gis/geos/prototypes/io.py8
-rw-r--r--django/contrib/gis/geos/prototypes/misc.py3
-rw-r--r--django/contrib/gis/geos/prototypes/predicates.py1
-rw-r--r--django/contrib/gis/geos/prototypes/prepared.py5
-rw-r--r--django/contrib/gis/geos/prototypes/threadsafe.py5
-rw-r--r--django/contrib/gis/geos/prototypes/topology.py5
-rw-r--r--django/contrib/gis/geos/tests/test_geos.py6
-rw-r--r--django/contrib/gis/geos/tests/test_io.py2
-rw-r--r--django/contrib/gis/management/commands/inspectdb.py3
-rw-r--r--django/contrib/gis/maps/google/gmap.py5
-rw-r--r--django/contrib/gis/maps/google/overlays.py8
-rw-r--r--django/contrib/gis/maps/google/zoom.py5
-rw-r--r--django/contrib/gis/measure.py2
-rw-r--r--django/contrib/gis/serializers/geojson.py4
-rw-r--r--django/contrib/gis/sitemaps/kml.py4
-rw-r--r--django/contrib/gis/sitemaps/views.py4
-rw-r--r--django/contrib/gis/tests/distapp/tests.py8
-rw-r--r--django/contrib/gis/tests/geo3d/tests.py2
-rw-r--r--django/contrib/gis/tests/geoadmin/models.py2
-rw-r--r--django/contrib/gis/tests/geoapp/sitemaps.py1
-rw-r--r--django/contrib/gis/tests/geoapp/test_feeds.py4
-rw-r--r--django/contrib/gis/tests/geoapp/test_sitemaps.py5
-rw-r--r--django/contrib/gis/tests/geoapp/tests.py6
-rw-r--r--django/contrib/gis/tests/geoapp/urls.py3
-rw-r--r--django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py2
-rw-r--r--django/contrib/gis/tests/gis_migrations/test_commands.py2
-rw-r--r--django/contrib/gis/tests/gis_migrations/test_operations.py2
-rw-r--r--django/contrib/gis/tests/inspectapp/tests.py4
-rw-r--r--django/contrib/gis/tests/layermap/tests.py6
-rw-r--r--django/contrib/gis/tests/test_geoforms.py2
-rw-r--r--django/contrib/gis/tests/test_measure.py2
-rw-r--r--django/contrib/gis/tests/test_spatialrefsys.py6
-rw-r--r--django/contrib/gis/utils/layermapping.py15
-rw-r--r--django/contrib/gis/utils/ogrinspect.py7
-rw-r--r--django/contrib/gis/utils/srs.py2
-rw-r--r--django/contrib/humanize/apps.py1
-rw-r--r--django/contrib/humanize/templatetags/humanize.py2
-rw-r--r--django/contrib/humanize/tests.py17
-rw-r--r--django/contrib/messages/apps.py1
-rw-r--r--django/contrib/messages/storage/base.py3
-rw-r--r--django/contrib/messages/storage/cookie.py4
-rw-r--r--django/contrib/messages/storage/session.py4
-rw-r--r--django/contrib/messages/tests/base.py4
-rw-r--r--django/contrib/messages/tests/test_api.py3
-rw-r--r--django/contrib/messages/tests/test_cookie.py7
-rw-r--r--django/contrib/messages/tests/test_fallback.py15
-rw-r--r--django/contrib/messages/tests/test_mixins.py2
-rw-r--r--django/contrib/messages/tests/test_session.py4
-rw-r--r--django/contrib/messages/tests/urls.py7
-rw-r--r--django/contrib/postgres/fields/array.py3
-rw-r--r--django/contrib/postgres/fields/hstore.py3
-rw-r--r--django/contrib/postgres/fields/ranges.py7
-rw-r--r--django/contrib/postgres/forms/array.py8
-rw-r--r--django/contrib/postgres/forms/hstore.py1
-rw-r--r--django/contrib/postgres/forms/ranges.py7
-rw-r--r--django/contrib/postgres/signals.py4
-rw-r--r--django/contrib/postgres/validators.py4
-rw-r--r--django/contrib/redirects/apps.py1
-rw-r--r--django/contrib/redirects/middleware.py2
-rw-r--r--django/contrib/redirects/migrations/0001_initial.py2
-rw-r--r--django/contrib/redirects/models.py4
-rw-r--r--django/contrib/sessions/apps.py1
-rw-r--r--django/contrib/sessions/backends/base.py11
-rw-r--r--django/contrib/sessions/backends/cache.py2
-rw-r--r--django/contrib/sessions/backends/cached_db.py2
-rw-r--r--django/contrib/sessions/backends/db.py6
-rw-r--r--django/contrib/sessions/backends/file.py9
-rw-r--r--django/contrib/sessions/backends/signed_cookies.py3
-rw-r--r--django/contrib/sessions/middleware.py2
-rw-r--r--django/contrib/sessions/migrations/0001_initial.py2
-rw-r--r--django/contrib/sessions/models.py2
-rw-r--r--django/contrib/sessions/serializers.py1
-rw-r--r--django/contrib/sessions/tests.py24
-rw-r--r--django/contrib/sitemaps/apps.py1
-rw-r--r--django/contrib/sitemaps/management/commands/ping_google.py2
-rw-r--r--django/contrib/sitemaps/tests/test_generic.py2
-rw-r--r--django/contrib/sitemaps/tests/test_http.py6
-rw-r--r--django/contrib/sitemaps/tests/urls/http.py6
-rw-r--r--django/contrib/sitemaps/views.py2
-rw-r--r--django/contrib/sites/apps.py1
-rw-r--r--django/contrib/sites/migrations/0001_initial.py4
-rw-r--r--django/contrib/sites/models.py3
-rw-r--r--django/contrib/sites/tests.py2
-rw-r--r--django/contrib/staticfiles/apps.py1
-rw-r--r--django/contrib/staticfiles/finders.py15
-rw-r--r--django/contrib/staticfiles/handlers.py7
-rw-r--r--django/contrib/staticfiles/management/commands/collectstatic.py7
-rw-r--r--django/contrib/staticfiles/management/commands/findstatic.py4
-rw-r--r--django/contrib/staticfiles/management/commands/runserver.py4
-rw-r--r--django/contrib/staticfiles/storage.py17
-rw-r--r--django/contrib/staticfiles/templatetags/staticfiles.py2
-rw-r--r--django/contrib/staticfiles/testing.py3
-rw-r--r--django/contrib/staticfiles/utils.py3
-rw-r--r--django/contrib/staticfiles/views.py3
-rw-r--r--django/contrib/syndication/apps.py1
-rw-r--r--django/contrib/syndication/views.py7
-rw-r--r--django/contrib/webdesign/apps.py1
-rw-r--r--django/core/cache/backends/base.py2
-rw-r--r--django/core/cache/backends/db.py14
-rw-r--r--django/core/cache/backends/dummy.py2
-rw-r--r--django/core/cache/backends/filebased.py4
-rw-r--r--django/core/cache/backends/locmem.py9
-rw-r--r--django/core/cache/backends/memcached.py4
-rw-r--r--django/core/cache/utils.py1
-rw-r--r--django/core/checks/compatibility/django_1_7_0.py2
-rw-r--r--django/core/checks/messages.py3
-rw-r--r--django/core/checks/security/base.py3
-rw-r--r--django/core/checks/security/csrf.py3
-rw-r--r--django/core/checks/security/sessions.py2
-rw-r--r--django/core/context_processors.py3
-rw-r--r--django/core/files/move.py1
-rw-r--r--django/core/files/storage.py15
-rw-r--r--django/core/files/temp.py1
-rw-r--r--django/core/files/uploadedfile.py2
-rw-r--r--django/core/files/uploadhandler.py4
-rw-r--r--django/core/handlers/base.py9
-rw-r--r--django/core/handlers/wsgi.py2
-rw-r--r--django/core/mail/backends/filebased.py3
-rw-r--r--django/core/mail/backends/smtp.py2
-rw-r--r--django/core/mail/message.py16
-rw-r--r--django/core/management/base.py5
-rw-r--r--django/core/management/color.py3
-rw-r--r--django/core/management/commands/createcachetable.py4
-rw-r--r--django/core/management/commands/dbshell.py2
-rw-r--r--django/core/management/commands/dumpdata.py4
-rw-r--r--django/core/management/commands/flush.py6
-rw-r--r--django/core/management/commands/inspectdb.py4
-rw-r--r--django/core/management/commands/loaddata.py10
-rw-r--r--django/core/management/commands/makemessages.py11
-rw-r--r--django/core/management/commands/makemigrations.py10
-rw-r--r--django/core/management/commands/migrate.py12
-rw-r--r--django/core/management/commands/runserver.py13
-rw-r--r--django/core/management/commands/showmigrations.py2
-rw-r--r--django/core/management/commands/sqlflush.py2
-rw-r--r--django/core/management/commands/sqlmigrate.py2
-rw-r--r--django/core/management/commands/sqlsequencereset.py2
-rw-r--r--django/core/management/commands/squashmigrations.py10
-rw-r--r--django/core/management/commands/test.py2
-rw-r--r--django/core/management/templates.py10
-rw-r--r--django/core/management/utils.py4
-rw-r--r--django/core/serializers/json.py8
-rw-r--r--django/core/serializers/python.py2
-rw-r--r--django/core/serializers/pyyaml.py10
-rw-r--r--django/core/serializers/xml_serializer.py11
-rw-r--r--django/core/urlresolvers.py9
-rw-r--r--django/core/validators.py5
-rw-r--r--django/db/backends/base/base.py7
-rw-r--r--django/db/backends/base/creation.py1
-rw-r--r--django/db/backends/base/introspection.py1
-rw-r--r--django/db/backends/base/operations.py2
-rw-r--r--django/db/backends/dummy/base.py2
-rw-r--r--django/db/backends/mysql/base.py18
-rw-r--r--django/db/backends/mysql/introspection.py8
-rw-r--r--django/db/backends/oracle/base.py14
-rw-r--r--django/db/backends/oracle/creation.py1
-rw-r--r--django/db/backends/oracle/operations.py2
-rw-r--r--django/db/backends/oracle/schema.py6
-rw-r--r--django/db/backends/postgresql_psycopg2/base.py18
-rw-r--r--django/db/backends/postgresql_psycopg2/introspection.py2
-rw-r--r--django/db/backends/postgresql_psycopg2/operations.py4
-rw-r--r--django/db/backends/postgresql_psycopg2/schema.py4
-rw-r--r--django/db/backends/sqlite3/base.py14
-rw-r--r--django/db/backends/sqlite3/introspection.py1
-rw-r--r--django/db/backends/sqlite3/operations.py6
-rw-r--r--django/db/backends/sqlite3/schema.py4
-rw-r--r--django/db/backends/utils.py1
-rw-r--r--django/db/migrations/autodetector.py9
-rw-r--r--django/db/migrations/executor.py3
-rw-r--r--django/db/migrations/graph.py1
-rw-r--r--django/db/migrations/loader.py7
-rw-r--r--django/db/migrations/migration.py1
-rw-r--r--django/db/migrations/operations/base.py1
-rw-r--r--django/db/migrations/operations/fields.py1
-rw-r--r--django/db/migrations/operations/models.py4
-rw-r--r--django/db/migrations/state.py9
-rw-r--r--django/db/migrations/writer.py5
-rw-r--r--django/db/models/aggregates.py2
-rw-r--r--django/db/models/base.py25
-rw-r--r--django/db/models/deletion.py2
-rw-r--r--django/db/models/expressions.py2
-rw-r--r--django/db/models/fields/files.py10
-rw-r--r--django/db/models/fields/related.py21
-rw-r--r--django/db/models/lookups.py2
-rw-r--r--django/db/models/manager.py2
-rw-r--r--django/db/models/options.py8
-rw-r--r--django/db/models/query.py21
-rw-r--r--django/db/models/query_utils.py4
-rw-r--r--django/db/models/sql/aggregates.py3
-rw-r--r--django/db/models/sql/compiler.py11
-rw-r--r--django/db/models/sql/query.py25
-rw-r--r--django/db/models/sql/subqueries.py1
-rw-r--r--django/db/models/sql/where.py1
-rw-r--r--django/db/transaction.py4
-rw-r--r--django/db/utils.py7
-rw-r--r--django/dispatch/weakref_backports.py1
-rw-r--r--django/forms/fields.py22
-rw-r--r--django/forms/forms.py15
-rw-r--r--django/forms/formsets.py7
-rw-r--r--django/forms/models.py19
-rw-r--r--django/forms/utils.py18
-rw-r--r--django/forms/widgets.py6
-rw-r--r--django/http/cookie.py4
-rw-r--r--django/http/multipartparser.py6
-rw-r--r--django/http/request.py9
-rw-r--r--django/http/response.py8
-rw-r--r--django/middleware/cache.py8
-rw-r--r--django/middleware/common.py7
-rw-r--r--django/middleware/csrf.py3
-rw-r--r--django/middleware/gzip.py2
-rw-r--r--django/middleware/locale.py7
-rw-r--r--django/shortcuts.py16
-rw-r--r--django/template/backends/base.py3
-rw-r--r--django/template/backends/django.py3
-rw-r--r--django/template/backends/jinja2.py4
-rw-r--r--django/template/base.py35
-rw-r--r--django/template/context.py3
-rw-r--r--django/template/debug.py8
-rw-r--r--django/template/defaultfilters.py25
-rw-r--r--django/template/defaulttags.py29
-rw-r--r--django/template/engine.py4
-rw-r--r--django/template/loader.py8
-rw-r--r--django/template/loader_tags.py7
-rw-r--r--django/template/loaders/cached.py1
-rw-r--r--django/template/loaders/eggs.py10
-rw-r--r--django/template/response.py2
-rw-r--r--django/template/utils.py5
-rw-r--r--django/templatetags/cache.py6
-rw-r--r--django/templatetags/future.py3
-rw-r--r--django/templatetags/i18n.py9
-rw-r--r--django/templatetags/l10n.py3
-rw-r--r--django/templatetags/tz.py7
-rw-r--r--django/test/client.py19
-rw-r--r--django/test/html.py7
-rw-r--r--django/test/runner.py2
-rw-r--r--django/test/signals.py4
-rw-r--r--django/test/testcases.py25
-rw-r--r--django/test/utils.py10
-rw-r--r--django/utils/_os.py4
-rw-r--r--django/utils/autoreload.py3
-rw-r--r--django/utils/cache.py2
-rw-r--r--django/utils/crypto.py16
-rw-r--r--django/utils/dateformat.py12
-rw-r--r--django/utils/dateparse.py4
-rw-r--r--django/utils/dates.py2
-rw-r--r--django/utils/datetime_safe.py4
-rw-r--r--django/utils/deconstruct.py4
-rw-r--r--django/utils/decorators.py2
-rw-r--r--django/utils/encoding.py5
-rw-r--r--django/utils/feedgenerator.py6
-rw-r--r--django/utils/formats.py14
-rw-r--r--django/utils/functional.py2
-rw-r--r--django/utils/html.py11
-rw-r--r--django/utils/html_parser.py3
-rw-r--r--django/utils/http.py8
-rw-r--r--django/utils/ipv6.py2
-rw-r--r--django/utils/jslex.py1
-rw-r--r--django/utils/module_loading.py5
-rw-r--r--django/utils/numberformat.py2
-rw-r--r--django/utils/safestring.py2
-rw-r--r--django/utils/text.py8
-rw-r--r--django/utils/timezone.py12
-rw-r--r--django/utils/translation/trans_real.py16
-rw-r--r--django/views/csrf.py1
-rw-r--r--django/views/debug.py13
-rw-r--r--django/views/decorators/cache.py7
-rw-r--r--django/views/decorators/csrf.py5
-rw-r--r--django/views/decorators/gzip.py2
-rw-r--r--django/views/decorators/http.py10
-rw-r--r--django/views/decorators/vary.py1
-rw-r--r--django/views/defaults.py2
-rw-r--r--django/views/generic/base.py4
-rw-r--r--django/views/generic/dates.py13
-rw-r--r--django/views/generic/detail.py2
-rw-r--r--django/views/generic/edit.py7
-rw-r--r--django/views/generic/list.py4
-rw-r--r--django/views/i18n.py12
-rw-r--r--django/views/static.py10
-rw-r--r--docs/_ext/applyxrefs.py2
-rw-r--r--docs/_ext/djangodocs.py7
-rw-r--r--docs/_ext/literals_to_xrefs.py2
-rw-r--r--scripts/manage_translations.py5
-rw-r--r--setup.cfg7
-rw-r--r--setup.py4
-rw-r--r--tests/admin_autodiscover/admin.py1
-rw-r--r--tests/admin_changelist/admin.py5
-rw-r--r--tests/admin_changelist/tests.py29
-rw-r--r--tests/admin_changelist/urls.py1
-rw-r--r--tests/admin_checks/models.py4
-rw-r--r--tests/admin_checks/tests.py2
-rw-r--r--tests/admin_custom_urls/tests.py2
-rw-r--r--tests/admin_custom_urls/urls.py1
-rw-r--r--tests/admin_docs/tests.py4
-rw-r--r--tests/admin_docs/views.py2
-rw-r--r--tests/admin_filters/models.py4
-rw-r--r--tests/admin_filters/tests.py12
-rw-r--r--tests/admin_inlines/admin.py2
-rw-r--r--tests/admin_inlines/models.py3
-rw-r--r--tests/admin_inlines/tests.py21
-rw-r--r--tests/admin_inlines/urls.py1
-rw-r--r--tests/admin_ordering/tests.py8
-rw-r--r--tests/admin_registration/tests.py2
-rw-r--r--tests/admin_scripts/app_with_import/models.py2
-rw-r--r--tests/admin_scripts/complex_app/admin/foo.py1
-rw-r--r--tests/admin_scripts/tests.py18
-rw-r--r--tests/admin_scripts/urls.py1
-rw-r--r--tests/admin_utils/tests.py16
-rw-r--r--tests/admin_views/admin.py51
-rw-r--r--tests/admin_views/custom_has_permission_admin.py2
-rw-r--r--tests/admin_views/customadmin.py6
-rw-r--r--tests/admin_views/models.py4
-rw-r--r--tests/admin_views/tests.py66
-rw-r--r--tests/admin_views/urls.py3
-rw-r--r--tests/admin_widgets/models.py2
-rw-r--r--tests/admin_widgets/tests.py19
-rw-r--r--tests/admin_widgets/urls.py1
-rw-r--r--tests/aggregation/tests.py13
-rw-r--r--tests/aggregation_regress/models.py2
-rw-r--r--tests/aggregation_regress/tests.py10
-rw-r--r--tests/annotations/tests.py8
-rw-r--r--tests/app_loading/tests.py2
-rw-r--r--tests/apps/models.py1
-rw-r--r--tests/apps/tests.py9
-rw-r--r--tests/backends/models.py2
-rw-r--r--tests/backends/tests.py20
-rw-r--r--tests/basic/tests.py15
-rw-r--r--tests/builtin_server/tests.py3
-rw-r--r--tests/bulk_create/tests.py7
-rw-r--r--tests/cache/models.py3
-rw-r--r--tests/cache/tests.py35
-rw-r--r--tests/check_framework/test_model_field_deprecation.py2
-rw-r--r--tests/check_framework/test_security.py5
-rw-r--r--tests/check_framework/tests.py7
-rw-r--r--tests/choices/models.py1
-rw-r--r--tests/conditional_processing/tests.py1
-rw-r--r--tests/conditional_processing/urls.py1
-rw-r--r--tests/conditional_processing/views.py4
-rw-r--r--tests/contenttypes_tests/tests.py6
-rw-r--r--tests/context_processors/urls.py1
-rw-r--r--tests/csrf_tests/tests.py7
-rw-r--r--tests/custom_columns/tests.py2
-rw-r--r--tests/custom_lookups/tests.py6
-rw-r--r--tests/custom_managers/models.py4
-rw-r--r--tests/custom_managers/tests.py8
-rw-r--r--tests/custom_pk/models.py2
-rw-r--r--tests/custom_pk/tests.py4
-rw-r--r--tests/dates/tests.py2
-rw-r--r--tests/datetimes/tests.py11
-rw-r--r--tests/db_functions/tests.py6
-rw-r--r--tests/db_typecasts/tests.py1
-rw-r--r--tests/decorators/tests.py22
-rw-r--r--tests/defer/tests.py4
-rw-r--r--tests/defer_regress/tests.py10
-rw-r--r--tests/delete/tests.py11
-rw-r--r--tests/delete_regress/models.py2
-rw-r--r--tests/delete_regress/tests.py12
-rw-r--r--tests/dispatch/tests.py1
-rw-r--r--tests/distinct_on_fields/tests.py2
-rw-r--r--tests/expressions/tests.py18
-rw-r--r--tests/expressions_case/tests.py8
-rw-r--r--tests/extra_regress/tests.py4
-rw-r--r--tests/field_subclassing/fields.py4
-rw-r--r--tests/field_subclassing/models.py5
-rw-r--r--tests/field_subclassing/tests.py2
-rw-r--r--tests/file_storage/models.py2
-rw-r--r--tests/file_storage/tests.py15
-rw-r--r--tests/file_storage/urls.py1
-rw-r--r--tests/file_uploads/tests.py6
-rw-r--r--tests/file_uploads/urls.py1
-rw-r--r--tests/file_uploads/views.py2
-rw-r--r--tests/files/tests.py10
-rw-r--r--tests/fixtures/tests.py8
-rw-r--r--tests/fixtures_regress/tests.py33
-rw-r--r--tests/force_insert_update/tests.py7
-rw-r--r--tests/foreign_object/models.py3
-rw-r--r--tests/foreign_object/tests.py13
-rw-r--r--tests/forms_tests/models.py1
-rw-r--r--tests/forms_tests/tests/test_error_messages.py4
-rw-r--r--tests/forms_tests/tests/test_fields.py24
-rw-r--r--tests/forms_tests/tests/test_forms.py10
-rw-r--r--tests/forms_tests/tests/test_formsets.py6
-rw-r--r--tests/forms_tests/tests/test_input_formats.py5
-rw-r--r--tests/forms_tests/tests/test_media.py4
-rw-r--r--tests/forms_tests/tests/test_regressions.py2
-rw-r--r--tests/forms_tests/tests/test_utils.py6
-rw-r--r--tests/forms_tests/tests/test_widgets.py4
-rw-r--r--tests/forms_tests/tests/tests.py10
-rw-r--r--tests/forms_tests/urls.py1
-rw-r--r--tests/from_db_value/tests.py2
-rw-r--r--tests/generic_inline_admin/admin.py6
-rw-r--r--tests/generic_inline_admin/models.py2
-rw-r--r--tests/generic_inline_admin/tests.py3
-rw-r--r--tests/generic_relations/models.py2
-rw-r--r--tests/generic_relations/tests.py9
-rw-r--r--tests/generic_relations_regress/models.py5
-rw-r--r--tests/generic_relations_regress/tests.py11
-rw-r--r--tests/generic_views/test_base.py4
-rw-r--r--tests/generic_views/test_edit.py4
-rw-r--r--tests/generic_views/test_list.py4
-rw-r--r--tests/generic_views/urls.py4
-rw-r--r--tests/generic_views/views.py2
-rw-r--r--tests/get_earliest_or_latest/tests.py2
-rw-r--r--tests/get_object_or_404/tests.py4
-rw-r--r--tests/get_or_create/tests.py12
-rw-r--r--tests/handlers/tests.py9
-rw-r--r--tests/http_utils/tests.py6
-rw-r--r--tests/httpwrappers/tests.py17
-rw-r--r--tests/i18n/contenttypes/tests.py3
-rw-r--r--tests/i18n/patterns/tests.py8
-rw-r--r--tests/i18n/patterns/urls/default.py1
-rw-r--r--tests/i18n/patterns/urls/included.py1
-rw-r--r--tests/i18n/patterns/urls/namespace.py1
-rw-r--r--tests/i18n/patterns/urls/path_unused.py1
-rw-r--r--tests/i18n/patterns/urls/wrong.py1
-rw-r--r--tests/i18n/patterns/urls/wrong_namespace.py1
-rw-r--r--tests/i18n/test_compilation.py13
-rw-r--r--tests/i18n/test_extraction.py12
-rw-r--r--tests/i18n/tests.py45
-rw-r--r--tests/i18n/urls.py1
-rw-r--r--tests/indexes/models.py3
-rw-r--r--tests/inline_formsets/tests.py2
-rw-r--r--tests/introspection/tests.py2
-rw-r--r--tests/invalid_models_tests/test_models.py2
-rw-r--r--tests/invalid_models_tests/test_relative_fields.py2
-rw-r--r--tests/known_related_objects/tests.py2
-rw-r--r--tests/logging_tests/tests.py9
-rw-r--r--tests/logging_tests/views.py2
-rw-r--r--tests/lookup/tests.py2
-rw-r--r--tests/m2m_and_m2o/tests.py2
-rw-r--r--tests/m2m_intermediary/tests.py2
-rw-r--r--tests/m2m_regress/tests.py6
-rw-r--r--tests/m2m_signals/tests.py2
-rw-r--r--tests/m2m_through/tests.py8
-rw-r--r--tests/m2m_through_regress/tests.py7
-rw-r--r--tests/mail/tests.py17
-rw-r--r--tests/managers_regress/models.py4
-rw-r--r--tests/managers_regress/tests.py14
-rw-r--r--tests/many_to_one/tests.py10
-rw-r--r--tests/max_lengths/tests.py2
-rw-r--r--tests/middleware/test_security.py2
-rw-r--r--tests/middleware/tests.py14
-rw-r--r--tests/middleware/views.py10
-rw-r--r--tests/middleware_exceptions/tests.py2
-rw-r--r--tests/migrate_signals/tests.py3
-rw-r--r--tests/migration_test_data_persistence/migrations/0001_initial.py2
-rw-r--r--tests/migration_test_data_persistence/tests.py3
-rw-r--r--tests/migrations/deprecated_field_migrations/0001_initial.py2
-rw-r--r--tests/migrations/migrations_test_apps/lookuperror_a/migrations/0001_initial.py2
-rw-r--r--tests/migrations/migrations_test_apps/lookuperror_a/migrations/0002_a2.py2
-rw-r--r--tests/migrations/migrations_test_apps/lookuperror_a/migrations/0003_a3.py2
-rw-r--r--tests/migrations/migrations_test_apps/lookuperror_a/migrations/0004_a4.py2
-rw-r--r--tests/migrations/migrations_test_apps/lookuperror_b/migrations/0001_initial.py2
-rw-r--r--tests/migrations/migrations_test_apps/lookuperror_b/migrations/0002_b2.py2
-rw-r--r--tests/migrations/migrations_test_apps/lookuperror_b/migrations/0003_b3.py2
-rw-r--r--tests/migrations/migrations_test_apps/lookuperror_c/migrations/0001_initial.py2
-rw-r--r--tests/migrations/migrations_test_apps/lookuperror_c/migrations/0002_c2.py2
-rw-r--r--tests/migrations/migrations_test_apps/lookuperror_c/migrations/0003_c3.py2
-rw-r--r--tests/migrations/migrations_test_apps/unmigrated_app/models.py1
-rw-r--r--tests/migrations/test_autodetector.py10
-rw-r--r--tests/migrations/test_commands.py2
-rw-r--r--tests/migrations/test_executor.py4
-rw-r--r--tests/migrations/test_graph.py4
-rw-r--r--tests/migrations/test_loader.py5
-rw-r--r--tests/migrations/test_migrations_custom_user/0001_initial.py2
-rw-r--r--tests/migrations/test_migrations_no_changes/0003_third.py2
-rw-r--r--tests/migrations/test_migrations_no_default/0001_initial.py2
-rw-r--r--tests/migrations/test_multidb.py12
-rw-r--r--tests/migrations/test_operations.py10
-rw-r--r--tests/migrations/test_optimizer.py5
-rw-r--r--tests/migrations/test_state.py9
-rw-r--r--tests/migrations/test_writer.py20
-rw-r--r--tests/model_fields/models.py22
-rw-r--r--tests/model_fields/test_field_flags.py6
-rw-r--r--tests/model_fields/test_uuid.py2
-rw-r--r--tests/model_fields/tests.py28
-rw-r--r--tests/model_forms/models.py3
-rw-r--r--tests/model_forms/tests.py30
-rw-r--r--tests/model_formsets/tests.py18
-rw-r--r--tests/model_formsets_regress/tests.py11
-rw-r--r--tests/model_inheritance/models.py1
-rw-r--r--tests/model_inheritance/same_model_name/models.py4
-rw-r--r--tests/model_inheritance/tests.py7
-rw-r--r--tests/model_inheritance_regress/tests.py14
-rw-r--r--tests/model_meta/models.py7
-rw-r--r--tests/model_meta/results.py4
-rw-r--r--tests/model_meta/test_legacy.py2
-rw-r--r--tests/model_meta/tests.py12
-rw-r--r--tests/model_options/models/tablespaces.py1
-rw-r--r--tests/model_options/test_default_related_name.py2
-rw-r--r--tests/model_options/test_tablespaces.py5
-rw-r--r--tests/model_package/tests.py4
-rw-r--r--tests/model_permalink/views.py10
-rw-r--r--tests/model_regress/models.py1
-rw-r--r--tests/model_regress/test_pickle.py2
-rw-r--r--tests/model_regress/tests.py10
-rw-r--r--tests/model_validation/tests.py4
-rw-r--r--tests/modeladmin/tests.py12
-rw-r--r--tests/multiple_database/models.py2
-rw-r--r--tests/multiple_database/tests.py4
-rw-r--r--tests/nested_foreign_keys/tests.py4
-rw-r--r--tests/null_fk/tests.py5
-rw-r--r--tests/null_fk_ordering/tests.py2
-rw-r--r--tests/null_queries/tests.py4
-rw-r--r--tests/one_to_one/tests.py8
-rw-r--r--tests/order_with_respect_to/tests.py5
-rw-r--r--tests/pagination/custom.py2
-rw-r--r--tests/pagination/tests.py9
-rw-r--r--tests/postgres_tests/array_default_migrations/0001_initial.py2
-rw-r--r--tests/postgres_tests/array_default_migrations/0002_integerarraymodel_field_2.py2
-rw-r--r--tests/postgres_tests/migrations/0001_setup_extensions.py4
-rw-r--r--tests/postgres_tests/migrations/0002_create_test_models.py2
-rw-r--r--tests/postgres_tests/models.py4
-rw-r--r--tests/postgres_tests/test_array.py9
-rw-r--r--tests/postgres_tests/test_ranges.py10
-rw-r--r--tests/prefetch_related/models.py2
-rw-r--r--tests/prefetch_related/tests.py12
-rw-r--r--tests/proxy_model_inheritance/tests.py5
-rw-r--r--tests/proxy_models/admin.py2
-rw-r--r--tests/proxy_models/models.py1
-rw-r--r--tests/proxy_models/tests.py16
-rw-r--r--tests/proxy_models/urls.py1
-rw-r--r--tests/queries/tests.py36
-rw-r--r--tests/queryset_pickle/models.py2
-rw-r--r--tests/queryset_pickle/tests.py4
-rw-r--r--tests/raw_query/tests.py2
-rw-r--r--tests/requests/tests.py12
-rw-r--r--tests/resolve_url/tests.py4
-rw-r--r--tests/reverse_lookup/tests.py2
-rwxr-xr-xtests/runtests.py11
-rw-r--r--tests/schema/fields.py5
-rw-r--r--tests/schema/tests.py16
-rw-r--r--tests/select_for_update/tests.py8
-rw-r--r--tests/select_related/models.py6
-rw-r--r--tests/select_related/tests.py6
-rw-r--r--tests/select_related_onetoone/tests.py7
-rw-r--r--tests/select_related_regress/tests.py8
-rw-r--r--tests/serializers/tests.py26
-rw-r--r--tests/serializers_regress/models.py5
-rw-r--r--tests/serializers_regress/tests.py40
-rw-r--r--tests/servers/tests.py6
-rw-r--r--tests/servers/urls.py1
-rw-r--r--tests/servers/views.py1
-rw-r--r--tests/settings_tests/tests.py8
-rw-r--r--tests/shortcuts/tests.py2
-rw-r--r--tests/shortcuts/views.py3
-rw-r--r--tests/signing/tests.py2
-rw-r--r--tests/sites_framework/migrations/0001_initial.py2
-rw-r--r--tests/sites_framework/tests.py5
-rw-r--r--tests/staticfiles_tests/storage.py3
-rw-r--r--tests/staticfiles_tests/test_liveserver.py6
-rw-r--r--tests/staticfiles_tests/tests.py15
-rw-r--r--tests/string_lookup/tests.py3
-rw-r--r--tests/swappable_models/tests.py5
-rw-r--r--tests/syndication_tests/tests.py11
-rw-r--r--tests/syndication_tests/urls.py1
-rw-r--r--tests/template_backends/test_django.py6
-rw-r--r--tests/template_backends/test_jinja2.py4
-rw-r--r--tests/template_loader/tests.py7
-rw-r--r--tests/template_tests/alternate_urls.py1
-rw-r--r--tests/template_tests/filter_tests/test_autoescape.py2
-rw-r--r--tests/template_tests/filter_tests/test_date.py2
-rw-r--r--tests/template_tests/filter_tests/test_time.py2
-rw-r--r--tests/template_tests/filter_tests/test_timesince.py2
-rw-r--r--tests/template_tests/filter_tests/test_timeuntil.py2
-rw-r--r--tests/template_tests/syntax_tests/test_autoescape.py2
-rw-r--r--tests/template_tests/syntax_tests/test_basic.py3
-rw-r--r--tests/template_tests/syntax_tests/test_exceptions.py2
-rw-r--r--tests/template_tests/syntax_tests/test_extends.py1
-rw-r--r--tests/template_tests/syntax_tests/test_filter_syntax.py2
-rw-r--r--tests/template_tests/syntax_tests/test_if.py4
-rw-r--r--tests/template_tests/syntax_tests/test_include.py3
-rw-r--r--tests/template_tests/syntax_tests/test_numpy.py2
-rw-r--r--tests/template_tests/syntax_tests/test_ssi.py2
-rw-r--r--tests/template_tests/syntax_tests/test_static.py2
-rw-r--r--tests/template_tests/syntax_tests/test_url.py2
-rw-r--r--tests/template_tests/templatetags/bad_tag.py1
-rw-r--r--tests/template_tests/templatetags/inclusion.py1
-rw-r--r--tests/template_tests/test_context.py4
-rw-r--r--tests/template_tests/test_loaders.py17
-rw-r--r--tests/template_tests/test_parser.py4
-rw-r--r--tests/template_tests/test_response.py12
-rw-r--r--tests/template_tests/test_unicode.py4
-rw-r--r--tests/template_tests/tests.py13
-rw-r--r--tests/template_tests/urls.py2
-rw-r--r--tests/template_tests/utils.py3
-rw-r--r--tests/test_client/tests.py3
-rw-r--r--tests/test_client/urls.py1
-rw-r--r--tests/test_client/views.py6
-rw-r--r--tests/test_client_regress/models.py2
-rw-r--r--tests/test_client_regress/tests.py16
-rw-r--r--tests/test_client_regress/urls.py3
-rw-r--r--tests/test_client_regress/views.py2
-rw-r--r--tests/test_runner/test_discover_runner.py2
-rw-r--r--tests/test_runner/tests.py7
-rw-r--r--tests/test_utils/tests.py6
-rw-r--r--tests/test_utils/urls.py1
-rw-r--r--tests/timezones/tests.py31
-rw-r--r--tests/transactions/tests.py10
-rw-r--r--tests/unmanaged_models/models.py1
-rw-r--r--tests/unmanaged_models/tests.py2
-rw-r--r--tests/update/tests.py2
-rw-r--r--tests/update_only_fields/tests.py4
-rw-r--r--tests/urlpatterns_reverse/extra_urls.py3
-rw-r--r--tests/urlpatterns_reverse/included_named_urls.py3
-rw-r--r--tests/urlpatterns_reverse/included_named_urls2.py1
-rw-r--r--tests/urlpatterns_reverse/included_namespace_urls.py3
-rw-r--r--tests/urlpatterns_reverse/included_no_kwargs_urls.py1
-rw-r--r--tests/urlpatterns_reverse/included_urls.py1
-rw-r--r--tests/urlpatterns_reverse/included_urls2.py1
-rw-r--r--tests/urlpatterns_reverse/named_urls.py3
-rw-r--r--tests/urlpatterns_reverse/namespace_urls.py2
-rw-r--r--tests/urlpatterns_reverse/reverse_lazy_urls.py2
-rw-r--r--tests/urlpatterns_reverse/tests.py20
-rw-r--r--tests/urlpatterns_reverse/urlconf_inner.py2
-rw-r--r--tests/urlpatterns_reverse/urlconf_outer.py3
-rw-r--r--tests/urlpatterns_reverse/urls.py3
-rw-r--r--tests/urlpatterns_reverse/urls_error_handlers_callables.py1
-rw-r--r--tests/urlpatterns_reverse/urls_without_full_import.py3
-rw-r--r--tests/urlpatterns_reverse/views.py5
-rw-r--r--tests/user_commands/tests.py4
-rw-r--r--tests/utils_tests/test_archive.py3
-rw-r--r--tests/utils_tests/test_autoreload.py4
-rw-r--r--tests/utils_tests/test_baseconv.py4
-rw-r--r--tests/utils_tests/test_datastructures.py6
-rw-r--r--tests/utils_tests/test_dateformat.py9
-rw-r--r--tests/utils_tests/test_dateparse.py6
-rw-r--r--tests/utils_tests/test_datetime_safe.py5
-rw-r--r--tests/utils_tests/test_decorators.py2
-rw-r--r--tests/utils_tests/test_encoding.py6
-rw-r--r--tests/utils_tests/test_functional.py2
-rw-r--r--tests/utils_tests/test_html.py2
-rw-r--r--tests/utils_tests/test_http.py5
-rw-r--r--tests/utils_tests/test_ipv6.py2
-rw-r--r--tests/utils_tests/test_module/another_bad_module.py1
-rw-r--r--tests/utils_tests/test_module/another_good_module.py1
-rw-r--r--tests/utils_tests/test_module_loading.py7
-rw-r--r--tests/utils_tests/test_safestring.py12
-rw-r--r--tests/utils_tests/test_termcolors.py6
-rw-r--r--tests/utils_tests/test_timesince.py2
-rw-r--r--tests/utils_tests/test_timezone.py7
-rw-r--r--tests/validation/test_unique.py7
-rw-r--r--tests/validation/tests.py6
-rw-r--r--tests/validators/tests.py5
-rw-r--r--tests/view_tests/default_urls.py1
-rw-r--r--tests/view_tests/generic_urls.py2
-rw-r--r--tests/view_tests/templatetags/debugtags.py1
-rw-r--r--tests/view_tests/tests/test_csrf.py2
-rw-r--r--tests/view_tests/tests/test_debug.py13
-rw-r--r--tests/view_tests/tests/test_i18n.py7
-rw-r--r--tests/view_tests/tests/test_static.py2
-rw-r--r--tests/view_tests/urls.py3
-rw-r--r--tests/view_tests/views.py16
-rw-r--r--tests/wsgi/urls.py2
793 files changed, 2525 insertions, 2307 deletions
diff --git a/django/apps/config.py b/django/apps/config.py
index fd0e2fe78c..76b3014d9d 100644
--- a/django/apps/config.py
+++ b/django/apps/config.py
@@ -1,10 +1,9 @@
-from importlib import import_module
import os
+from importlib import import_module
from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
-from django.utils.module_loading import module_has_submodule
from django.utils._os import upath
-
+from django.utils.module_loading import module_has_submodule
MODELS_MODULE_NAME = 'models'
diff --git a/django/apps/registry.py b/django/apps/registry.py
index 9ddd56462a..c64106cd6f 100644
--- a/django/apps/registry.py
+++ b/django/apps/registry.py
@@ -1,7 +1,7 @@
-from collections import Counter, defaultdict, OrderedDict
import sys
import threading
import warnings
+from collections import Counter, OrderedDict, defaultdict
from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured
from django.utils import lru_cache
diff --git a/django/conf/project_template/project_name/settings.py b/django/conf/project_template/project_name/settings.py
index 9d4b38d171..c0db27cbdc 100644
--- a/django/conf/project_template/project_name/settings.py
+++ b/django/conf/project_template/project_name/settings.py
@@ -10,8 +10,9 @@ For the full list of settings and their values, see
https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/
"""
-# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
+
+# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
diff --git a/django/conf/project_template/project_name/wsgi.py b/django/conf/project_template/project_name/wsgi.py
index 94d60c8cf9..0d68b95645 100644
--- a/django/conf/project_template/project_name/wsgi.py
+++ b/django/conf/project_template/project_name/wsgi.py
@@ -8,7 +8,9 @@ https://docs.djangoproject.com/en/{{ docs_version }}/howto/deployment/wsgi/
"""
import os
-os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
from django.core.wsgi import get_wsgi_application
+
+os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings")
+
application = get_wsgi_application()
diff --git a/django/contrib/admin/actions.py b/django/contrib/admin/actions.py
index 2dafd3ea3a..3478145b30 100644
--- a/django/contrib/admin/actions.py
+++ b/django/contrib/admin/actions.py
@@ -2,14 +2,14 @@
Built-in, globally-available admin actions.
"""
-from django.core.exceptions import PermissionDenied
from django.contrib import messages
from django.contrib.admin import helpers
from django.contrib.admin.utils import get_deleted_objects, model_ngettext
+from django.core.exceptions import PermissionDenied
from django.db import router
from django.template.response import TemplateResponse
from django.utils.encoding import force_text
-from django.utils.translation import ugettext_lazy, ugettext as _
+from django.utils.translation import ugettext as _, ugettext_lazy
def delete_selected(modeladmin, request, queryset):
diff --git a/django/contrib/admin/apps.py b/django/contrib/admin/apps.py
index b052746ff4..c965cdbc89 100644
--- a/django/contrib/admin/apps.py
+++ b/django/contrib/admin/apps.py
@@ -1,6 +1,6 @@
from django.apps import AppConfig
-from django.core import checks
from django.contrib.admin.checks import check_admin_app
+from django.core import checks
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py
index f90793daec..d8f7fe57e4 100644
--- a/django/contrib/admin/checks.py
+++ b/django/contrib/admin/checks.py
@@ -3,11 +3,15 @@ from __future__ import unicode_literals
from itertools import chain
-from django.contrib.admin.utils import get_fields_from_path, NotRelationField, flatten
+from django.contrib.admin.utils import (
+ NotRelationField, flatten, get_fields_from_path,
+)
from django.core import checks
from django.core.exceptions import FieldDoesNotExist
from django.db import models
-from django.forms.models import BaseModelForm, _get_foreign_key, BaseModelFormSet
+from django.forms.models import (
+ BaseModelForm, BaseModelFormSet, _get_foreign_key,
+)
def check_admin_app(**kwargs):
diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py
index 0c0eb339ce..863da76818 100644
--- a/django/contrib/admin/filters.py
+++ b/django/contrib/admin/filters.py
@@ -7,15 +7,17 @@ certain test -- e.g. being a DateField or ForeignKey.
"""
import datetime
+from django.contrib.admin.options import IncorrectLookupParameters
+from django.contrib.admin.utils import (
+ get_limit_choices_to_from_path, get_model_from_relation,
+ prepare_lookup_value, reverse_field_path,
+)
+from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.db import models
from django.db.models.fields.related import ForeignObjectRel, ManyToManyField
-from django.core.exceptions import ImproperlyConfigured, ValidationError
-from django.utils.encoding import smart_text, force_text
-from django.utils.translation import ugettext_lazy as _
from django.utils import timezone
-from django.contrib.admin.utils import (get_model_from_relation,
- reverse_field_path, get_limit_choices_to_from_path, prepare_lookup_value)
-from django.contrib.admin.options import IncorrectLookupParameters
+from django.utils.encoding import force_text, smart_text
+from django.utils.translation import ugettext_lazy as _
class ListFilter(object):
diff --git a/django/contrib/admin/forms.py b/django/contrib/admin/forms.py
index ede6f257ad..2e482b9c15 100644
--- a/django/contrib/admin/forms.py
+++ b/django/contrib/admin/forms.py
@@ -1,7 +1,6 @@
from __future__ import unicode_literals
from django import forms
-
from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py
index bd41063e43..07ea9a4813 100644
--- a/django/contrib/admin/helpers.py
+++ b/django/contrib/admin/helpers.py
@@ -3,22 +3,23 @@ from __future__ import unicode_literals
import warnings
from django import forms
-from django.contrib.admin.utils import (flatten_fieldsets, lookup_field,
- display_for_field, label_for_field, help_text_for_field)
+from django.conf import settings
from django.contrib.admin.templatetags.admin_static import static
+from django.contrib.admin.utils import (
+ display_for_field, flatten_fieldsets, help_text_for_field, label_for_field,
+ lookup_field,
+)
from django.core.exceptions import ObjectDoesNotExist
from django.db.models.fields.related import ManyToManyRel
from django.forms.utils import flatatt
from django.template.defaultfilters import capfirst, linebreaksbr
+from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text, smart_text
from django.utils.functional import cached_property
from django.utils.html import conditional_escape, format_html
from django.utils.safestring import mark_safe
-from django.utils import six
from django.utils.translation import ugettext_lazy as _
-from django.conf import settings
-
ACTION_CHECKBOX_NAME = '_selected_action'
diff --git a/django/contrib/admin/migrations/0001_initial.py b/django/contrib/admin/migrations/0001_initial.py
index b9872dcc44..088d36becd 100644
--- a/django/contrib/admin/migrations/0001_initial.py
+++ b/django/contrib/admin/migrations/0001_initial.py
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
-from django.conf import settings
import django.contrib.admin.models
+from django.conf import settings
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/admin/models.py b/django/contrib/admin/models.py
index 9ecb367e05..4e1d2aed04 100644
--- a/django/contrib/admin/models.py
+++ b/django/contrib/admin/models.py
@@ -1,13 +1,12 @@
from __future__ import unicode_literals
-from django.db import models
from django.conf import settings
-from django.contrib.contenttypes.models import ContentType
from django.contrib.admin.utils import quote
-from django.core.urlresolvers import reverse, NoReverseMatch
+from django.contrib.contenttypes.models import ContentType
+from django.core.urlresolvers import NoReverseMatch, reverse
+from django.db import models
+from django.utils.encoding import python_2_unicode_compatible, smart_text
from django.utils.translation import ugettext, ugettext_lazy as _
-from django.utils.encoding import smart_text
-from django.utils.encoding import python_2_unicode_compatible
ADDITION = 1
CHANGE = 2
diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py
index 1419e86589..f0fd4c1a90 100644
--- a/django/contrib/admin/options.py
+++ b/django/contrib/admin/options.py
@@ -1,34 +1,39 @@
-from collections import OrderedDict
import copy
import operator
+from collections import OrderedDict
from functools import partial, reduce, update_wrapper
from django import forms
from django.conf import settings
from django.contrib import messages
-from django.contrib.admin import widgets, helpers
-from django.contrib.admin.checks import (BaseModelAdminChecks, ModelAdminChecks,
- InlineModelAdminChecks)
+from django.contrib.admin import helpers, widgets
+from django.contrib.admin.checks import (
+ BaseModelAdminChecks, InlineModelAdminChecks, ModelAdminChecks,
+)
from django.contrib.admin.exceptions import DisallowedModelAdminToField
-from django.contrib.admin.utils import (quote, unquote, flatten_fieldsets,
- get_deleted_objects, model_format_dict, NestedObjects,
- lookup_needs_distinct)
from django.contrib.admin.templatetags.admin_static import static
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
+from django.contrib.admin.utils import (
+ NestedObjects, flatten_fieldsets, get_deleted_objects,
+ lookup_needs_distinct, model_format_dict, quote, unquote,
+)
from django.contrib.auth import get_permission_codename
-from django.core.exceptions import (PermissionDenied, ValidationError,
- FieldDoesNotExist, FieldError)
+from django.core.exceptions import (
+ FieldDoesNotExist, FieldError, PermissionDenied, ValidationError,
+)
from django.core.paginator import Paginator
from django.core.urlresolvers import reverse
-from django.db import models, transaction, router
+from django.db import models, router, transaction
from django.db.models.constants import LOOKUP_SEP
from django.db.models.fields import BLANK_CHOICE_DASH
from django.db.models.fields.related import ForeignObjectRel
from django.db.models.sql.constants import QUERY_TERMS
-from django.forms.formsets import all_valid, DELETION_FIELD_NAME
-from django.forms.models import (modelform_factory, modelformset_factory,
- inlineformset_factory, BaseInlineFormSet, modelform_defines_fields)
-from django.forms.widgets import SelectMultiple, CheckboxSelectMultiple
+from django.forms.formsets import DELETION_FIELD_NAME, all_valid
+from django.forms.models import (
+ BaseInlineFormSet, inlineformset_factory, modelform_defines_fields,
+ modelform_factory, modelformset_factory,
+)
+from django.forms.widgets import CheckboxSelectMultiple, SelectMultiple
from django.http import Http404, HttpResponseRedirect
from django.http.response import HttpResponseBase
from django.shortcuts import get_object_or_404
@@ -38,14 +43,11 @@ from django.utils.decorators import method_decorator
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.html import escape, escapejs
from django.utils.http import urlencode
-from django.utils.text import capfirst, get_text_list
-from django.utils.translation import string_concat
-from django.utils.translation import ugettext as _
-from django.utils.translation import ungettext
from django.utils.safestring import mark_safe
+from django.utils.text import capfirst, get_text_list
+from django.utils.translation import string_concat, ugettext as _, ungettext
from django.views.decorators.csrf import csrf_protect
-
IS_POPUP_VAR = '_popup'
TO_FIELD_VAR = '_to_field'
diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py
index 8389a3fe09..4b5ee57746 100644
--- a/django/contrib/admin/sites.py
+++ b/django/contrib/admin/sites.py
@@ -1,19 +1,20 @@
from functools import update_wrapper
-from django.http import Http404, HttpResponseRedirect
+
+from django.apps import apps
+from django.conf import settings
from django.contrib.admin import ModelAdmin, actions
from django.contrib.auth import REDIRECT_FIELD_NAME
-from django.views.decorators.csrf import csrf_protect
-from django.db.models.base import ModelBase
-from django.apps import apps
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
-from django.core.urlresolvers import reverse, NoReverseMatch
+from django.core.urlresolvers import NoReverseMatch, reverse
+from django.db.models.base import ModelBase
+from django.http import Http404, HttpResponseRedirect
from django.template.engine import Engine
from django.template.response import TemplateResponse
from django.utils import six
from django.utils.text import capfirst
-from django.utils.translation import ugettext_lazy, ugettext as _
+from django.utils.translation import ugettext as _, ugettext_lazy
from django.views.decorators.cache import never_cache
-from django.conf import settings
+from django.views.decorators.csrf import csrf_protect
system_check_errors = []
diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py
index 6f7c530aa7..55fba4f90c 100644
--- a/django/contrib/admin/templatetags/admin_list.py
+++ b/django/contrib/admin/templatetags/admin_list.py
@@ -2,24 +2,25 @@ from __future__ import unicode_literals
import datetime
-from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
-from django.contrib.admin.utils import (lookup_field, display_for_field,
- display_for_value, label_for_field)
-from django.contrib.admin.views.main import (ALL_VAR, EMPTY_CHANGELIST_VALUE,
- ORDER_VAR, PAGE_VAR, SEARCH_VAR)
from django.contrib.admin.templatetags.admin_static import static
+from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
+from django.contrib.admin.utils import (
+ display_for_field, display_for_value, label_for_field, lookup_field,
+)
+from django.contrib.admin.views.main import (
+ ALL_VAR, EMPTY_CHANGELIST_VALUE, ORDER_VAR, PAGE_VAR, SEARCH_VAR,
+)
from django.core.exceptions import ObjectDoesNotExist
from django.core.urlresolvers import NoReverseMatch
from django.db import models
+from django.template import Library
+from django.template.loader import get_template
from django.utils import formats
+from django.utils.encoding import force_text
from django.utils.html import escapejs, format_html
from django.utils.safestring import mark_safe
from django.utils.text import capfirst
from django.utils.translation import ugettext as _
-from django.utils.encoding import force_text
-from django.template import Library
-from django.template.loader import get_template
-
register = Library()
diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py
index 95cbe634b2..f704ef3af7 100644
--- a/django/contrib/admin/utils.py
+++ b/django/contrib/admin/utils.py
@@ -6,7 +6,7 @@ from collections import defaultdict
from django.contrib.auth import get_permission_codename
from django.core.exceptions import FieldDoesNotExist
-from django.core.urlresolvers import reverse, NoReverseMatch
+from django.core.urlresolvers import NoReverseMatch, reverse
from django.db import models
from django.db.models.constants import LOOKUP_SEP
from django.db.models.deletion import Collector
diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py
index 07457a87fc..fa91ceae3a 100644
--- a/django/contrib/admin/views/main.py
+++ b/django/contrib/admin/views/main.py
@@ -1,22 +1,26 @@
-from collections import OrderedDict
import sys
+from collections import OrderedDict
-from django.core.exceptions import FieldDoesNotExist, SuspiciousOperation, ImproperlyConfigured
+from django.contrib.admin import FieldListFilter
+from django.contrib.admin.exceptions import (
+ DisallowedModelAdminLookup, DisallowedModelAdminToField,
+)
+from django.contrib.admin.options import (
+ IS_POPUP_VAR, TO_FIELD_VAR, IncorrectLookupParameters,
+)
+from django.contrib.admin.utils import (
+ get_fields_from_path, lookup_needs_distinct, prepare_lookup_value, quote,
+)
+from django.core.exceptions import (
+ FieldDoesNotExist, ImproperlyConfigured, SuspiciousOperation,
+)
from django.core.paginator import InvalidPage
from django.core.urlresolvers import reverse
from django.db import models
from django.utils import six
from django.utils.encoding import force_text
-from django.utils.translation import ugettext, ugettext_lazy
from django.utils.http import urlencode
-
-from django.contrib.admin import FieldListFilter
-from django.contrib.admin.exceptions import (
- DisallowedModelAdminLookup, DisallowedModelAdminToField,
-)
-from django.contrib.admin.options import IncorrectLookupParameters, IS_POPUP_VAR, TO_FIELD_VAR
-from django.contrib.admin.utils import (quote, get_fields_from_path,
- lookup_needs_distinct, prepare_lookup_value)
+from django.utils.translation import ugettext, ugettext_lazy
# Changelist settings
ALL_VAR = 'all'
diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py
index 10ac364f74..19b4187b52 100644
--- a/django/contrib/admin/widgets.py
+++ b/django/contrib/admin/widgets.py
@@ -9,15 +9,17 @@ from django import forms
from django.contrib.admin.templatetags.admin_static import static
from django.core.urlresolvers import reverse
from django.db.models.deletion import CASCADE
-from django.forms.widgets import Media, RadioFieldRenderer
from django.forms.utils import flatatt
+from django.forms.widgets import Media, RadioFieldRenderer
from django.template.loader import render_to_string
-from django.utils.html import escape, format_html, format_html_join, smart_urlquote
+from django.utils import six
+from django.utils.encoding import force_text
+from django.utils.html import (
+ escape, format_html, format_html_join, smart_urlquote,
+)
+from django.utils.safestring import mark_safe
from django.utils.text import Truncator
from django.utils.translation import ugettext as _
-from django.utils.safestring import mark_safe
-from django.utils.encoding import force_text
-from django.utils import six
class FilteredSelectMultiple(forms.SelectMultiple):
diff --git a/django/contrib/admindocs/apps.py b/django/contrib/admindocs/apps.py
index 7994f618cd..28ddbfb92a 100644
--- a/django/contrib/admindocs/apps.py
+++ b/django/contrib/admindocs/apps.py
@@ -1,5 +1,4 @@
from django.apps import AppConfig
-
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/admindocs/middleware.py b/django/contrib/admindocs/middleware.py
index 330b76423b..2e4cede0b9 100644
--- a/django/contrib/admindocs/middleware.py
+++ b/django/contrib/admindocs/middleware.py
@@ -1,5 +1,5 @@
-from django.conf import settings
from django import http
+from django.conf import settings
class XViewMiddleware(object):
diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py
index 779a8a446b..f366025f89 100644
--- a/django/contrib/admindocs/utils.py
+++ b/django/contrib/admindocs/utils.py
@@ -1,12 +1,13 @@
"Misc. utility functions/classes for admin documentation generator."
import re
-from email.parser import HeaderParser
from email.errors import HeaderParseError
+from email.parser import HeaderParser
-from django.utils.safestring import mark_safe
from django.core.urlresolvers import reverse
from django.utils.encoding import force_bytes
+from django.utils.safestring import mark_safe
+
try:
import docutils.core
import docutils.nodes
diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py
index 4ce64c3a53..91ca143508 100644
--- a/django/contrib/admindocs/views.py
+++ b/django/contrib/admindocs/views.py
@@ -1,23 +1,25 @@
-from importlib import import_module
import inspect
import os
import re
+from importlib import import_module
from django.apps import apps
from django.conf import settings
from django.contrib import admin
from django.contrib.admin.views.decorators import staff_member_required
-from django.db import models
+from django.contrib.admindocs import utils
+from django.core import urlresolvers
from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist
+from django.db import models
from django.http import Http404
-from django.core import urlresolvers
-from django.contrib.admindocs import utils
-from django.template.base import (builtins, get_library,
- get_templatetags_modules, InvalidTemplateLibrary, libraries)
+from django.template.base import (
+ InvalidTemplateLibrary, builtins, get_library, get_templatetags_modules,
+ libraries,
+)
from django.template.engine import Engine
-from django.utils.decorators import method_decorator
-from django.utils._os import upath
from django.utils import six
+from django.utils._os import upath
+from django.utils.decorators import method_decorator
from django.utils.translation import ugettext as _
from django.views.generic import TemplateView
diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py
index 90394c8f09..b791609031 100644
--- a/django/contrib/auth/admin.py
+++ b/django/contrib/auth/admin.py
@@ -1,19 +1,19 @@
-from django.db import transaction
from django.conf import settings
from django.conf.urls import url
-from django.contrib import admin
+from django.contrib import admin, messages
from django.contrib.admin.options import IS_POPUP_VAR
from django.contrib.auth import update_session_auth_hash
-from django.contrib.auth.forms import (UserCreationForm, UserChangeForm,
- AdminPasswordChangeForm)
-from django.contrib.auth.models import User, Group
-from django.contrib import messages
+from django.contrib.auth.forms import (
+ AdminPasswordChangeForm, UserChangeForm, UserCreationForm,
+)
+from django.contrib.auth.models import Group, User
from django.core.exceptions import PermissionDenied
-from django.http import HttpResponseRedirect, Http404
+from django.db import transaction
+from django.http import Http404, HttpResponseRedirect
from django.shortcuts import get_object_or_404
from django.template.response import TemplateResponse
-from django.utils.html import escape
from django.utils.decorators import method_decorator
+from django.utils.html import escape
from django.utils.translation import ugettext, ugettext_lazy as _
from django.views.decorators.csrf import csrf_protect
from django.views.decorators.debug import sensitive_post_parameters
diff --git a/django/contrib/auth/apps.py b/django/contrib/auth/apps.py
index bbfcb7dbd1..109a34dff6 100644
--- a/django/contrib/auth/apps.py
+++ b/django/contrib/auth/apps.py
@@ -1,6 +1,6 @@
from django.apps import AppConfig
-from django.core import checks
from django.contrib.auth.checks import check_user_model
+from django.core import checks
from django.db.models.signals import post_migrate
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py
index 00a772fd4f..9f08259038 100644
--- a/django/contrib/auth/backends.py
+++ b/django/contrib/auth/backends.py
@@ -1,4 +1,5 @@
from __future__ import unicode_literals
+
from django.contrib.auth import get_user_model
from django.contrib.auth.models import Permission
diff --git a/django/contrib/auth/decorators.py b/django/contrib/auth/decorators.py
index 99e2983e63..9b2504b33c 100644
--- a/django/contrib/auth/decorators.py
+++ b/django/contrib/auth/decorators.py
@@ -1,10 +1,11 @@
from functools import wraps
+
from django.conf import settings
from django.contrib.auth import REDIRECT_FIELD_NAME
from django.core.exceptions import PermissionDenied
+from django.shortcuts import resolve_url
from django.utils.decorators import available_attrs
from django.utils.six.moves.urllib.parse import urlparse
-from django.shortcuts import resolve_url
def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME):
diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py
index 3d19b2247e..cc3be5ba0b 100644
--- a/django/contrib/auth/forms.py
+++ b/django/contrib/auth/forms.py
@@ -3,6 +3,13 @@ from __future__ import unicode_literals
from collections import OrderedDict
from django import forms
+from django.contrib.auth import authenticate, get_user_model
+from django.contrib.auth.hashers import (
+ UNUSABLE_PASSWORD_PREFIX, identify_hasher,
+)
+from django.contrib.auth.models import User
+from django.contrib.auth.tokens import default_token_generator
+from django.contrib.sites.shortcuts import get_current_site
from django.core.mail import EmailMultiAlternatives
from django.forms.utils import flatatt
from django.template import loader
@@ -13,12 +20,6 @@ from django.utils.safestring import mark_safe
from django.utils.text import capfirst
from django.utils.translation import ugettext, ugettext_lazy as _
-from django.contrib.auth import authenticate, get_user_model
-from django.contrib.auth.models import User
-from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX, identify_hasher
-from django.contrib.auth.tokens import default_token_generator
-from django.contrib.sites.shortcuts import get_current_site
-
class ReadOnlyPasswordHashWidget(forms.Widget):
def render(self, name, value, attrs):
diff --git a/django/contrib/auth/handlers/modwsgi.py b/django/contrib/auth/handlers/modwsgi.py
index 8ada9750f1..6b91ed9c6e 100644
--- a/django/contrib/auth/handlers/modwsgi.py
+++ b/django/contrib/auth/handlers/modwsgi.py
@@ -1,5 +1,5 @@
-from django.contrib import auth
from django import db
+from django.contrib import auth
from django.utils.encoding import force_bytes
diff --git a/django/contrib/auth/hashers.py b/django/contrib/auth/hashers.py
index 44ebf89c36..59676f6562 100644
--- a/django/contrib/auth/hashers.py
+++ b/django/contrib/auth/hashers.py
@@ -2,22 +2,22 @@ from __future__ import unicode_literals
import base64
import binascii
-from collections import OrderedDict
import hashlib
import importlib
+from collections import OrderedDict
-from django.dispatch import receiver
from django.conf import settings
-from django.core.signals import setting_changed
-from django.utils.encoding import force_bytes, force_str, force_text
from django.core.exceptions import ImproperlyConfigured
-from django.utils.crypto import (
- pbkdf2, constant_time_compare, get_random_string)
+from django.core.signals import setting_changed
+from django.dispatch import receiver
from django.utils import lru_cache
+from django.utils.crypto import (
+ constant_time_compare, get_random_string, pbkdf2,
+)
+from django.utils.encoding import force_bytes, force_str, force_text
from django.utils.module_loading import import_string
from django.utils.translation import ugettext_noop as _
-
UNUSABLE_PASSWORD_PREFIX = '!' # This will never be a valid encoded hash
UNUSABLE_PASSWORD_SUFFIX_LENGTH = 40 # number of random chars to add after UNUSABLE_PASSWORD_PREFIX
diff --git a/django/contrib/auth/migrations/0001_initial.py b/django/contrib/auth/migrations/0001_initial.py
index 33c8e00153..a58f73ab1a 100644
--- a/django/contrib/auth/migrations/0001_initial.py
+++ b/django/contrib/auth/migrations/0001_initial.py
@@ -1,10 +1,10 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
+import django.contrib.auth.models
from django.core import validators
-from django.db import models, migrations
+from django.db import migrations, models
from django.utils import timezone
-import django.contrib.auth.models
class Migration(migrations.Migration):
diff --git a/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py b/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py
index 8e82223237..8b58e7814b 100644
--- a/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py
+++ b/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/auth/migrations/0003_alter_user_email_max_length.py b/django/contrib/auth/migrations/0003_alter_user_email_max_length.py
index a9b8058089..0a082f2656 100644
--- a/django/contrib/auth/migrations/0003_alter_user_email_max_length.py
+++ b/django/contrib/auth/migrations/0003_alter_user_email_max_length.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/auth/migrations/0004_alter_user_username_opts.py b/django/contrib/auth/migrations/0004_alter_user_username_opts.py
index 80a156e001..0f7bfdf3a7 100644
--- a/django/contrib/auth/migrations/0004_alter_user_username_opts.py
+++ b/django/contrib/auth/migrations/0004_alter_user_username_opts.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
import django.core.validators
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/auth/migrations/0005_alter_user_last_login_null.py b/django/contrib/auth/migrations/0005_alter_user_last_login_null.py
index 128a4e4962..b8b9289787 100644
--- a/django/contrib/auth/migrations/0005_alter_user_last_login_null.py
+++ b/django/contrib/auth/migrations/0005_alter_user_last_login_null.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py
index 89b3054b70..4dc49c2d0c 100644
--- a/django/contrib/auth/models.py
+++ b/django/contrib/auth/models.py
@@ -1,21 +1,20 @@
from __future__ import unicode_literals
+from django.contrib import auth
+from django.contrib.auth.hashers import (
+ check_password, is_password_usable, make_password,
+)
+from django.contrib.auth.signals import user_logged_in
+from django.contrib.contenttypes.models import ContentType
+from django.core import validators
from django.core.exceptions import PermissionDenied
from django.core.mail import send_mail
-from django.core import validators
from django.db import models
from django.db.models.manager import EmptyManager
+from django.utils import six, timezone
from django.utils.crypto import get_random_string, salted_hmac
-from django.utils import six
-from django.utils.translation import ugettext_lazy as _
-from django.utils import timezone
-
-from django.contrib import auth
-from django.contrib.auth.hashers import (
- check_password, make_password, is_password_usable)
-from django.contrib.auth.signals import user_logged_in
-from django.contrib.contenttypes.models import ContentType
from django.utils.encoding import python_2_unicode_compatible
+from django.utils.translation import ugettext_lazy as _
def update_last_login(sender, user, **kwargs):
diff --git a/django/contrib/auth/tests/backend_alias.py b/django/contrib/auth/tests/backend_alias.py
index 1f31f7a16a..7314bac4ee 100644
--- a/django/contrib/auth/tests/backend_alias.py
+++ b/django/contrib/auth/tests/backend_alias.py
@@ -1,2 +1,4 @@
# For testing that auth backends can be referenced using a convenience import
-from django.contrib.auth.tests.test_auth_backends import ImportedModelBackend # NOQA
+from django.contrib.auth.tests.test_auth_backends import ImportedModelBackend
+
+__all__ = ['ImportedModelBackend']
diff --git a/django/contrib/auth/tests/custom_user.py b/django/contrib/auth/tests/custom_user.py
index c856431bba..e7ce6162e9 100644
--- a/django/contrib/auth/tests/custom_user.py
+++ b/django/contrib/auth/tests/custom_user.py
@@ -1,13 +1,8 @@
-from django.db import models
from django.contrib.auth.models import (
- BaseUserManager,
- AbstractBaseUser,
- AbstractUser,
- UserManager,
- PermissionsMixin,
- Group,
- Permission,
+ AbstractBaseUser, AbstractUser, BaseUserManager, Group, Permission,
+ PermissionsMixin, UserManager,
)
+from django.db import models
# The custom User uses email as the unique identifier, and requires
diff --git a/django/contrib/auth/tests/settings.py b/django/contrib/auth/tests/settings.py
index b3e1eff156..7da6144d4b 100644
--- a/django/contrib/auth/tests/settings.py
+++ b/django/contrib/auth/tests/settings.py
@@ -2,7 +2,6 @@ import os
from django.utils._os import upath
-
AUTH_MIDDLEWARE_CLASSES = [
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
diff --git a/django/contrib/auth/tests/test_auth_backends.py b/django/contrib/auth/tests/test_auth_backends.py
index 383fae759e..2abdc4d797 100644
--- a/django/contrib/auth/tests/test_auth_backends.py
+++ b/django/contrib/auth/tests/test_auth_backends.py
@@ -1,16 +1,19 @@
from __future__ import unicode_literals
+
from datetime import date
+from django.contrib.auth import BACKEND_SESSION_KEY, authenticate, get_user
from django.contrib.auth.backends import ModelBackend
-from django.contrib.auth.models import User, Group, Permission, AnonymousUser
+from django.contrib.auth.hashers import MD5PasswordHasher
+from django.contrib.auth.models import AnonymousUser, Group, Permission, User
+from django.contrib.auth.tests.custom_user import (
+ CustomPermissionsUser, CustomUser, ExtensionUser,
+)
from django.contrib.auth.tests.utils import skipIfCustomUser
-from django.contrib.auth.tests.custom_user import ExtensionUser, CustomPermissionsUser, CustomUser
from django.contrib.contenttypes.models import ContentType
from django.core.exceptions import ImproperlyConfigured, PermissionDenied
-from django.contrib.auth import authenticate, BACKEND_SESSION_KEY, get_user
from django.http import HttpRequest
from django.test import TestCase, modify_settings, override_settings
-from django.contrib.auth.hashers import MD5PasswordHasher
class CountingMD5PasswordHasher(MD5PasswordHasher):
diff --git a/django/contrib/auth/tests/test_basic.py b/django/contrib/auth/tests/test_basic.py
index fed94db82f..ca7db755e6 100644
--- a/django/contrib/auth/tests/test_basic.py
+++ b/django/contrib/auth/tests/test_basic.py
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
from django.apps import apps
from django.contrib.auth import get_user_model
-from django.contrib.auth.models import User, AnonymousUser
+from django.contrib.auth.models import AnonymousUser, User
from django.contrib.auth.tests.custom_user import CustomUser
from django.contrib.auth.tests.utils import skipIfCustomUser
from django.core.exceptions import ImproperlyConfigured
diff --git a/django/contrib/auth/tests/test_context_processors.py b/django/contrib/auth/tests/test_context_processors.py
index 2f7e5ab4b2..3e1c19e91d 100644
--- a/django/contrib/auth/tests/test_context_processors.py
+++ b/django/contrib/auth/tests/test_context_processors.py
@@ -1,7 +1,7 @@
from django.contrib.auth import authenticate
-from django.contrib.auth.models import User, Permission
+from django.contrib.auth.context_processors import PermLookupDict, PermWrapper
+from django.contrib.auth.models import Permission, User
from django.contrib.contenttypes.models import ContentType
-from django.contrib.auth.context_processors import PermWrapper, PermLookupDict
from django.db.models import Q
from django.test import TestCase, override_settings
diff --git a/django/contrib/auth/tests/test_forms.py b/django/contrib/auth/tests/test_forms.py
index 601c0868d7..6437ef6b2e 100644
--- a/django/contrib/auth/tests/test_forms.py
+++ b/django/contrib/auth/tests/test_forms.py
@@ -3,16 +3,18 @@ from __future__ import unicode_literals
import re
from django import forms
+from django.contrib.auth.forms import (
+ AuthenticationForm, PasswordChangeForm, PasswordResetForm,
+ ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget, SetPasswordForm,
+ UserChangeForm, UserCreationForm,
+)
from django.contrib.auth.models import User
-from django.contrib.auth.forms import (UserCreationForm, AuthenticationForm,
- PasswordChangeForm, SetPasswordForm, UserChangeForm, PasswordResetForm,
- ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget)
from django.core import mail
from django.core.mail import EmailMultiAlternatives
-from django.forms.fields import Field, CharField
+from django.forms.fields import CharField, Field
from django.test import TestCase, override_settings
-from django.utils.encoding import force_text
from django.utils import translation
+from django.utils.encoding import force_text
from django.utils.text import capfirst
from django.utils.translation import ugettext as _
diff --git a/django/contrib/auth/tests/test_handlers.py b/django/contrib/auth/tests/test_handlers.py
index f4fa3030de..a6a4f9cd06 100644
--- a/django/contrib/auth/tests/test_handlers.py
+++ b/django/contrib/auth/tests/test_handlers.py
@@ -1,11 +1,12 @@
from __future__ import unicode_literals
-from django.contrib.auth.handlers.modwsgi import check_password, groups_for_user
-from django.contrib.auth.models import User, Group
+from django.contrib.auth.handlers.modwsgi import (
+ check_password, groups_for_user,
+)
+from django.contrib.auth.models import Group, User
from django.contrib.auth.tests.custom_user import CustomUser
from django.contrib.auth.tests.utils import skipIfCustomUser
-from django.test import TransactionTestCase
-from django.test import override_settings
+from django.test import TransactionTestCase, override_settings
# This must be a TransactionTestCase because the WSGI auth handler performs
diff --git a/django/contrib/auth/tests/test_hashers.py b/django/contrib/auth/tests/test_hashers.py
index 740ba462a2..52253d6efb 100644
--- a/django/contrib/auth/tests/test_hashers.py
+++ b/django/contrib/auth/tests/test_hashers.py
@@ -4,14 +4,16 @@ from __future__ import unicode_literals
from unittest import skipUnless
from django.conf.global_settings import PASSWORD_HASHERS
-from django.contrib.auth.hashers import (is_password_usable, BasePasswordHasher,
- check_password, make_password, PBKDF2PasswordHasher, PBKDF2SHA1PasswordHasher,
- get_hasher, identify_hasher, UNUSABLE_PASSWORD_PREFIX, UNUSABLE_PASSWORD_SUFFIX_LENGTH)
+from django.contrib.auth.hashers import (
+ UNUSABLE_PASSWORD_PREFIX, UNUSABLE_PASSWORD_SUFFIX_LENGTH,
+ BasePasswordHasher, PBKDF2PasswordHasher, PBKDF2SHA1PasswordHasher,
+ check_password, get_hasher, identify_hasher, is_password_usable,
+ make_password,
+)
from django.test import SimpleTestCase
from django.test.utils import override_settings
from django.utils import six
-
try:
import crypt
except ImportError:
diff --git a/django/contrib/auth/tests/test_management.py b/django/contrib/auth/tests/test_management.py
index 24e4317392..1a210a1915 100644
--- a/django/contrib/auth/tests/test_management.py
+++ b/django/contrib/auth/tests/test_management.py
@@ -1,23 +1,28 @@
from __future__ import unicode_literals
-from datetime import date
import locale
import sys
+from datetime import date
from django.apps import apps
-from django.contrib.auth import models, management
+from django.contrib.auth import management, models
from django.contrib.auth.checks import check_user_model
from django.contrib.auth.management import create_permissions
-from django.contrib.auth.management.commands import changepassword, createsuperuser
-from django.contrib.auth.models import User, Group
-from django.contrib.auth.tests.custom_user import CustomUser, CustomUserWithFK, Email
+from django.contrib.auth.management.commands import (
+ changepassword, createsuperuser,
+)
+from django.contrib.auth.models import Group, User
+from django.contrib.auth.tests.custom_user import (
+ CustomUser, CustomUserWithFK, Email,
+)
from django.contrib.auth.tests.utils import skipIfCustomUser
from django.contrib.contenttypes.models import ContentType
-from django.core import checks
-from django.core import exceptions
+from django.core import checks, exceptions
from django.core.management import call_command
from django.core.management.base import CommandError
-from django.test import TestCase, override_settings, override_system_checks, skipUnlessDBFeature
+from django.test import (
+ TestCase, override_settings, override_system_checks, skipUnlessDBFeature,
+)
from django.utils import six
from django.utils.encoding import force_str
diff --git a/django/contrib/auth/tests/test_models.py b/django/contrib/auth/tests/test_models.py
index b0a35a445a..ee51b15a98 100644
--- a/django/contrib/auth/tests/test_models.py
+++ b/django/contrib/auth/tests/test_models.py
@@ -1,5 +1,7 @@
from django.contrib.auth import get_user_model
-from django.contrib.auth.models import AbstractUser, Group, Permission, User, UserManager
+from django.contrib.auth.models import (
+ AbstractUser, Group, Permission, User, UserManager,
+)
from django.contrib.auth.tests.utils import skipIfCustomUser
from django.contrib.contenttypes.models import ContentType
from django.core import mail
diff --git a/django/contrib/auth/tests/test_signals.py b/django/contrib/auth/tests/test_signals.py
index e3c89f2366..909c28a36d 100644
--- a/django/contrib/auth/tests/test_signals.py
+++ b/django/contrib/auth/tests/test_signals.py
@@ -1,9 +1,8 @@
from django.contrib.auth import signals
from django.contrib.auth.models import User
from django.contrib.auth.tests.utils import skipIfCustomUser
-from django.test import TestCase
+from django.test import TestCase, override_settings
from django.test.client import RequestFactory
-from django.test import override_settings
@skipIfCustomUser
diff --git a/django/contrib/auth/tests/test_templates.py b/django/contrib/auth/tests/test_templates.py
index 409a1705f3..ab3aea42db 100644
--- a/django/contrib/auth/tests/test_templates.py
+++ b/django/contrib/auth/tests/test_templates.py
@@ -3,11 +3,10 @@ from django.contrib.auth.models import User
from django.contrib.auth.tests.utils import skipIfCustomUser
from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.contrib.auth.views import (
- password_reset, password_reset_done, password_reset_confirm,
- password_reset_complete, password_change, password_change_done,
+ password_change, password_change_done, password_reset,
+ password_reset_complete, password_reset_confirm, password_reset_done,
)
-from django.test import RequestFactory, TestCase
-from django.test import override_settings
+from django.test import RequestFactory, TestCase, override_settings
from django.utils.encoding import force_bytes, force_text
from django.utils.http import urlsafe_base64_encode
diff --git a/django/contrib/auth/tests/test_tokens.py b/django/contrib/auth/tests/test_tokens.py
index 583546ab3a..b9433bdcfa 100644
--- a/django/contrib/auth/tests/test_tokens.py
+++ b/django/contrib/auth/tests/test_tokens.py
@@ -1,11 +1,11 @@
-from datetime import date, timedelta
import sys
import unittest
+from datetime import date, timedelta
from django.conf import settings
from django.contrib.auth.models import User
-from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.contrib.auth.tests.utils import skipIfCustomUser
+from django.contrib.auth.tokens import PasswordResetTokenGenerator
from django.test import TestCase
diff --git a/django/contrib/auth/tests/test_views.py b/django/contrib/auth/tests/test_views.py
index fd01909c2b..c065d30dbe 100644
--- a/django/contrib/auth/tests/test_views.py
+++ b/django/contrib/auth/tests/test_views.py
@@ -1,33 +1,34 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from importlib import import_module
import itertools
import re
+from importlib import import_module
from django.apps import apps
from django.conf import settings
-from django.contrib.sites.requests import RequestSite
from django.contrib.admin.models import LogEntry
-from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME
-from django.contrib.auth.forms import (AuthenticationForm, PasswordChangeForm,
- SetPasswordForm)
+from django.contrib.auth import REDIRECT_FIELD_NAME, SESSION_KEY
+from django.contrib.auth.forms import (
+ AuthenticationForm, PasswordChangeForm, SetPasswordForm,
+)
from django.contrib.auth.models import User
from django.contrib.auth.views import login as login_view, redirect_to_login
+from django.contrib.sessions.middleware import SessionMiddleware
+from django.contrib.sites.requests import RequestSite
from django.core import mail
from django.core.urlresolvers import NoReverseMatch, reverse, reverse_lazy
-from django.http import QueryDict, HttpRequest
-from django.utils.deprecation import RemovedInDjango20Warning
-from django.utils.encoding import force_text
-from django.utils.http import urlquote
-from django.utils.six.moves.urllib.parse import urlparse, ParseResult
-from django.utils.translation import LANGUAGE_SESSION_KEY
+from django.http import HttpRequest, QueryDict
+from django.middleware.csrf import CsrfViewMiddleware
from django.test import (
TestCase, ignore_warnings, modify_settings, override_settings,
)
from django.test.utils import patch_logger
-from django.middleware.csrf import CsrfViewMiddleware
-from django.contrib.sessions.middleware import SessionMiddleware
+from django.utils.deprecation import RemovedInDjango20Warning
+from django.utils.encoding import force_text
+from django.utils.http import urlquote
+from django.utils.six.moves.urllib.parse import ParseResult, urlparse
+from django.utils.translation import LANGUAGE_SESSION_KEY
# Needed so model is installed when tests are run independently:
from .custom_user import CustomUser # NOQA
diff --git a/django/contrib/auth/tests/urls.py b/django/contrib/auth/tests/urls.py
index 41e742a93b..6f83e0f420 100644
--- a/django/contrib/auth/tests/urls.py
+++ b/django/contrib/auth/tests/urls.py
@@ -1,13 +1,13 @@
-from django.conf.urls import url, include
+from django.conf.urls import include, url
from django.contrib import admin
-from django.contrib.auth.forms import AuthenticationForm
-from django.contrib.auth.urls import urlpatterns
from django.contrib.auth import views
from django.contrib.auth.decorators import login_required
+from django.contrib.auth.forms import AuthenticationForm
+from django.contrib.auth.urls import urlpatterns
from django.contrib.messages.api import info
-from django.http import HttpResponse, HttpRequest
+from django.http import HttpRequest, HttpResponse
from django.shortcuts import render
-from django.template import Template, RequestContext
+from django.template import RequestContext, Template
from django.views.decorators.cache import never_cache
diff --git a/django/contrib/auth/tests/urls_admin.py b/django/contrib/auth/tests/urls_admin.py
index 49d6f38447..8d2fe3fd10 100644
--- a/django/contrib/auth/tests/urls_admin.py
+++ b/django/contrib/auth/tests/urls_admin.py
@@ -4,8 +4,8 @@ Test URLs for auth admins.
from django.conf.urls import include, url
from django.contrib import admin
-from django.contrib.auth.admin import UserAdmin, GroupAdmin
-from django.contrib.auth.models import User, Group
+from django.contrib.auth.admin import GroupAdmin, UserAdmin
+from django.contrib.auth.models import Group, User
from django.contrib.auth.urls import urlpatterns
# Create a silo'd admin site for just the user/group admins.
diff --git a/django/contrib/auth/tokens.py b/django/contrib/auth/tokens.py
index 89100daeb2..b925c21eff 100644
--- a/django/contrib/auth/tokens.py
+++ b/django/contrib/auth/tokens.py
@@ -1,8 +1,9 @@
from datetime import date
+
from django.conf import settings
-from django.utils.http import int_to_base36, base36_to_int
-from django.utils.crypto import constant_time_compare, salted_hmac
from django.utils import six
+from django.utils.crypto import constant_time_compare, salted_hmac
+from django.utils.http import base36_to_int, int_to_base36
class PasswordResetTokenGenerator(object):
diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py
index 348fca8745..deedb7f232 100644
--- a/django/contrib/auth/views.py
+++ b/django/contrib/auth/views.py
@@ -1,25 +1,31 @@
import warnings
from django.conf import settings
+# Avoid shadowing the login() and logout() views below.
+from django.contrib.auth import (
+ REDIRECT_FIELD_NAME, get_user_model, login as auth_login,
+ logout as auth_logout, update_session_auth_hash,
+)
+from django.contrib.auth.decorators import login_required
+from django.contrib.auth.forms import (
+ AuthenticationForm, PasswordChangeForm, PasswordResetForm, SetPasswordForm,
+)
+from django.contrib.auth.tokens import default_token_generator
+from django.contrib.sites.shortcuts import get_current_site
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, QueryDict
+from django.shortcuts import resolve_url
from django.template.response import TemplateResponse
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.http import is_safe_url, urlsafe_base64_decode
-from django.utils.translation import ugettext as _
from django.utils.six.moves.urllib.parse import urlparse, urlunparse
-from django.shortcuts import resolve_url
-from django.views.decorators.debug import sensitive_post_parameters
+from django.utils.translation import ugettext as _
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_protect
+from django.views.decorators.debug import sensitive_post_parameters
+
# Avoid shadowing the login() and logout() views below.
-from django.contrib.auth import (REDIRECT_FIELD_NAME, login as auth_login,
- logout as auth_logout, get_user_model, update_session_auth_hash)
-from django.contrib.auth.decorators import login_required
-from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm, SetPasswordForm, PasswordChangeForm
-from django.contrib.auth.tokens import default_token_generator
-from django.contrib.sites.shortcuts import get_current_site
@sensitive_post_parameters()
diff --git a/django/contrib/contenttypes/admin.py b/django/contrib/contenttypes/admin.py
index 3db9d2d612..85bf3227e3 100644
--- a/django/contrib/contenttypes/admin.py
+++ b/django/contrib/contenttypes/admin.py
@@ -6,7 +6,7 @@ from django.contrib.admin.checks import InlineModelAdminChecks
from django.contrib.admin.options import InlineModelAdmin, flatten_fieldsets
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.forms import (
- BaseGenericInlineFormSet, generic_inlineformset_factory
+ BaseGenericInlineFormSet, generic_inlineformset_factory,
)
from django.core import checks
from django.core.exceptions import FieldDoesNotExist
diff --git a/django/contrib/contenttypes/checks.py b/django/contrib/contenttypes/checks.py
index 890859505a..1b3df21353 100644
--- a/django/contrib/contenttypes/checks.py
+++ b/django/contrib/contenttypes/checks.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.utils import six
from django.apps import apps
+from django.utils import six
def check_generic_foreign_keys(**kwargs):
diff --git a/django/contrib/contenttypes/fields.py b/django/contrib/contenttypes/fields.py
index b20d38768d..c11d6284c0 100644
--- a/django/contrib/contenttypes/fields.py
+++ b/django/contrib/contenttypes/fields.py
@@ -2,16 +2,15 @@ from __future__ import unicode_literals
from collections import defaultdict
+from django.contrib.contenttypes.models import ContentType
from django.core import checks
from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist
-from django.db import connection
-from django.db import models, router, transaction, DEFAULT_DB_ALIAS
-from django.db.models import signals, DO_NOTHING
+from django.db import DEFAULT_DB_ALIAS, connection, models, router, transaction
+from django.db.models import DO_NOTHING, signals
from django.db.models.base import ModelBase
from django.db.models.fields.related import ForeignObject, ForeignObjectRel
from django.db.models.query_utils import PathInfo
-from django.contrib.contenttypes.models import ContentType
-from django.utils.encoding import smart_text, python_2_unicode_compatible
+from django.utils.encoding import python_2_unicode_compatible, smart_text
@python_2_unicode_compatible
diff --git a/django/contrib/contenttypes/forms.py b/django/contrib/contenttypes/forms.py
index 693628d3de..e590c3db05 100644
--- a/django/contrib/contenttypes/forms.py
+++ b/django/contrib/contenttypes/forms.py
@@ -1,9 +1,9 @@
from __future__ import unicode_literals
+from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.forms import ModelForm, modelformset_factory
from django.forms.models import BaseModelFormSet
-from django.contrib.contenttypes.models import ContentType
class BaseGenericInlineFormSet(BaseModelFormSet):
diff --git a/django/contrib/contenttypes/migrations/0001_initial.py b/django/contrib/contenttypes/migrations/0001_initial.py
index 09519f1d75..68190b2a2b 100644
--- a/django/contrib/contenttypes/migrations/0001_initial.py
+++ b/django/contrib/contenttypes/migrations/0001_initial.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
import django.contrib.contenttypes.models
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py b/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py
index 1b91437dbc..b2e18846b9 100644
--- a/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py
+++ b/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
def add_legacy_name(apps, schema_editor):
diff --git a/django/contrib/contenttypes/models.py b/django/contrib/contenttypes/models.py
index 684380c832..5205ec80f9 100644
--- a/django/contrib/contenttypes/models.py
+++ b/django/contrib/contenttypes/models.py
@@ -5,9 +5,9 @@ import warnings
from django.apps import apps
from django.db import models
from django.db.utils import OperationalError, ProgrammingError
-from django.utils.translation import ugettext_lazy as _
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text, python_2_unicode_compatible
+from django.utils.translation import ugettext_lazy as _
class ContentTypeManager(models.Manager):
diff --git a/django/contrib/contenttypes/tests/tests.py b/django/contrib/contenttypes/tests/tests.py
index f41732b6b5..aed559c5fd 100644
--- a/django/contrib/contenttypes/tests/tests.py
+++ b/django/contrib/contenttypes/tests/tests.py
@@ -6,11 +6,14 @@ from django.contrib.contenttypes.models import ContentType
from django.contrib.contenttypes.views import shortcut
from django.contrib.sites.shortcuts import get_current_site
from django.core.management import call_command
-from django.http import HttpRequest, Http404
+from django.http import Http404, HttpRequest
from django.test import TestCase, override_settings, skipUnlessDBFeature
from django.utils import six
-from .models import ConcreteModel, ProxyModel, FooWithoutUrl, FooWithUrl, FooWithBrokenAbsoluteUrl
+from .models import (
+ ConcreteModel, FooWithBrokenAbsoluteUrl, FooWithoutUrl, FooWithUrl,
+ ProxyModel,
+)
class ContentTypesTests(TestCase):
diff --git a/django/contrib/flatpages/admin.py b/django/contrib/flatpages/admin.py
index 5711a9466e..06ed824c45 100644
--- a/django/contrib/flatpages/admin.py
+++ b/django/contrib/flatpages/admin.py
@@ -1,7 +1,7 @@
from django.contrib import admin
+from django.contrib.flatpages.forms import FlatpageForm
from django.contrib.flatpages.models import FlatPage
from django.utils.translation import ugettext_lazy as _
-from django.contrib.flatpages.forms import FlatpageForm
class FlatPageAdmin(admin.ModelAdmin):
diff --git a/django/contrib/flatpages/apps.py b/django/contrib/flatpages/apps.py
index c35bebf721..ac966c81f5 100644
--- a/django/contrib/flatpages/apps.py
+++ b/django/contrib/flatpages/apps.py
@@ -1,5 +1,4 @@
from django.apps import AppConfig
-
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/flatpages/middleware.py b/django/contrib/flatpages/middleware.py
index 9fe595d0cf..32d881ffa4 100644
--- a/django/contrib/flatpages/middleware.py
+++ b/django/contrib/flatpages/middleware.py
@@ -1,6 +1,6 @@
+from django.conf import settings
from django.contrib.flatpages.views import flatpage
from django.http import Http404
-from django.conf import settings
class FlatpageFallbackMiddleware(object):
diff --git a/django/contrib/flatpages/migrations/0001_initial.py b/django/contrib/flatpages/migrations/0001_initial.py
index 5f583a1051..fe0a3f3374 100644
--- a/django/contrib/flatpages/migrations/0001_initial.py
+++ b/django/contrib/flatpages/migrations/0001_initial.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/flatpages/models.py b/django/contrib/flatpages/models.py
index 1bddb0b8d2..eac4edd122 100644
--- a/django/contrib/flatpages/models.py
+++ b/django/contrib/flatpages/models.py
@@ -1,10 +1,10 @@
from __future__ import unicode_literals
-from django.db import models
from django.contrib.sites.models import Site
from django.core.urlresolvers import get_script_prefix
-from django.utils.translation import ugettext_lazy as _
+from django.db import models
from django.utils.encoding import iri_to_uri, python_2_unicode_compatible
+from django.utils.translation import ugettext_lazy as _
@python_2_unicode_compatible
diff --git a/django/contrib/flatpages/templatetags/flatpages.py b/django/contrib/flatpages/templatetags/flatpages.py
index d7ced97d17..db82c4aa2c 100644
--- a/django/contrib/flatpages/templatetags/flatpages.py
+++ b/django/contrib/flatpages/templatetags/flatpages.py
@@ -3,7 +3,6 @@ from django.conf import settings
from django.contrib.flatpages.models import FlatPage
from django.contrib.sites.shortcuts import get_current_site
-
register = template.Library()
diff --git a/django/contrib/flatpages/tests/settings.py b/django/contrib/flatpages/tests/settings.py
index b10ebe564c..ad888f9d95 100644
--- a/django/contrib/flatpages/tests/settings.py
+++ b/django/contrib/flatpages/tests/settings.py
@@ -1,6 +1,5 @@
import os
-
FLATPAGES_TEMPLATES = [{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(os.path.dirname(__file__), 'templates')],
diff --git a/django/contrib/flatpages/tests/test_csrf.py b/django/contrib/flatpages/tests/test_csrf.py
index b9d7f32327..f8616b3913 100644
--- a/django/contrib/flatpages/tests/test_csrf.py
+++ b/django/contrib/flatpages/tests/test_csrf.py
@@ -1,7 +1,6 @@
from django.contrib.auth.models import User
from django.contrib.auth.tests.utils import skipIfCustomUser
-from django.test import TestCase, Client
-from django.test import override_settings
+from django.test import Client, TestCase, override_settings
from .settings import FLATPAGES_TEMPLATES
diff --git a/django/contrib/flatpages/tests/test_models.py b/django/contrib/flatpages/tests/test_models.py
index f091f3e0ea..c48dc38637 100644
--- a/django/contrib/flatpages/tests/test_models.py
+++ b/django/contrib/flatpages/tests/test_models.py
@@ -2,8 +2,8 @@
from __future__ import unicode_literals
-from django.core.urlresolvers import set_script_prefix, clear_script_prefix
from django.contrib.flatpages.models import FlatPage
+from django.core.urlresolvers import clear_script_prefix, set_script_prefix
from django.test import TestCase
diff --git a/django/contrib/flatpages/tests/test_templatetags.py b/django/contrib/flatpages/tests/test_templatetags.py
index a4a65ce840..209332b79c 100644
--- a/django/contrib/flatpages/tests/test_templatetags.py
+++ b/django/contrib/flatpages/tests/test_templatetags.py
@@ -1,6 +1,6 @@
from django.contrib.auth.models import AnonymousUser, User
from django.contrib.auth.tests.utils import skipIfCustomUser
-from django.template import Template, Context, TemplateSyntaxError
+from django.template import Context, Template, TemplateSyntaxError
from django.test import TestCase, override_settings
from .settings import FLATPAGES_TEMPLATES
diff --git a/django/contrib/gis/admin/options.py b/django/contrib/gis/admin/options.py
index 8ca0d92c29..f9412336e3 100644
--- a/django/contrib/gis/admin/options.py
+++ b/django/contrib/gis/admin/options.py
@@ -1,7 +1,7 @@
from django.contrib.admin import ModelAdmin
from django.contrib.gis.admin.widgets import OpenLayersWidget
-from django.contrib.gis.gdal import HAS_GDAL, OGRGeomType
from django.contrib.gis.db import models
+from django.contrib.gis.gdal import HAS_GDAL, OGRGeomType
class GeoModelAdmin(ModelAdmin):
diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py
index c85e7a6125..52b624a112 100644
--- a/django/contrib/gis/admin/widgets.py
+++ b/django/contrib/gis/admin/widgets.py
@@ -1,12 +1,10 @@
import logging
+from django.contrib.gis.gdal import GDALException
+from django.contrib.gis.geos import GEOSException, GEOSGeometry
from django.forms.widgets import Textarea
from django.template import loader
-from django.utils import six
-from django.utils import translation
-
-from django.contrib.gis.gdal import GDALException
-from django.contrib.gis.geos import GEOSGeometry, GEOSException
+from django.utils import six, translation
# Creating a template context that contains Django settings
# values needed by admin map templates.
diff --git a/django/contrib/gis/apps.py b/django/contrib/gis/apps.py
index 6ca51e9b42..919272b064 100644
--- a/django/contrib/gis/apps.py
+++ b/django/contrib/gis/apps.py
@@ -1,6 +1,5 @@
from django.apps import AppConfig
from django.core import serializers
-
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/gis/db/backends/mysql/base.py b/django/contrib/gis/db/backends/mysql/base.py
index afeed42203..d252b38804 100644
--- a/django/contrib/gis/db/backends/mysql/base.py
+++ b/django/contrib/gis/db/backends/mysql/base.py
@@ -1,4 +1,5 @@
-from django.db.backends.mysql.base import DatabaseWrapper as MySQLDatabaseWrapper
+from django.db.backends.mysql.base import \
+ DatabaseWrapper as MySQLDatabaseWrapper
from .features import DatabaseFeatures
from .introspection import MySQLIntrospection
diff --git a/django/contrib/gis/db/backends/mysql/features.py b/django/contrib/gis/db/backends/mysql/features.py
index 02c611b292..a547ec967a 100644
--- a/django/contrib/gis/db/backends/mysql/features.py
+++ b/django/contrib/gis/db/backends/mysql/features.py
@@ -1,5 +1,6 @@
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
-from django.db.backends.mysql.features import DatabaseFeatures as MySQLDatabaseFeatures
+from django.db.backends.mysql.features import \
+ DatabaseFeatures as MySQLDatabaseFeatures
class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures):
diff --git a/django/contrib/gis/db/backends/mysql/operations.py b/django/contrib/gis/db/backends/mysql/operations.py
index 9d0d2a9928..130c103ac2 100644
--- a/django/contrib/gis/db/backends/mysql/operations.py
+++ b/django/contrib/gis/db/backends/mysql/operations.py
@@ -1,5 +1,6 @@
from django.contrib.gis.db.backends.base.adapter import WKTAdapter
-from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations
+from django.contrib.gis.db.backends.base.operations import \
+ BaseSpatialOperations
from django.contrib.gis.db.backends.utils import SpatialOperator
from django.contrib.gis.db.models import aggregates
from django.db.backends.mysql.operations import DatabaseOperations
diff --git a/django/contrib/gis/db/backends/mysql/schema.py b/django/contrib/gis/db/backends/mysql/schema.py
index 4d708686ba..e60f3d2fcc 100644
--- a/django/contrib/gis/db/backends/mysql/schema.py
+++ b/django/contrib/gis/db/backends/mysql/schema.py
@@ -1,8 +1,8 @@
import logging
from django.contrib.gis.db.models.fields import GeometryField
-from django.db.utils import OperationalError
from django.db.backends.mysql.schema import DatabaseSchemaEditor
+from django.db.utils import OperationalError
logger = logging.getLogger('django.contrib.gis')
diff --git a/django/contrib/gis/db/backends/oracle/adapter.py b/django/contrib/gis/db/backends/oracle/adapter.py
index e26603e531..60961af817 100644
--- a/django/contrib/gis/db/backends/oracle/adapter.py
+++ b/django/contrib/gis/db/backends/oracle/adapter.py
@@ -1,4 +1,5 @@
from cx_Oracle import CLOB
+
from django.contrib.gis.db.backends.base.adapter import WKTAdapter
diff --git a/django/contrib/gis/db/backends/oracle/base.py b/django/contrib/gis/db/backends/oracle/base.py
index d20ac2a9e7..167b61d01b 100644
--- a/django/contrib/gis/db/backends/oracle/base.py
+++ b/django/contrib/gis/db/backends/oracle/base.py
@@ -1,4 +1,5 @@
-from django.db.backends.oracle.base import DatabaseWrapper as OracleDatabaseWrapper
+from django.db.backends.oracle.base import \
+ DatabaseWrapper as OracleDatabaseWrapper
from .features import DatabaseFeatures
from .introspection import OracleIntrospection
diff --git a/django/contrib/gis/db/backends/oracle/features.py b/django/contrib/gis/db/backends/oracle/features.py
index ef56ec627d..df0aedcf32 100644
--- a/django/contrib/gis/db/backends/oracle/features.py
+++ b/django/contrib/gis/db/backends/oracle/features.py
@@ -1,5 +1,6 @@
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
-from django.db.backends.oracle.features import DatabaseFeatures as OracleDatabaseFeatures
+from django.db.backends.oracle.features import \
+ DatabaseFeatures as OracleDatabaseFeatures
class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures):
diff --git a/django/contrib/gis/db/backends/oracle/introspection.py b/django/contrib/gis/db/backends/oracle/introspection.py
index 53a449bb5a..764ce7d243 100644
--- a/django/contrib/gis/db/backends/oracle/introspection.py
+++ b/django/contrib/gis/db/backends/oracle/introspection.py
@@ -1,5 +1,7 @@
-import cx_Oracle
import sys
+
+import cx_Oracle
+
from django.db.backends.oracle.introspection import DatabaseIntrospection
from django.utils import six
diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py
index 277126a77e..9d40505632 100644
--- a/django/contrib/gis/db/backends/oracle/operations.py
+++ b/django/contrib/gis/db/backends/oracle/operations.py
@@ -9,7 +9,8 @@
"""
import re
-from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations
+from django.contrib.gis.db.backends.base.operations import \
+ BaseSpatialOperations
from django.contrib.gis.db.backends.oracle.adapter import OracleSpatialAdapter
from django.contrib.gis.db.backends.utils import SpatialOperator
from django.contrib.gis.db.models import aggregates
@@ -19,7 +20,6 @@ from django.db.backends.oracle.base import Database
from django.db.backends.oracle.operations import DatabaseOperations
from django.utils import six
-
DEFAULT_TOLERANCE = '0.05'
diff --git a/django/contrib/gis/db/backends/postgis/base.py b/django/contrib/gis/db/backends/postgis/base.py
index 083f76d0a8..8d17b16c12 100644
--- a/django/contrib/gis/db/backends/postgis/base.py
+++ b/django/contrib/gis/db/backends/postgis/base.py
@@ -1,8 +1,7 @@
from django.conf import settings
from django.db.backends.base.base import NO_DB_ALIAS
-from django.db.backends.postgresql_psycopg2.base import (
- DatabaseWrapper as Psycopg2DatabaseWrapper,
-)
+from django.db.backends.postgresql_psycopg2.base import \
+ DatabaseWrapper as Psycopg2DatabaseWrapper
from django.utils.functional import cached_property
from .creation import PostGISCreation
diff --git a/django/contrib/gis/db/backends/postgis/features.py b/django/contrib/gis/db/backends/postgis/features.py
index dfa225c6e7..1cc15bde38 100644
--- a/django/contrib/gis/db/backends/postgis/features.py
+++ b/django/contrib/gis/db/backends/postgis/features.py
@@ -1,7 +1,6 @@
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
-from django.db.backends.postgresql_psycopg2.features import (
- DatabaseFeatures as Psycopg2DatabaseFeatures,
-)
+from django.db.backends.postgresql_psycopg2.features import \
+ DatabaseFeatures as Psycopg2DatabaseFeatures
class DatabaseFeatures(BaseSpatialFeatures, Psycopg2DatabaseFeatures):
diff --git a/django/contrib/gis/db/backends/postgis/introspection.py b/django/contrib/gis/db/backends/postgis/introspection.py
index 631844a030..5e08b2f9ce 100644
--- a/django/contrib/gis/db/backends/postgis/introspection.py
+++ b/django/contrib/gis/db/backends/postgis/introspection.py
@@ -1,5 +1,6 @@
-from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrospection
from django.contrib.gis.gdal import OGRGeomType
+from django.db.backends.postgresql_psycopg2.introspection import \
+ DatabaseIntrospection
class GeoIntrospectionError(Exception):
diff --git a/django/contrib/gis/db/backends/postgis/models.py b/django/contrib/gis/db/backends/postgis/models.py
index a438ffcc20..83b254cb39 100644
--- a/django/contrib/gis/db/backends/postgis/models.py
+++ b/django/contrib/gis/db/backends/postgis/models.py
@@ -1,8 +1,8 @@
"""
The GeometryColumns and SpatialRefSys models for the PostGIS backend.
"""
-from django.db import models
from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin
+from django.db import models
from django.utils.encoding import python_2_unicode_compatible
diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py
index 2255897f2f..e0af0c1ecb 100644
--- a/django/contrib/gis/db/backends/postgis/operations.py
+++ b/django/contrib/gis/db/backends/postgis/operations.py
@@ -1,13 +1,15 @@
import re
from django.conf import settings
-from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations
+from django.contrib.gis.db.backends.base.operations import \
+ BaseSpatialOperations
from django.contrib.gis.db.backends.postgis.adapter import PostGISAdapter
from django.contrib.gis.db.backends.utils import SpatialOperator
from django.contrib.gis.geometry.backend import Geometry
from django.contrib.gis.measure import Distance
from django.core.exceptions import ImproperlyConfigured
-from django.db.backends.postgresql_psycopg2.operations import DatabaseOperations
+from django.db.backends.postgresql_psycopg2.operations import \
+ DatabaseOperations
from django.db.utils import ProgrammingError
from django.utils.functional import cached_property
diff --git a/django/contrib/gis/db/backends/spatialite/adapter.py b/django/contrib/gis/db/backends/spatialite/adapter.py
index 70ad900046..c1184f4685 100644
--- a/django/contrib/gis/db/backends/spatialite/adapter.py
+++ b/django/contrib/gis/db/backends/spatialite/adapter.py
@@ -1,5 +1,5 @@
-from django.db.backends.sqlite3.base import Database
from django.contrib.gis.db.backends.base.adapter import WKTAdapter
+from django.db.backends.sqlite3.base import Database
class SpatiaLiteAdapter(WKTAdapter):
diff --git a/django/contrib/gis/db/backends/spatialite/features.py b/django/contrib/gis/db/backends/spatialite/features.py
index 4ab382e00b..613087b51e 100644
--- a/django/contrib/gis/db/backends/spatialite/features.py
+++ b/django/contrib/gis/db/backends/spatialite/features.py
@@ -1,5 +1,6 @@
from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures
-from django.db.backends.sqlite3.features import DatabaseFeatures as SQLiteDatabaseFeatures
+from django.db.backends.sqlite3.features import \
+ DatabaseFeatures as SQLiteDatabaseFeatures
from django.utils.functional import cached_property
diff --git a/django/contrib/gis/db/backends/spatialite/introspection.py b/django/contrib/gis/db/backends/spatialite/introspection.py
index b81a2e4089..c1ed7629b9 100644
--- a/django/contrib/gis/db/backends/spatialite/introspection.py
+++ b/django/contrib/gis/db/backends/spatialite/introspection.py
@@ -1,5 +1,7 @@
from django.contrib.gis.gdal import OGRGeomType
-from django.db.backends.sqlite3.introspection import DatabaseIntrospection, FlexibleFieldLookupDict
+from django.db.backends.sqlite3.introspection import (
+ DatabaseIntrospection, FlexibleFieldLookupDict,
+)
from django.utils import six
diff --git a/django/contrib/gis/db/backends/spatialite/models.py b/django/contrib/gis/db/backends/spatialite/models.py
index a1f0f2d44b..d1b58b7582 100644
--- a/django/contrib/gis/db/backends/spatialite/models.py
+++ b/django/contrib/gis/db/backends/spatialite/models.py
@@ -1,10 +1,10 @@
"""
The GeometryColumns and SpatialRefSys models for the SpatiaLite backend.
"""
-from django.db import connection, models
-from django.db.backends.signals import connection_created
from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin
from django.contrib.gis.db.backends.spatialite.base import DatabaseWrapper
+from django.db import connection, models
+from django.db.backends.signals import connection_created
from django.utils.encoding import python_2_unicode_compatible
diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py
index c4700e7aef..73adb02b05 100644
--- a/django/contrib/gis/db/backends/spatialite/operations.py
+++ b/django/contrib/gis/db/backends/spatialite/operations.py
@@ -1,9 +1,10 @@
import re
import sys
-from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations
-from django.contrib.gis.db.backends.utils import SpatialOperator
+from django.contrib.gis.db.backends.base.operations import \
+ BaseSpatialOperations
from django.contrib.gis.db.backends.spatialite.adapter import SpatiaLiteAdapter
+from django.contrib.gis.db.backends.utils import SpatialOperator
from django.contrib.gis.db.models import aggregates
from django.contrib.gis.geometry.backend import Geometry
from django.contrib.gis.measure import Distance
diff --git a/django/contrib/gis/db/backends/spatialite/schema.py b/django/contrib/gis/db/backends/spatialite/schema.py
index e067bfc03b..bdf2b93740 100644
--- a/django/contrib/gis/db/backends/spatialite/schema.py
+++ b/django/contrib/gis/db/backends/spatialite/schema.py
@@ -1,5 +1,5 @@
-from django.db.utils import DatabaseError
from django.db.backends.sqlite3.schema import DatabaseSchemaEditor
+from django.db.utils import DatabaseError
class SpatialiteSchemaEditor(DatabaseSchemaEditor):
diff --git a/django/contrib/gis/db/models/aggregates.py b/django/contrib/gis/db/models/aggregates.py
index 42198d9287..60954951e6 100644
--- a/django/contrib/gis/db/models/aggregates.py
+++ b/django/contrib/gis/db/models/aggregates.py
@@ -1,5 +1,5 @@
-from django.db.models.aggregates import Aggregate
from django.contrib.gis.db.models.fields import ExtentField
+from django.db.models.aggregates import Aggregate
__all__ = ['Collect', 'Extent', 'Extent3D', 'MakeLine', 'Union']
diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py
index 5e70697a2b..af6d3da972 100644
--- a/django/contrib/gis/db/models/fields.py
+++ b/django/contrib/gis/db/models/fields.py
@@ -1,11 +1,11 @@
-from django.db.models.fields import Field
-from django.db.models.expressions import ExpressionNode
-from django.utils.translation import ugettext_lazy as _
from django.contrib.gis import forms
from django.contrib.gis.db.models.lookups import gis_lookups
from django.contrib.gis.db.models.proxy import GeometryProxy
from django.contrib.gis.geometry.backend import Geometry, GeometryException
+from django.db.models.expressions import ExpressionNode
+from django.db.models.fields import Field
from django.utils import six
+from django.utils.translation import ugettext_lazy as _
# Local cache of the spatial_ref_sys table, which holds SRID data for each
# spatial database alias. This cache exists so that the database isn't queried
diff --git a/django/contrib/gis/db/models/lookups.py b/django/contrib/gis/db/models/lookups.py
index eb64eff6c7..b739e468ce 100644
--- a/django/contrib/gis/db/models/lookups.py
+++ b/django/contrib/gis/db/models/lookups.py
@@ -1,10 +1,11 @@
from __future__ import unicode_literals
+
import re
from django.core.exceptions import FieldDoesNotExist
from django.db.models.constants import LOOKUP_SEP
+from django.db.models.expressions import Col, ExpressionNode
from django.db.models.lookups import Lookup
-from django.db.models.expressions import ExpressionNode, Col
from django.utils import six
gis_lookups = {}
diff --git a/django/contrib/gis/db/models/manager.py b/django/contrib/gis/db/models/manager.py
index 609bdf3637..22d009a972 100644
--- a/django/contrib/gis/db/models/manager.py
+++ b/django/contrib/gis/db/models/manager.py
@@ -1,5 +1,5 @@
-from django.db.models.manager import Manager
from django.contrib.gis.db.models.query import GeoQuerySet
+from django.db.models.manager import Manager
class GeoManager(Manager.from_queryset(GeoQuerySet)):
diff --git a/django/contrib/gis/db/models/query.py b/django/contrib/gis/db/models/query.py
index c36381ecaa..998acff79c 100644
--- a/django/contrib/gis/db/models/query.py
+++ b/django/contrib/gis/db/models/query.py
@@ -1,13 +1,8 @@
import warnings
-from django.db import connections
-from django.db.models.expressions import RawSQL
-from django.db.models.fields import Field
-from django.db.models.query import QuerySet
-
from django.contrib.gis.db.models import aggregates
from django.contrib.gis.db.models.fields import (
- get_srid_info, LineStringField, GeometryField, PointField,
+ GeometryField, LineStringField, PointField, get_srid_info,
)
from django.contrib.gis.db.models.lookups import GISLookup
from django.contrib.gis.db.models.sql import (
@@ -15,7 +10,10 @@ from django.contrib.gis.db.models.sql import (
)
from django.contrib.gis.geometry.backend import Geometry
from django.contrib.gis.measure import Area, Distance
-
+from django.db import connections
+from django.db.models.expressions import RawSQL
+from django.db.models.fields import Field
+from django.db.models.query import QuerySet
from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
diff --git a/django/contrib/gis/db/models/sql/aggregates.py b/django/contrib/gis/db/models/sql/aggregates.py
index fe0e396f2f..b83bafda70 100644
--- a/django/contrib/gis/db/models/sql/aggregates.py
+++ b/django/contrib/gis/db/models/sql/aggregates.py
@@ -1,7 +1,6 @@
from django.db.models.sql import aggregates
from django.db.models.sql.aggregates import * # NOQA
-
__all__ = ['Collect', 'Extent', 'Extent3D', 'MakeLine', 'Union'] + aggregates.__all__
diff --git a/django/contrib/gis/forms/fields.py b/django/contrib/gis/forms/fields.py
index af481b8be7..4ae56de88b 100644
--- a/django/contrib/gis/forms/fields.py
+++ b/django/contrib/gis/forms/fields.py
@@ -1,11 +1,9 @@
from __future__ import unicode_literals
from django import forms
+from django.contrib.gis.geos import GEOSException, GEOSGeometry
from django.utils.translation import ugettext_lazy as _
-# While this couples the geographic forms to the GEOS library,
-# it decouples from database (by not importing SpatialBackend).
-from django.contrib.gis.geos import GEOSException, GEOSGeometry
from .widgets import OpenLayersWidget
diff --git a/django/contrib/gis/forms/widgets.py b/django/contrib/gis/forms/widgets.py
index 26cc0565b0..37c9be8fbc 100644
--- a/django/contrib/gis/forms/widgets.py
+++ b/django/contrib/gis/forms/widgets.py
@@ -4,11 +4,10 @@ import logging
from django.conf import settings
from django.contrib.gis import gdal
-from django.contrib.gis.geos import GEOSGeometry, GEOSException
+from django.contrib.gis.geos import GEOSException, GEOSGeometry
from django.forms.widgets import Widget
from django.template import loader
-from django.utils import six
-from django.utils import translation
+from django.utils import six, translation
logger = logging.getLogger('django.contrib.gis')
diff --git a/django/contrib/gis/gdal/datasource.py b/django/contrib/gis/gdal/datasource.py
index ec9ab8c2a4..d574839cf4 100644
--- a/django/contrib/gis/gdal/datasource.py
+++ b/django/contrib/gis/gdal/datasource.py
@@ -33,20 +33,15 @@
# OFTReal returns floats, all else returns string.
val = field.value
"""
-# ctypes prerequisites.
from ctypes import byref
-# The GDAL C library, OGR exceptions, and the Layer object.
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.driver import Driver
from django.contrib.gis.gdal.error import GDALException, OGRIndexError
from django.contrib.gis.gdal.layer import Layer
-
-# Getting the ctypes prototypes for the DataSource.
from django.contrib.gis.gdal.prototypes import ds as capi
-
-from django.utils.encoding import force_bytes, force_text
from django.utils import six
+from django.utils.encoding import force_bytes, force_text
from django.utils.six.moves import range
diff --git a/django/contrib/gis/gdal/driver.py b/django/contrib/gis/gdal/driver.py
index 7628e360b9..51d0c9fe33 100644
--- a/django/contrib/gis/gdal/driver.py
+++ b/django/contrib/gis/gdal/driver.py
@@ -1,8 +1,8 @@
from ctypes import c_void_p
+
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi
-
from django.utils import six
from django.utils.encoding import force_bytes, force_text
diff --git a/django/contrib/gis/gdal/envelope.py b/django/contrib/gis/gdal/envelope.py
index 59d48b7bff..ae9ba434e7 100644
--- a/django/contrib/gis/gdal/envelope.py
+++ b/django/contrib/gis/gdal/envelope.py
@@ -11,6 +11,7 @@
Lower left (min_x, min_y) o----------+
"""
from ctypes import Structure, c_double
+
from django.contrib.gis.gdal.error import GDALException
diff --git a/django/contrib/gis/gdal/feature.py b/django/contrib/gis/gdal/feature.py
index da86c70244..ce46ae5209 100644
--- a/django/contrib/gis/gdal/feature.py
+++ b/django/contrib/gis/gdal/feature.py
@@ -1,14 +1,10 @@
-# The GDAL C library, OGR exception, and the Field object
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.error import GDALException, OGRIndexError
from django.contrib.gis.gdal.field import Field
from django.contrib.gis.gdal.geometries import OGRGeometry, OGRGeomType
-
-# ctypes function prototypes
from django.contrib.gis.gdal.prototypes import ds as capi, geom as geom_api
-
-from django.utils.encoding import force_bytes, force_text
from django.utils import six
+from django.utils.encoding import force_bytes, force_text
from django.utils.six.moves import range
diff --git a/django/contrib/gis/gdal/field.py b/django/contrib/gis/gdal/field.py
index 487c29ea42..599ee60bf3 100644
--- a/django/contrib/gis/gdal/field.py
+++ b/django/contrib/gis/gdal/field.py
@@ -1,5 +1,6 @@
from ctypes import byref, c_int
from datetime import date, datetime, time
+
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.error import GDALException
from django.contrib.gis.gdal.prototypes import ds as capi
diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py
index d00aa1a785..e9abfbf439 100644
--- a/django/contrib/gis/gdal/geometries.py
+++ b/django/contrib/gis/gdal/geometries.py
@@ -38,33 +38,27 @@
>>> print(gt1 == 3, gt1 == 'Polygon') # Equivalence works w/non-OGRGeomType objects
True True
"""
-# Python library requisites.
import sys
from binascii import a2b_hex, b2a_hex
-from ctypes import byref, string_at, c_char_p, c_double, c_ubyte, c_void_p
+from ctypes import byref, c_char_p, c_double, c_ubyte, c_void_p, string_at
-# Getting GDAL prerequisites
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.envelope import Envelope, OGREnvelope
-from django.contrib.gis.gdal.error import GDALException, OGRIndexError, SRSException
+from django.contrib.gis.gdal.error import (
+ GDALException, OGRIndexError, SRSException,
+)
from django.contrib.gis.gdal.geomtype import OGRGeomType
-from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform
-
-# Getting the ctypes prototype functions that interface w/the GDAL C library.
from django.contrib.gis.gdal.prototypes import geom as capi, srs as srs_api
-
-# For recognizing geometry input.
-from django.contrib.gis.geometry.regex import hex_regex, wkt_regex, json_regex
-
+from django.contrib.gis.gdal.srs import CoordTransform, SpatialReference
+from django.contrib.gis.geometry.regex import hex_regex, json_regex, wkt_regex
from django.utils import six
from django.utils.six.moves import range
+
# For more information, see the OGR C API source code:
# http://www.gdal.org/ogr/ogr__api_8h.html
#
# The OGR_G_* routines are relevant here.
-
-
class OGRGeometry(GDALBase):
"Generally encapsulates an OGR geometry."
diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py
index 9a06bad789..abb184e2f9 100644
--- a/django/contrib/gis/gdal/geomtype.py
+++ b/django/contrib/gis/gdal/geomtype.py
@@ -1,5 +1,4 @@
from django.contrib.gis.gdal.error import GDALException
-
from django.utils import six
diff --git a/django/contrib/gis/gdal/layer.py b/django/contrib/gis/gdal/layer.py
index e2627a2da9..640d2ad938 100644
--- a/django/contrib/gis/gdal/layer.py
+++ b/django/contrib/gis/gdal/layer.py
@@ -1,21 +1,20 @@
-# Needed ctypes routines
-from ctypes import c_double, byref
+from ctypes import byref, c_double
-# Other GDAL imports.
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.envelope import Envelope, OGREnvelope
-from django.contrib.gis.gdal.error import GDALException, OGRIndexError, SRSException
+from django.contrib.gis.gdal.error import (
+ GDALException, OGRIndexError, SRSException,
+)
from django.contrib.gis.gdal.feature import Feature
from django.contrib.gis.gdal.field import OGRFieldTypes
-from django.contrib.gis.gdal.geomtype import OGRGeomType
from django.contrib.gis.gdal.geometries import OGRGeometry
+from django.contrib.gis.gdal.geomtype import OGRGeomType
+from django.contrib.gis.gdal.prototypes import (
+ ds as capi, geom as geom_api, srs as srs_api,
+)
from django.contrib.gis.gdal.srs import SpatialReference
-
-# GDAL ctypes function prototypes.
-from django.contrib.gis.gdal.prototypes import ds as capi, geom as geom_api, srs as srs_api
-
-from django.utils.encoding import force_bytes, force_text
from django.utils import six
+from django.utils.encoding import force_bytes, force_text
from django.utils.six.moves import range
diff --git a/django/contrib/gis/gdal/libgdal.py b/django/contrib/gis/gdal/libgdal.py
index 280ae2ef5b..4f8224c19f 100644
--- a/django/contrib/gis/gdal/libgdal.py
+++ b/django/contrib/gis/gdal/libgdal.py
@@ -3,7 +3,7 @@ from __future__ import unicode_literals
import logging
import os
import re
-from ctypes import c_char_p, c_int, CDLL, CFUNCTYPE
+from ctypes import CDLL, CFUNCTYPE, c_char_p, c_int
from ctypes.util import find_library
from django.contrib.gis.gdal.error import GDALException
diff --git a/django/contrib/gis/gdal/prototypes/ds.py b/django/contrib/gis/gdal/prototypes/ds.py
index 69257a1140..2f79f7316e 100644
--- a/django/contrib/gis/gdal/prototypes/ds.py
+++ b/django/contrib/gis/gdal/prototypes/ds.py
@@ -3,11 +3,14 @@
related data structures. OGR_Dr_*, OGR_DS_*, OGR_L_*, OGR_F_*,
OGR_Fld_* routines are relevant here.
"""
-from ctypes import c_char_p, c_double, c_int, c_long, c_void_p, POINTER
+from ctypes import POINTER, c_char_p, c_double, c_int, c_long, c_void_p
+
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/errcheck.py b/django/contrib/gis/gdal/prototypes/errcheck.py
index d6c5ad17eb..edc40529ed 100644
--- a/django/contrib/gis/gdal/prototypes/errcheck.py
+++ b/django/contrib/gis/gdal/prototypes/errcheck.py
@@ -4,7 +4,9 @@
"""
from ctypes import c_void_p, string_at
-from django.contrib.gis.gdal.error import check_err, GDALException, SRSException
+from django.contrib.gis.gdal.error import (
+ GDALException, SRSException, check_err,
+)
from django.contrib.gis.gdal.libgdal import lgdal
from django.utils import six
diff --git a/django/contrib/gis/gdal/prototypes/generation.py b/django/contrib/gis/gdal/prototypes/generation.py
index 79b7b47825..39bf621796 100644
--- a/django/contrib/gis/gdal/prototypes/generation.py
+++ b/django/contrib/gis/gdal/prototypes/generation.py
@@ -4,9 +4,11 @@
"""
from ctypes import c_char_p, c_double, c_int, c_void_p
from functools import partial
+
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)
+ check_arg_errcode, check_const_string, check_errcode, check_geom,
+ check_geom_offset, check_pointer, check_srs, check_str_arg, check_string,
+)
class gdal_char_p(c_char_p):
diff --git a/django/contrib/gis/gdal/prototypes/geom.py b/django/contrib/gis/gdal/prototypes/geom.py
index 22ff1ed833..6d6412c546 100644
--- a/django/contrib/gis/gdal/prototypes/geom.py
+++ b/django/contrib/gis/gdal/prototypes/geom.py
@@ -1,9 +1,12 @@
-from ctypes import c_char_p, c_double, c_int, c_void_p, POINTER
+from ctypes import POINTER, c_char_p, c_double, c_int, c_void_p
+
from django.contrib.gis.gdal.envelope import OGREnvelope
from django.contrib.gis.gdal.libgdal import lgdal
from django.contrib.gis.gdal.prototypes.errcheck import 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 ###
diff --git a/django/contrib/gis/gdal/prototypes/raster.py b/django/contrib/gis/gdal/prototypes/raster.py
index db32ee1e0b..5e07c76955 100644
--- a/django/contrib/gis/gdal/prototypes/raster.py
+++ b/django/contrib/gis/gdal/prototypes/raster.py
@@ -2,12 +2,14 @@
This module houses the ctypes function prototypes for GDAL DataSource (raster)
related data structures.
"""
-from ctypes import c_char_p, c_double, c_int, c_void_p, POINTER
+from ctypes import POINTER, c_char_p, c_double, c_int, c_void_p
from functools import partial
from django.contrib.gis.gdal.libgdal import lgdal
-from django.contrib.gis.gdal.prototypes.generation import (const_string_output,
- double_output, int_output, void_output, voidptr_output)
+from django.contrib.gis.gdal.prototypes.generation import (
+ const_string_output, double_output, int_output, void_output,
+ voidptr_output,
+)
# For more detail about c function names and definitions see
# http://gdal.org/gdal_8h.html
diff --git a/django/contrib/gis/gdal/prototypes/srs.py b/django/contrib/gis/gdal/prototypes/srs.py
index 71ec1ed603..7ab22024ed 100644
--- a/django/contrib/gis/gdal/prototypes/srs.py
+++ b/django/contrib/gis/gdal/prototypes/srs.py
@@ -1,7 +1,10 @@
-from ctypes import c_char_p, c_int, c_void_p, POINTER
+from ctypes import POINTER, c_char_p, c_int, c_void_p
+
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.
diff --git a/django/contrib/gis/gdal/raster/source.py b/django/contrib/gis/gdal/raster/source.py
index e89e70d2e8..bb72db49ee 100644
--- a/django/contrib/gis/gdal/raster/source.py
+++ b/django/contrib/gis/gdal/raster/source.py
@@ -1,5 +1,5 @@
-from ctypes import addressof, byref, c_double
import os
+from ctypes import addressof, byref, c_double
from django.contrib.gis.gdal.base import GDALBase
from django.contrib.gis.gdal.driver import Driver
@@ -8,10 +8,11 @@ from django.contrib.gis.gdal.prototypes import raster as capi
from django.contrib.gis.gdal.raster.band import GDALBand
from django.contrib.gis.gdal.srs import SpatialReference, SRSException
from django.utils import six
-from django.utils.six.moves import range
-from django.utils.encoding import (force_bytes, force_text,
- python_2_unicode_compatible)
+from django.utils.encoding import (
+ force_bytes, force_text, python_2_unicode_compatible,
+)
from django.utils.functional import cached_property
+from django.utils.six.moves import range
class TransformPoint(list):
diff --git a/django/contrib/gis/gdal/srs.py b/django/contrib/gis/gdal/srs.py
index 8749d079b3..265ea000c2 100644
--- a/django/contrib/gis/gdal/srs.py
+++ b/django/contrib/gis/gdal/srs.py
@@ -28,16 +28,13 @@
"""
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 SRSException
from django.contrib.gis.gdal.prototypes import srs as capi
-
from django.utils import six
from django.utils.encoding import force_bytes, force_text
-#### Spatial Reference class. ####
class SpatialReference(GDALBase):
"""
A wrapper for the OGRSpatialReference object. According to the GDAL Web site,
diff --git a/django/contrib/gis/gdal/tests/test_ds.py b/django/contrib/gis/gdal/tests/test_ds.py
index 04b1c0f982..ef62c160cc 100644
--- a/django/contrib/gis/gdal/tests/test_ds.py
+++ b/django/contrib/gis/gdal/tests/test_ds.py
@@ -3,7 +3,9 @@ import unittest
from unittest import skipUnless
from django.contrib.gis.gdal import HAS_GDAL
-from django.contrib.gis.geometry.test_data import get_ds_file, TestDS, TEST_DATA
+from django.contrib.gis.geometry.test_data import (
+ TEST_DATA, TestDS, get_ds_file,
+)
if HAS_GDAL:
from django.contrib.gis.gdal import DataSource, Envelope, OGRGeometry, GDALException, OGRIndexError, GDAL_VERSION
diff --git a/django/contrib/gis/gdal/tests/test_geom.py b/django/contrib/gis/gdal/tests/test_geom.py
index 4f422c06f6..5696223554 100644
--- a/django/contrib/gis/gdal/tests/test_geom.py
+++ b/django/contrib/gis/gdal/tests/test_geom.py
@@ -1,16 +1,18 @@
import json
-from binascii import b2a_hex
-try:
- from django.utils.six.moves import cPickle as pickle
-except ImportError:
- import pickle
import unittest
+from binascii import b2a_hex
from unittest import skipUnless
from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.geometry.test_data import TestDataMixin
from django.utils.six.moves import range
+try:
+ from django.utils.six.moves import cPickle as pickle
+except ImportError:
+ import pickle
+
+
if HAS_GDAL:
from django.contrib.gis.gdal import (OGRGeometry, OGRGeomType,
GDALException, OGRIndexError, SpatialReference, CoordTransform,
diff --git a/django/contrib/gis/geoip/base.py b/django/contrib/gis/geoip/base.py
index 9409019d94..a2787af471 100644
--- a/django/contrib/gis/geoip/base.py
+++ b/django/contrib/gis/geoip/base.py
@@ -2,14 +2,14 @@ import os
import re
from ctypes import c_char_p
-from django.core.validators import ipv4_re
from django.contrib.gis.geoip.libgeoip import GEOIP_SETTINGS
from django.contrib.gis.geoip.prototypes import (
- GeoIP_open, GeoIP_delete, GeoIP_database_info,
- GeoIP_lib_version, GeoIP_record_by_addr, GeoIP_record_by_name,
GeoIP_country_code_by_addr, GeoIP_country_code_by_name,
- GeoIP_country_name_by_addr, GeoIP_country_name_by_name)
-
+ GeoIP_country_name_by_addr, GeoIP_country_name_by_name,
+ GeoIP_database_info, GeoIP_delete, GeoIP_lib_version, GeoIP_open,
+ GeoIP_record_by_addr, GeoIP_record_by_name,
+)
+from django.core.validators import ipv4_re
from django.utils import six
from django.utils.encoding import force_bytes
diff --git a/django/contrib/gis/geoip/libgeoip.py b/django/contrib/gis/geoip/libgeoip.py
index cc4d92c7d0..a6023ff229 100644
--- a/django/contrib/gis/geoip/libgeoip.py
+++ b/django/contrib/gis/geoip/libgeoip.py
@@ -1,6 +1,7 @@
import os
from ctypes import CDLL
from ctypes.util import find_library
+
from django.conf import settings
# Creating the settings dictionary with any settings, if needed.
diff --git a/django/contrib/gis/geoip/prototypes.py b/django/contrib/gis/geoip/prototypes.py
index 22c17f006f..6b47313cfe 100644
--- a/django/contrib/gis/geoip/prototypes.py
+++ b/django/contrib/gis/geoip/prototypes.py
@@ -1,5 +1,6 @@
-from ctypes import c_char_p, c_float, c_int, string_at, Structure, POINTER
-from django.contrib.gis.geoip.libgeoip import lgeoip, free
+from ctypes import POINTER, Structure, c_char_p, c_float, c_int, string_at
+
+from django.contrib.gis.geoip.libgeoip import free, lgeoip
#### GeoIP C Structure definitions ####
diff --git a/django/contrib/gis/geoip/tests.py b/django/contrib/gis/geoip/tests.py
index 06558e0093..8d1309a671 100644
--- a/django/contrib/gis/geoip/tests.py
+++ b/django/contrib/gis/geoip/tests.py
@@ -6,9 +6,8 @@ import unittest
from unittest import skipUnless
from django.conf import settings
-from django.contrib.gis.geos import HAS_GEOS
from django.contrib.gis.geoip import HAS_GEOIP
-
+from django.contrib.gis.geos import HAS_GEOS
from django.utils import six
if HAS_GEOIP:
diff --git a/django/contrib/gis/geometry/backend/geos.py b/django/contrib/gis/geometry/backend/geos.py
index b4d48dbc98..02ca3dd29e 100644
--- a/django/contrib/gis/geometry/backend/geos.py
+++ b/django/contrib/gis/geometry/backend/geos.py
@@ -1,4 +1,5 @@
from django.contrib.gis.geos import (
- GEOSGeometry as Geometry, GEOSException as GeometryException)
+ GEOSException as GeometryException, GEOSGeometry as Geometry,
+)
__all__ = ['Geometry', 'GeometryException']
diff --git a/django/contrib/gis/geometry/test_data.py b/django/contrib/gis/geometry/test_data.py
index d6a8bf8263..58d82dbdcc 100644
--- a/django/contrib/gis/geometry/test_data.py
+++ b/django/contrib/gis/geometry/test_data.py
@@ -10,7 +10,6 @@ from django.utils import six
from django.utils._os import upath
from django.utils.functional import cached_property
-
# Path where reference test data is located.
TEST_DATA = os.path.join(os.path.dirname(upath(gis.__file__)), 'tests', 'data')
diff --git a/django/contrib/gis/geos/collections.py b/django/contrib/gis/geos/collections.py
index 83f57cbd18..84b872602d 100644
--- a/django/contrib/gis/geos/collections.py
+++ b/django/contrib/gis/geos/collections.py
@@ -2,13 +2,14 @@
This module houses the Geometry Collection objects:
GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon
"""
-from ctypes import c_int, c_uint, byref
+from ctypes import byref, c_int, c_uint
+
+from django.contrib.gis.geos import prototypes as capi
from django.contrib.gis.geos.geometry import GEOSGeometry
from django.contrib.gis.geos.libgeos import get_pointer_arr
-from django.contrib.gis.geos.linestring import LineString, LinearRing
+from django.contrib.gis.geos.linestring import LinearRing, LineString
from django.contrib.gis.geos.point import Point
from django.contrib.gis.geos.polygon import Polygon
-from django.contrib.gis.geos import prototypes as capi
from django.utils.six.moves import range
diff --git a/django/contrib/gis/geos/coordseq.py b/django/contrib/gis/geos/coordseq.py
index c238d4cda5..8185ab43cc 100644
--- a/django/contrib/gis/geos/coordseq.py
+++ b/django/contrib/gis/geos/coordseq.py
@@ -3,11 +3,12 @@
by GEOSGeometry to house the actual coordinates of the Point,
LineString, and LinearRing geometries.
"""
-from ctypes import c_double, c_uint, byref
+from ctypes import byref, c_double, c_uint
+
+from django.contrib.gis.geos import prototypes as capi
from django.contrib.gis.geos.base import GEOSBase, numpy
from django.contrib.gis.geos.error import GEOSException, GEOSIndexError
from django.contrib.gis.geos.libgeos import CS_PTR
-from django.contrib.gis.geos import prototypes as capi
from django.utils.six.moves import range
diff --git a/django/contrib/gis/geos/factory.py b/django/contrib/gis/geos/factory.py
index 87ee660020..eb06da2c00 100644
--- a/django/contrib/gis/geos/factory.py
+++ b/django/contrib/gis/geos/factory.py
@@ -1,5 +1,4 @@
-from django.contrib.gis.geos.geometry import GEOSGeometry, wkt_regex, hex_regex
-
+from django.contrib.gis.geos.geometry import GEOSGeometry, hex_regex, wkt_regex
from django.utils import six
diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py
index c3ba634df1..5b478857ec 100644
--- a/django/contrib/gis/geos/geometry.py
+++ b/django/contrib/gis/geos/geometry.py
@@ -4,32 +4,19 @@
"""
from __future__ import unicode_literals
-# Python, ctypes and types dependencies.
from ctypes import addressof, byref, c_double
-# super-class for mutable list behavior
-from django.contrib.gis.geos.mutable_list import ListMixin
-
from django.contrib.gis.gdal.error import SRSException
-
-# GEOS-related dependencies.
+from django.contrib.gis.geometry.regex import hex_regex, json_regex, wkt_regex
+from django.contrib.gis.geos import prototypes as capi
from django.contrib.gis.geos.base import GEOSBase, gdal
from django.contrib.gis.geos.coordseq import GEOSCoordSeq
from django.contrib.gis.geos.error import GEOSException, GEOSIndexError
from django.contrib.gis.geos.libgeos import GEOM_PTR
-
-# All other functions in this module come from the ctypes
-# prototypes module -- which handles all interaction with
-# the underlying GEOS library.
-from django.contrib.gis.geos import prototypes as capi
-
-# These functions provide access to a thread-local instance
-# of their corresponding GEOS I/O class.
-from django.contrib.gis.geos.prototypes.io import wkt_r, wkt_w, wkb_r, wkb_w, ewkb_w
-
-# For recognizing geometry input.
-from django.contrib.gis.geometry.regex import hex_regex, wkt_regex, json_regex
-
+from django.contrib.gis.geos.mutable_list import ListMixin
+from django.contrib.gis.geos.prototypes.io import (
+ ewkb_w, wkb_r, wkb_w, wkt_r, wkt_w,
+)
from django.utils import six
from django.utils.encoding import force_bytes, force_text
@@ -684,11 +671,12 @@ class GEOSGeometry(GEOSBase, ListMixin):
# Class mapping dictionary. Has to be at the end to avoid import
# conflicts with GEOSGeometry.
-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
-from django.contrib.gis.geos.collections import GeometryCollection, MultiPoint, MultiLineString, MultiPolygon
-from django.contrib.gis.geos.prepared import PreparedGeometry
+from django.contrib.gis.geos.linestring import LineString, LinearRing # isort:skip
+from django.contrib.gis.geos.point import Point # isort:skip
+from django.contrib.gis.geos.polygon import Polygon # isort:skip
+from django.contrib.gis.geos.collections import ( # isort:skip
+ GeometryCollection, MultiPoint, MultiLineString, MultiPolygon)
+from django.contrib.gis.geos.prepared import PreparedGeometry # isort:skip
GEOS_CLASSES = {
0: Point,
1: LineString,
diff --git a/django/contrib/gis/geos/io.py b/django/contrib/gis/geos/io.py
index f12be89830..daf67dd28c 100644
--- a/django/contrib/gis/geos/io.py
+++ b/django/contrib/gis/geos/io.py
@@ -4,7 +4,9 @@ objects. Specifically, this has Python implementations of WKB/WKT
reader and writer classes.
"""
from django.contrib.gis.geos.geometry import GEOSGeometry
-from django.contrib.gis.geos.prototypes.io import _WKTReader, _WKBReader, WKBWriter, WKTWriter
+from django.contrib.gis.geos.prototypes.io import (
+ WKBWriter, WKTWriter, _WKBReader, _WKTReader,
+)
__all__ = ['WKBWriter', 'WKTWriter', 'WKBReader', 'WKTReader']
diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py
index 207fa780a4..fa5fa21a25 100644
--- a/django/contrib/gis/geos/libgeos.py
+++ b/django/contrib/gis/geos/libgeos.py
@@ -9,7 +9,7 @@
import logging
import os
import re
-from ctypes import c_char_p, Structure, CDLL, CFUNCTYPE, POINTER
+from ctypes import CDLL, CFUNCTYPE, POINTER, Structure, c_char_p
from ctypes.util import find_library
from django.contrib.gis.geos.error import GEOSException
diff --git a/django/contrib/gis/geos/linestring.py b/django/contrib/gis/geos/linestring.py
index 829ab48945..62802c1efd 100644
--- a/django/contrib/gis/geos/linestring.py
+++ b/django/contrib/gis/geos/linestring.py
@@ -1,9 +1,9 @@
+from django.contrib.gis.geos import prototypes as capi
from django.contrib.gis.geos.base import numpy
from django.contrib.gis.geos.coordseq import GEOSCoordSeq
from django.contrib.gis.geos.error import GEOSException
from django.contrib.gis.geos.geometry import GEOSGeometry
from django.contrib.gis.geos.point import Point
-from django.contrib.gis.geos import prototypes as capi
from django.utils.six.moves import range
diff --git a/django/contrib/gis/geos/mutable_list.py b/django/contrib/gis/geos/mutable_list.py
index f01bc4275f..805351f252 100644
--- a/django/contrib/gis/geos/mutable_list.py
+++ b/django/contrib/gis/geos/mutable_list.py
@@ -8,8 +8,8 @@ See also http://www.aryehleib.com/MutableLists.html
Author: Aryeh Leib Taurog.
"""
-from django.utils.functional import total_ordering
from django.utils import six
+from django.utils.functional import total_ordering
from django.utils.six.moves import range
diff --git a/django/contrib/gis/geos/point.py b/django/contrib/gis/geos/point.py
index 2cc5c13683..0b58098fed 100644
--- a/django/contrib/gis/geos/point.py
+++ b/django/contrib/gis/geos/point.py
@@ -1,7 +1,8 @@
from ctypes import c_uint
+
+from django.contrib.gis.geos import prototypes as capi
from django.contrib.gis.geos.error import GEOSException
from django.contrib.gis.geos.geometry import GEOSGeometry
-from django.contrib.gis.geos import prototypes as capi
from django.utils import six
from django.utils.six.moves import range
diff --git a/django/contrib/gis/geos/polygon.py b/django/contrib/gis/geos/polygon.py
index 38b533df8f..c8059348cd 100644
--- a/django/contrib/gis/geos/polygon.py
+++ b/django/contrib/gis/geos/polygon.py
@@ -1,8 +1,9 @@
-from ctypes import c_uint, byref
+from ctypes import byref, c_uint
+
+from django.contrib.gis.geos import prototypes as capi
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.libgeos import GEOM_PTR, get_pointer_arr
from django.contrib.gis.geos.linestring import LinearRing
-from django.contrib.gis.geos import prototypes as capi
from django.utils import six
from django.utils.six.moves import range
diff --git a/django/contrib/gis/geos/prototypes/coordseq.py b/django/contrib/gis/geos/prototypes/coordseq.py
index b115fc3447..3e5204e5fe 100644
--- a/django/contrib/gis/geos/prototypes/coordseq.py
+++ b/django/contrib/gis/geos/prototypes/coordseq.py
@@ -1,6 +1,9 @@
-from ctypes import c_double, c_int, c_uint, POINTER
-from django.contrib.gis.geos.libgeos import GEOM_PTR, CS_PTR
-from django.contrib.gis.geos.prototypes.errcheck import last_arg_byref, GEOSException
+from ctypes import POINTER, c_double, c_int, c_uint
+
+from django.contrib.gis.geos.libgeos import CS_PTR, GEOM_PTR
+from django.contrib.gis.geos.prototypes.errcheck import (
+ GEOSException, last_arg_byref,
+)
from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
diff --git a/django/contrib/gis/geos/prototypes/errcheck.py b/django/contrib/gis/geos/prototypes/errcheck.py
index 034cfe5899..dd037a5632 100644
--- a/django/contrib/gis/geos/prototypes/errcheck.py
+++ b/django/contrib/gis/geos/prototypes/errcheck.py
@@ -2,10 +2,10 @@
Error checking functions for GEOS ctypes prototype functions.
"""
from ctypes import c_void_p, string_at
+
from django.contrib.gis.geos.error import GEOSException
from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
-
# Getting the `free` routine used to free the memory allocated for
# string pointers returned by GEOS.
free = GEOSFunc('GEOSFree')
diff --git a/django/contrib/gis/geos/prototypes/geom.py b/django/contrib/gis/geos/prototypes/geom.py
index 021fe6e469..b8320471e9 100644
--- a/django/contrib/gis/geos/prototypes/geom.py
+++ b/django/contrib/gis/geos/prototypes/geom.py
@@ -1,7 +1,9 @@
-from ctypes import c_char_p, c_int, c_size_t, c_ubyte, POINTER
+from ctypes import POINTER, c_char_p, c_int, c_size_t, c_ubyte
+
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)
+ 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/io.py b/django/contrib/gis/geos/prototypes/io.py
index 34bd34886a..55fd6d2f17 100644
--- a/django/contrib/gis/geos/prototypes/io.py
+++ b/django/contrib/gis/geos/prototypes/io.py
@@ -1,11 +1,13 @@
import threading
-from ctypes import byref, c_char_p, c_int, c_char, c_size_t, Structure, POINTER
+from ctypes import POINTER, Structure, byref, c_char, c_char_p, c_int, c_size_t
+
from django.contrib.gis.geos.base import GEOSBase
from django.contrib.gis.geos.libgeos import GEOM_PTR
-from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_string, check_sized_string
+from django.contrib.gis.geos.prototypes.errcheck import (
+ check_geom, check_sized_string, check_string,
+)
from django.contrib.gis.geos.prototypes.geom import c_uchar_p, geos_char_p
from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
-
from django.utils import six
from django.utils.encoding import force_bytes
diff --git a/django/contrib/gis/geos/prototypes/misc.py b/django/contrib/gis/geos/prototypes/misc.py
index 0e62e916b0..9dba880f18 100644
--- a/django/contrib/gis/geos/prototypes/misc.py
+++ b/django/contrib/gis/geos/prototypes/misc.py
@@ -2,7 +2,8 @@
This module is for the miscellaneous GEOS routines, particularly the
ones that return the area, distance, and length.
"""
-from ctypes import c_int, c_double, POINTER
+from ctypes import POINTER, c_double, c_int
+
from django.contrib.gis.geos.libgeos import GEOM_PTR
from django.contrib.gis.geos.prototypes.errcheck import check_dbl, check_string
from django.contrib.gis.geos.prototypes.geom import geos_char_p
diff --git a/django/contrib/gis/geos/prototypes/predicates.py b/django/contrib/gis/geos/prototypes/predicates.py
index f3c30a5062..0146784d03 100644
--- a/django/contrib/gis/geos/prototypes/predicates.py
+++ b/django/contrib/gis/geos/prototypes/predicates.py
@@ -3,6 +3,7 @@
unary and binary predicate operations on geometries.
"""
from ctypes import c_char, c_char_p, c_double
+
from django.contrib.gis.geos.libgeos import GEOM_PTR
from django.contrib.gis.geos.prototypes.errcheck import check_predicate
from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
diff --git a/django/contrib/gis/geos/prototypes/prepared.py b/django/contrib/gis/geos/prototypes/prepared.py
index ced56395b0..2c93e1eb2f 100644
--- a/django/contrib/gis/geos/prototypes/prepared.py
+++ b/django/contrib/gis/geos/prototypes/prepared.py
@@ -1,5 +1,8 @@
from ctypes import c_char
-from django.contrib.gis.geos.libgeos import GEOM_PTR, PREPGEOM_PTR, geos_version_info
+
+from django.contrib.gis.geos.libgeos import (
+ GEOM_PTR, PREPGEOM_PTR, geos_version_info,
+)
from django.contrib.gis.geos.prototypes.errcheck import check_predicate
from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
diff --git a/django/contrib/gis/geos/prototypes/threadsafe.py b/django/contrib/gis/geos/prototypes/threadsafe.py
index 61b13792bc..45c87d6004 100644
--- a/django/contrib/gis/geos/prototypes/threadsafe.py
+++ b/django/contrib/gis/geos/prototypes/threadsafe.py
@@ -1,5 +1,8 @@
import threading
-from django.contrib.gis.geos.libgeos import lgeos, notice_h, error_h, CONTEXT_PTR
+
+from django.contrib.gis.geos.libgeos import (
+ CONTEXT_PTR, error_h, lgeos, notice_h,
+)
class GEOSContextHandle(object):
diff --git a/django/contrib/gis/geos/prototypes/topology.py b/django/contrib/gis/geos/prototypes/topology.py
index 83d6706eaa..0e318409ee 100644
--- a/django/contrib/gis/geos/prototypes/topology.py
+++ b/django/contrib/gis/geos/prototypes/topology.py
@@ -11,8 +11,11 @@ __all__ = ['geos_boundary', 'geos_buffer', 'geos_cascaded_union',
'geos_interpolate_normalized']
from ctypes import c_double, c_int
+
from django.contrib.gis.geos.libgeos import GEOM_PTR
-from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_minus_one, check_string
+from django.contrib.gis.geos.prototypes.errcheck import (
+ check_geom, check_minus_one, check_string,
+)
from django.contrib.gis.geos.prototypes.geom import geos_char_p
from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc
diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py
index 48d4aabf13..4158faeaa7 100644
--- a/django/contrib/gis/geos/tests/test_geos.py
+++ b/django/contrib/gis/geos/tests/test_geos.py
@@ -4,16 +4,14 @@ import ctypes
import json
import random
import unittest
-from unittest import skipUnless
from binascii import a2b_hex, b2a_hex
from io import BytesIO
+from unittest import skipUnless
from django.contrib.gis.gdal import HAS_GDAL
-
from django.contrib.gis.geometry.test_data import TestDataMixin
-
-from django.utils.encoding import force_bytes
from django.utils import six
+from django.utils.encoding import force_bytes
from django.utils.six.moves import range
from .. import HAS_GEOS
diff --git a/django/contrib/gis/geos/tests/test_io.py b/django/contrib/gis/geos/tests/test_io.py
index 06ca76e33d..08ff6c13e8 100644
--- a/django/contrib/gis/geos/tests/test_io.py
+++ b/django/contrib/gis/geos/tests/test_io.py
@@ -6,7 +6,7 @@ from unittest import skipUnless
from django.utils.six import memoryview
-from ..import HAS_GEOS
+from ..import HAS_GEOS # isort:skip
if HAS_GEOS:
from .. import GEOSGeometry, WKTReader, WKTWriter, WKBReader, WKBWriter
diff --git a/django/contrib/gis/management/commands/inspectdb.py b/django/contrib/gis/management/commands/inspectdb.py
index 502f816ea4..229be74276 100644
--- a/django/contrib/gis/management/commands/inspectdb.py
+++ b/django/contrib/gis/management/commands/inspectdb.py
@@ -1,4 +1,5 @@
-from django.core.management.commands.inspectdb import Command as InspectDBCommand
+from django.core.management.commands.inspectdb import \
+ Command as InspectDBCommand
class Command(InspectDBCommand):
diff --git a/django/contrib/gis/maps/google/gmap.py b/django/contrib/gis/maps/google/gmap.py
index 845b39a806..d40c3b8218 100644
--- a/django/contrib/gis/maps/google/gmap.py
+++ b/django/contrib/gis/maps/google/gmap.py
@@ -1,13 +1,14 @@
from __future__ import unicode_literals
from django.conf import settings
+from django.contrib.gis.maps.google.overlays import (
+ GMarker, GPolygon, GPolyline,
+)
from django.template.loader import render_to_string
from django.utils.html import format_html
from django.utils.safestring import mark_safe
from django.utils.six.moves import range
-from django.contrib.gis.maps.google.overlays import GPolygon, GPolyline, GMarker
-
class GoogleMapException(Exception):
pass
diff --git a/django/contrib/gis/maps/google/overlays.py b/django/contrib/gis/maps/google/overlays.py
index d9ba31380a..f249e5d809 100644
--- a/django/contrib/gis/maps/google/overlays.py
+++ b/django/contrib/gis/maps/google/overlays.py
@@ -1,10 +1,12 @@
from __future__ import unicode_literals
-from django.contrib.gis.geos import fromstr, Point, LineString, LinearRing, Polygon
-from django.utils.functional import total_ordering
-from django.utils.safestring import mark_safe
+from django.contrib.gis.geos import (
+ LinearRing, LineString, Point, Polygon, fromstr,
+)
from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
+from django.utils.functional import total_ordering
+from django.utils.safestring import mark_safe
@python_2_unicode_compatible
diff --git a/django/contrib/gis/maps/google/zoom.py b/django/contrib/gis/maps/google/zoom.py
index a34748bb8e..d169fbd59b 100644
--- a/django/contrib/gis/maps/google/zoom.py
+++ b/django/contrib/gis/maps/google/zoom.py
@@ -1,9 +1,10 @@
from __future__ import unicode_literals
-from django.contrib.gis.geos import GEOSGeometry, LinearRing, Polygon, Point
+from math import atan, exp, log, pi, sin
+
+from django.contrib.gis.geos import GEOSGeometry, LinearRing, Point, Polygon
from django.contrib.gis.maps.google.gmap import GoogleMapException
from django.utils.six.moves import range
-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/measure.py b/django/contrib/gis/measure.py
index 90b316bb60..527512f71b 100644
--- a/django/contrib/gis/measure.py
+++ b/django/contrib/gis/measure.py
@@ -38,8 +38,8 @@ and Geoff Biggs' PhD work on dimensioned units for robotics.
__all__ = ['A', 'Area', 'D', 'Distance']
from decimal import Decimal
-from django.utils.functional import total_ordering
from django.utils import six
+from django.utils.functional import total_ordering
NUMERIC_TYPES = six.integer_types + (float, Decimal)
AREA_PREFIX = "sq_"
diff --git a/django/contrib/gis/serializers/geojson.py b/django/contrib/gis/serializers/geojson.py
index 573f85c045..eb0533bded 100644
--- a/django/contrib/gis/serializers/geojson.py
+++ b/django/contrib/gis/serializers/geojson.py
@@ -1,7 +1,9 @@
from __future__ import unicode_literals
from django.contrib.gis.gdal import HAS_GDAL
-from django.core.serializers.base import SerializerDoesNotExist, SerializationError
+from django.core.serializers.base import (
+ SerializationError, SerializerDoesNotExist,
+)
from django.core.serializers.json import Serializer as JSONSerializer
if HAS_GDAL:
diff --git a/django/contrib/gis/sitemaps/kml.py b/django/contrib/gis/sitemaps/kml.py
index d052cf6350..4dcaa8f595 100644
--- a/django/contrib/gis/sitemaps/kml.py
+++ b/django/contrib/gis/sitemaps/kml.py
@@ -1,7 +1,7 @@
from django.apps import apps
-from django.core import urlresolvers
-from django.contrib.sitemaps import Sitemap
from django.contrib.gis.db.models.fields import GeometryField
+from django.contrib.sitemaps import Sitemap
+from django.core import urlresolvers
from django.db import models
diff --git a/django/contrib/gis/sitemaps/views.py b/django/contrib/gis/sitemaps/views.py
index a84621374b..dc5eb40441 100644
--- a/django/contrib/gis/sitemaps/views.py
+++ b/django/contrib/gis/sitemaps/views.py
@@ -1,11 +1,11 @@
from __future__ import unicode_literals
from django.apps import apps
-from django.http import Http404
from django.contrib.gis.db.models.fields import GeometryField
from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz
from django.core.exceptions import FieldDoesNotExist
-from django.db import connections, DEFAULT_DB_ALIAS
+from django.db import DEFAULT_DB_ALIAS, connections
+from django.http import Http404
def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS):
diff --git a/django/contrib/gis/tests/distapp/tests.py b/django/contrib/gis/tests/distapp/tests.py
index 5f898e3dda..4c2ea60950 100644
--- a/django/contrib/gis/tests/distapp/tests.py
+++ b/django/contrib/gis/tests/distapp/tests.py
@@ -1,10 +1,12 @@
from __future__ import unicode_literals
-from django.db import connection
-from django.db.models import Q
from django.contrib.gis.geos import HAS_GEOS
from django.contrib.gis.measure import D # alias for Distance
-from django.contrib.gis.tests.utils import oracle, postgis, spatialite, no_oracle
+from django.contrib.gis.tests.utils import (
+ no_oracle, oracle, postgis, spatialite,
+)
+from django.db import connection
+from django.db.models import Q
from django.test import TestCase, skipUnlessDBFeature
if HAS_GEOS:
diff --git a/django/contrib/gis/tests/geo3d/tests.py b/django/contrib/gis/tests/geo3d/tests.py
index 9530cd9b55..022a8063ab 100644
--- a/django/contrib/gis/tests/geo3d/tests.py
+++ b/django/contrib/gis/tests/geo3d/tests.py
@@ -7,8 +7,8 @@ from unittest import skipUnless
from django.contrib.gis.gdal import HAS_GDAL
from django.contrib.gis.geos import HAS_GEOS
from django.test import TestCase, ignore_warnings, skipUnlessDBFeature
-from django.utils.deprecation import RemovedInDjango20Warning
from django.utils._os import upath
+from django.utils.deprecation import RemovedInDjango20Warning
if HAS_GEOS:
from django.contrib.gis.db.models import Union, Extent3D
diff --git a/django/contrib/gis/tests/geoadmin/models.py b/django/contrib/gis/tests/geoadmin/models.py
index 381a752570..cf8470e792 100644
--- a/django/contrib/gis/tests/geoadmin/models.py
+++ b/django/contrib/gis/tests/geoadmin/models.py
@@ -1,5 +1,5 @@
-from django.contrib.gis.db import models
from django.contrib.gis import admin
+from django.contrib.gis.db import models
from django.utils.encoding import python_2_unicode_compatible
diff --git a/django/contrib/gis/tests/geoapp/sitemaps.py b/django/contrib/gis/tests/geoapp/sitemaps.py
index 16f1f0146e..1a3101290a 100644
--- a/django/contrib/gis/tests/geoapp/sitemaps.py
+++ b/django/contrib/gis/tests/geoapp/sitemaps.py
@@ -2,7 +2,6 @@ from django.contrib.gis.sitemaps import KMLSitemap, KMZSitemap
from .models import City, Country
-
sitemaps = {'kml': KMLSitemap([City, Country]),
'kmz': KMZSitemap([City, Country]),
}
diff --git a/django/contrib/gis/tests/geoapp/test_feeds.py b/django/contrib/gis/tests/geoapp/test_feeds.py
index 1b89823ecb..19a6f69b00 100644
--- a/django/contrib/gis/tests/geoapp/test_feeds.py
+++ b/django/contrib/gis/tests/geoapp/test_feeds.py
@@ -3,10 +3,10 @@ from __future__ import unicode_literals
from xml.dom import minidom
from django.conf import settings
-from django.contrib.sites.models import Site
from django.contrib.gis.geos import HAS_GEOS
+from django.contrib.sites.models import Site
from django.test import (
- TestCase, modify_settings, override_settings, skipUnlessDBFeature
+ TestCase, modify_settings, override_settings, skipUnlessDBFeature,
)
if HAS_GEOS:
diff --git a/django/contrib/gis/tests/geoapp/test_sitemaps.py b/django/contrib/gis/tests/geoapp/test_sitemaps.py
index 4ef2bb9702..6a2d1f40b8 100644
--- a/django/contrib/gis/tests/geoapp/test_sitemaps.py
+++ b/django/contrib/gis/tests/geoapp/test_sitemaps.py
@@ -1,14 +1,15 @@
from __future__ import unicode_literals
+import zipfile
from io import BytesIO
from xml.dom import minidom
-import zipfile
from django.conf import settings
from django.contrib.gis.geos import HAS_GEOS
from django.contrib.sites.models import Site
from django.test import (
- TestCase, ignore_warnings, modify_settings, override_settings, skipUnlessDBFeature
+ TestCase, ignore_warnings, modify_settings, override_settings,
+ skipUnlessDBFeature,
)
from django.utils.deprecation import RemovedInDjango20Warning
diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py
index 7c999a20d0..9b45492715 100644
--- a/django/contrib/gis/tests/geoapp/tests.py
+++ b/django/contrib/gis/tests/geoapp/tests.py
@@ -3,11 +3,13 @@ from __future__ import unicode_literals
import re
from tempfile import NamedTemporaryFile
-from django.db import connection
from django.contrib.gis import gdal
from django.contrib.gis.geos import HAS_GEOS
-from django.contrib.gis.tests.utils import no_oracle, oracle, postgis, spatialite
+from django.contrib.gis.tests.utils import (
+ no_oracle, oracle, postgis, spatialite,
+)
from django.core.management import call_command
+from django.db import connection
from django.test import TestCase, ignore_warnings, skipUnlessDBFeature
from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
diff --git a/django/contrib/gis/tests/geoapp/urls.py b/django/contrib/gis/tests/geoapp/urls.py
index 238c64ad51..40a48053c7 100644
--- a/django/contrib/gis/tests/geoapp/urls.py
+++ b/django/contrib/gis/tests/geoapp/urls.py
@@ -2,13 +2,12 @@ from __future__ import unicode_literals
from django.conf.urls import url
from django.contrib.gis import views as gis_views
-from django.contrib.sitemaps import views as sitemap_views
from django.contrib.gis.sitemaps import views as gis_sitemap_views
+from django.contrib.sitemaps import views as sitemap_views
from .feeds import feed_dict
from .sitemaps import sitemaps
-
urlpatterns = [
url(r'^feeds/(?P<url>.*)/$', gis_views.feed, {'feed_dict': feed_dict}),
]
diff --git a/django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py b/django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py
index 212f702320..aceaaa301e 100644
--- a/django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py
+++ b/django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py
@@ -1,5 +1,5 @@
-from django.db import models, migrations
import django.contrib.gis.db.models.fields
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/gis/tests/gis_migrations/test_commands.py b/django/contrib/gis/tests/gis_migrations/test_commands.py
index bb0186fad5..076215465d 100644
--- a/django/contrib/gis/tests/gis_migrations/test_commands.py
+++ b/django/contrib/gis/tests/gis_migrations/test_commands.py
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
from django.core.management import call_command
from django.db import connection
-from django.test import skipUnlessDBFeature, TransactionTestCase
+from django.test import TransactionTestCase, skipUnlessDBFeature
@skipUnlessDBFeature("gis_enabled")
diff --git a/django/contrib/gis/tests/gis_migrations/test_operations.py b/django/contrib/gis/tests/gis_migrations/test_operations.py
index 8052e7ab1d..9bfe55b0bf 100644
--- a/django/contrib/gis/tests/gis_migrations/test_operations.py
+++ b/django/contrib/gis/tests/gis_migrations/test_operations.py
@@ -4,7 +4,7 @@ from django.contrib.gis.tests.utils import mysql
from django.db import connection, migrations, models
from django.db.migrations.migration import Migration
from django.db.migrations.state import ProjectState
-from django.test import skipUnlessDBFeature, TransactionTestCase
+from django.test import TransactionTestCase, skipUnlessDBFeature
if connection.features.gis_enabled:
from django.contrib.gis.db.models import fields
diff --git a/django/contrib/gis/tests/inspectapp/tests.py b/django/contrib/gis/tests/inspectapp/tests.py
index 82b2cfefd6..8e2f54c517 100644
--- a/django/contrib/gis/tests/inspectapp/tests.py
+++ b/django/contrib/gis/tests/inspectapp/tests.py
@@ -4,11 +4,11 @@ import os
import re
from unittest import skipUnless
+from django.contrib.gis.gdal import HAS_GDAL
+from django.contrib.gis.geometry.test_data import TEST_DATA
from django.core.management import call_command
from django.db import connection, connections
from django.test import TestCase, skipUnlessDBFeature
-from django.contrib.gis.gdal import HAS_GDAL
-from django.contrib.gis.geometry.test_data import TEST_DATA
from django.utils.six import StringIO
if HAS_GDAL:
diff --git a/django/contrib/gis/tests/layermap/tests.py b/django/contrib/gis/tests/layermap/tests.py
index 45709e30ce..85f105f4a0 100644
--- a/django/contrib/gis/tests/layermap/tests.py
+++ b/django/contrib/gis/tests/layermap/tests.py
@@ -1,15 +1,15 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from copy import copy
-from decimal import Decimal
import os
import unittest
+from copy import copy
+from decimal import Decimal
from unittest import skipUnless
+from django.conf import settings
from django.contrib.gis.gdal import HAS_GDAL
from django.db import connection
-from django.conf import settings
from django.test import TestCase, override_settings, skipUnlessDBFeature
from django.utils._os import upath
diff --git a/django/contrib/gis/tests/test_geoforms.py b/django/contrib/gis/tests/test_geoforms.py
index fa72cd1fac..bcbb5f0804 100644
--- a/django/contrib/gis/tests/test_geoforms.py
+++ b/django/contrib/gis/tests/test_geoforms.py
@@ -1,7 +1,7 @@
from unittest import skipUnless
-from django.forms import ValidationError
from django.contrib.gis.gdal import HAS_GDAL
+from django.forms import ValidationError
from django.test import SimpleTestCase, skipUnlessDBFeature
from django.utils import six
from django.utils.html import escape
diff --git a/django/contrib/gis/tests/test_measure.py b/django/contrib/gis/tests/test_measure.py
index f6b89ce1ca..771c10fe9d 100644
--- a/django/contrib/gis/tests/test_measure.py
+++ b/django/contrib/gis/tests/test_measure.py
@@ -5,7 +5,7 @@ and conversions. Here are some tests.
import unittest
-from django.contrib.gis.measure import Distance, Area, D, A
+from django.contrib.gis.measure import A, D, Area, Distance
class DistanceTest(unittest.TestCase):
diff --git a/django/contrib/gis/tests/test_spatialrefsys.py b/django/contrib/gis/tests/test_spatialrefsys.py
index 7f43124e5d..1a4b151f2b 100644
--- a/django/contrib/gis/tests/test_spatialrefsys.py
+++ b/django/contrib/gis/tests/test_spatialrefsys.py
@@ -1,13 +1,13 @@
import unittest
from django.contrib.gis.gdal import HAS_GDAL
-from django.contrib.gis.tests.utils import (oracle, postgis, spatialite,
- SpatialRefSys)
+from django.contrib.gis.tests.utils import (
+ SpatialRefSys, oracle, postgis, spatialite,
+)
from django.db import connection
from django.test import skipUnlessDBFeature
from django.utils import six
-
test_srs = ({
'srid': 4326,
'auth_name': ('EPSG', True),
diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py
index 2ff23fc38b..30e773d69d 100644
--- a/django/contrib/gis/utils/layermapping.py
+++ b/django/contrib/gis/utils/layermapping.py
@@ -8,14 +8,17 @@
"""
import sys
from decimal import Decimal, InvalidOperation as DecimalInvalidOperation
-from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist
-from django.db import connections, router
+
from django.contrib.gis.db.models import GeometryField
-from django.contrib.gis.gdal import (CoordTransform, DataSource,
- GDALException, OGRGeometry, OGRGeomType, SpatialReference)
+from django.contrib.gis.gdal import (
+ CoordTransform, DataSource, GDALException, OGRGeometry, OGRGeomType,
+ SpatialReference,
+)
from django.contrib.gis.gdal.field import (
- OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime)
-from django.db import models, transaction
+ OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime,
+)
+from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist
+from django.db import connections, models, router, transaction
from django.utils import six
from django.utils.encoding import force_text
diff --git a/django/contrib/gis/utils/ogrinspect.py b/django/contrib/gis/utils/ogrinspect.py
index 16732556d4..9c9a4c7f8c 100644
--- a/django/contrib/gis/utils/ogrinspect.py
+++ b/django/contrib/gis/utils/ogrinspect.py
@@ -3,11 +3,12 @@ This module is for inspecting OGR data sources and generating either
models for GeoDjango and/or mapping dictionaries for use with the
`LayerMapping` utility.
"""
-from django.utils.six.moves import zip
-# 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, OFTTime,
+)
from django.utils import six
+from django.utils.six.moves import zip
def mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False):
diff --git a/django/contrib/gis/utils/srs.py b/django/contrib/gis/utils/srs.py
index 1460be2de9..59ba77c6dd 100644
--- a/django/contrib/gis/utils/srs.py
+++ b/django/contrib/gis/utils/srs.py
@@ -1,5 +1,5 @@
from django.contrib.gis.gdal import SpatialReference
-from django.db import connections, DEFAULT_DB_ALIAS
+from django.db import DEFAULT_DB_ALIAS, connections
def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None,
diff --git a/django/contrib/humanize/apps.py b/django/contrib/humanize/apps.py
index 67b3012175..c518ee12df 100644
--- a/django/contrib/humanize/apps.py
+++ b/django/contrib/humanize/apps.py
@@ -1,5 +1,4 @@
from django.apps import AppConfig
-
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py
index 81c6d2a04c..bb9bc7b1ca 100644
--- a/django/contrib/humanize/templatetags/humanize.py
+++ b/django/contrib/humanize/templatetags/humanize.py
@@ -11,8 +11,8 @@ from django.template import defaultfilters
from django.utils.encoding import force_text
from django.utils.formats import number_format
from django.utils.safestring import mark_safe
-from django.utils.translation import pgettext, ungettext, ugettext as _
from django.utils.timezone import is_aware, utc
+from django.utils.translation import pgettext, ugettext as _, ungettext
register = template.Library()
diff --git a/django/contrib/humanize/tests.py b/django/contrib/humanize/tests.py
index a9882e479f..84528fd29d 100644
--- a/django/contrib/humanize/tests.py
+++ b/django/contrib/humanize/tests.py
@@ -1,21 +1,22 @@
from __future__ import unicode_literals
+
import datetime
from decimal import Decimal
from unittest import skipIf
-try:
- import pytz
-except ImportError:
- pytz = None
-
from django.contrib.humanize.templatetags import humanize
-from django.template import Template, Context, defaultfilters
+from django.template import Context, Template, defaultfilters
from django.test import TestCase, override_settings
-from django.utils.html import escape
-from django.utils.timezone import utc, get_fixed_timezone
from django.utils import translation
+from django.utils.html import escape
+from django.utils.timezone import get_fixed_timezone, utc
from django.utils.translation import ugettext as _
+try:
+ import pytz
+except ImportError:
+ pytz = None
+
# Mock out datetime in some tests so they don't fail occasionally when they
# run too slow. Use a fixed datetime for datetime.now(). DST change in
diff --git a/django/contrib/messages/apps.py b/django/contrib/messages/apps.py
index 1a9189383e..de48c8aa4d 100644
--- a/django/contrib/messages/apps.py
+++ b/django/contrib/messages/apps.py
@@ -1,5 +1,4 @@
from django.apps import AppConfig
-
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/messages/storage/base.py b/django/contrib/messages/storage/base.py
index 43dd3dbdd2..74f1ce7d9c 100644
--- a/django/contrib/messages/storage/base.py
+++ b/django/contrib/messages/storage/base.py
@@ -1,9 +1,8 @@
from __future__ import unicode_literals
from django.conf import settings
-from django.utils.encoding import force_text, python_2_unicode_compatible
from django.contrib.messages import constants, utils
-
+from django.utils.encoding import force_text, python_2_unicode_compatible
LEVEL_TAGS = utils.get_level_tags()
diff --git a/django/contrib/messages/storage/cookie.py b/django/contrib/messages/storage/cookie.py
index 71eee0cdfa..eb927411a7 100644
--- a/django/contrib/messages/storage/cookie.py
+++ b/django/contrib/messages/storage/cookie.py
@@ -3,9 +3,9 @@ import json
from django.conf import settings
from django.contrib.messages.storage.base import BaseStorage, Message
from django.http import SimpleCookie
-from django.utils.crypto import salted_hmac, constant_time_compare
-from django.utils.safestring import SafeData, mark_safe
from django.utils import six
+from django.utils.crypto import constant_time_compare, salted_hmac
+from django.utils.safestring import SafeData, mark_safe
class MessageEncoder(json.JSONEncoder):
diff --git a/django/contrib/messages/storage/session.py b/django/contrib/messages/storage/session.py
index c3e293c22e..7903fb03c1 100644
--- a/django/contrib/messages/storage/session.py
+++ b/django/contrib/messages/storage/session.py
@@ -1,7 +1,9 @@
import json
from django.contrib.messages.storage.base import BaseStorage
-from django.contrib.messages.storage.cookie import MessageEncoder, MessageDecoder
+from django.contrib.messages.storage.cookie import (
+ MessageDecoder, MessageEncoder,
+)
from django.utils import six
diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py
index 139d32c067..d1f951789f 100644
--- a/django/contrib/messages/tests/base.py
+++ b/django/contrib/messages/tests/base.py
@@ -2,10 +2,10 @@ from unittest import skipUnless
from django import http
from django.apps import apps
-from django.contrib.messages import constants, utils, get_level, set_level
+from django.contrib.messages import constants, get_level, set_level, utils
from django.contrib.messages.api import MessageFailure
from django.contrib.messages.constants import DEFAULT_LEVELS
-from django.contrib.messages.storage import default_storage, base
+from django.contrib.messages.storage import base, default_storage
from django.contrib.messages.storage.base import Message
from django.core.urlresolvers import reverse
from django.test import modify_settings, override_settings
diff --git a/django/contrib/messages/tests/test_api.py b/django/contrib/messages/tests/test_api.py
index 335a200450..f79db95866 100644
--- a/django/contrib/messages/tests/test_api.py
+++ b/django/contrib/messages/tests/test_api.py
@@ -1,6 +1,5 @@
-from django.test import TestCase, RequestFactory
-
from django.contrib import messages
+from django.test import RequestFactory, TestCase
class DummyStorage(object):
diff --git a/django/contrib/messages/tests/test_cookie.py b/django/contrib/messages/tests/test_cookie.py
index ba7b4dc08b..c986a174ca 100644
--- a/django/contrib/messages/tests/test_cookie.py
+++ b/django/contrib/messages/tests/test_cookie.py
@@ -1,10 +1,11 @@
import json
from django.contrib.messages import constants
-from django.contrib.messages.tests.base import BaseTests
-from django.contrib.messages.storage.cookie import (CookieStorage,
- MessageEncoder, MessageDecoder)
from django.contrib.messages.storage.base import Message
+from django.contrib.messages.storage.cookie import (
+ CookieStorage, MessageDecoder, MessageEncoder,
+)
+from django.contrib.messages.tests.base import BaseTests
from django.test import TestCase, override_settings
from django.utils.safestring import SafeData, mark_safe
diff --git a/django/contrib/messages/tests/test_fallback.py b/django/contrib/messages/tests/test_fallback.py
index cd0b1888f3..0afbe75ae6 100644
--- a/django/contrib/messages/tests/test_fallback.py
+++ b/django/contrib/messages/tests/test_fallback.py
@@ -1,11 +1,14 @@
from django.contrib.messages import constants
-from django.contrib.messages.storage.fallback import (FallbackStorage,
- CookieStorage)
+from django.contrib.messages.storage.fallback import (
+ CookieStorage, FallbackStorage,
+)
from django.contrib.messages.tests.base import BaseTests
-from django.contrib.messages.tests.test_cookie import (set_cookie_data,
- stored_cookie_messages_count)
-from django.contrib.messages.tests.test_session import (set_session_data,
- stored_session_messages_count)
+from django.contrib.messages.tests.test_cookie import (
+ set_cookie_data, stored_cookie_messages_count,
+)
+from django.contrib.messages.tests.test_session import (
+ set_session_data, stored_session_messages_count,
+)
from django.test import TestCase
diff --git a/django/contrib/messages/tests/test_mixins.py b/django/contrib/messages/tests/test_mixins.py
index 35bb86d057..bb0bb797d4 100644
--- a/django/contrib/messages/tests/test_mixins.py
+++ b/django/contrib/messages/tests/test_mixins.py
@@ -1,6 +1,6 @@
-from django.test import TestCase, override_settings
from django.contrib.messages.tests.urls import ContactFormViewWithMsg
from django.core.urlresolvers import reverse
+from django.test import TestCase, override_settings
@override_settings(ROOT_URLCONF='django.contrib.messages.tests.urls')
diff --git a/django/contrib/messages/tests/test_session.py b/django/contrib/messages/tests/test_session.py
index 940e1c02d0..cca659d3d8 100644
--- a/django/contrib/messages/tests/test_session.py
+++ b/django/contrib/messages/tests/test_session.py
@@ -1,9 +1,9 @@
from django.contrib.messages import constants
-from django.contrib.messages.tests.base import BaseTests
from django.contrib.messages.storage.base import Message
from django.contrib.messages.storage.session import SessionStorage
-from django.utils.safestring import SafeData, mark_safe
+from django.contrib.messages.tests.base import BaseTests
from django.test import TestCase
+from django.utils.safestring import SafeData, mark_safe
def set_session_data(storage, messages):
diff --git a/django/contrib/messages/tests/urls.py b/django/contrib/messages/tests/urls.py
index 43cc6063cb..d748690044 100644
--- a/django/contrib/messages/tests/urls.py
+++ b/django/contrib/messages/tests/urls.py
@@ -1,14 +1,15 @@
+from django import forms
from django.conf.urls import url
from django.contrib import messages
+from django.contrib.messages.views import SuccessMessageMixin
from django.core.urlresolvers import reverse
-from django import forms
-from django.http import HttpResponseRedirect, HttpResponse
+from django.http import HttpResponse, HttpResponseRedirect
from django.template import engines
from django.template.response import TemplateResponse
from django.views.decorators.cache import never_cache
-from django.contrib.messages.views import SuccessMessageMixin
from django.views.generic.edit import FormView
+
TEMPLATE = """{% if messages %}
<ul class="messages">
{% for message in messages %}
diff --git a/django/contrib/postgres/fields/array.py b/django/contrib/postgres/fields/array.py
index af575c6b30..8e442c4a7a 100644
--- a/django/contrib/postgres/fields/array.py
+++ b/django/contrib/postgres/fields/array.py
@@ -4,11 +4,10 @@ from django.contrib.postgres import lookups
from django.contrib.postgres.forms import SimpleArrayField
from django.contrib.postgres.validators import ArrayMaxLengthValidator
from django.core import checks, exceptions
-from django.db.models import Field, Transform, IntegerField
+from django.db.models import Field, IntegerField, Transform
from django.utils import six
from django.utils.translation import string_concat, ugettext_lazy as _
-
__all__ = ['ArrayField']
diff --git a/django/contrib/postgres/fields/hstore.py b/django/contrib/postgres/fields/hstore.py
index 1524368ecf..461fa047e2 100644
--- a/django/contrib/postgres/fields/hstore.py
+++ b/django/contrib/postgres/fields/hstore.py
@@ -3,11 +3,10 @@ import json
from django.contrib.postgres import forms, lookups
from django.contrib.postgres.fields.array import ArrayField
from django.core import exceptions
-from django.db.models import Field, Transform, TextField
+from django.db.models import Field, TextField, Transform
from django.utils import six
from django.utils.translation import ugettext_lazy as _
-
__all__ = ['HStoreField']
diff --git a/django/contrib/postgres/fields/ranges.py b/django/contrib/postgres/fields/ranges.py
index 8cb5229593..679e87f44e 100644
--- a/django/contrib/postgres/fields/ranges.py
+++ b/django/contrib/postgres/fields/ranges.py
@@ -1,12 +1,11 @@
import json
-from django.contrib.postgres import lookups, forms
+from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange, Range
+
+from django.contrib.postgres import forms, lookups
from django.db import models
from django.utils import six
-from psycopg2.extras import Range, NumericRange, DateRange, DateTimeTZRange
-
-
__all__ = [
'RangeField', 'IntegerRangeField', 'BigIntegerRangeField',
'FloatRangeField', 'DateTimeRangeField', 'DateRangeField',
diff --git a/django/contrib/postgres/forms/array.py b/django/contrib/postgres/forms/array.py
index 0bd4ee4916..01c4d53527 100644
--- a/django/contrib/postgres/forms/array.py
+++ b/django/contrib/postgres/forms/array.py
@@ -1,10 +1,12 @@
import copy
-from django.contrib.postgres.validators import ArrayMinLengthValidator, ArrayMaxLengthValidator
-from django.core.exceptions import ValidationError
from django import forms
-from django.utils.safestring import mark_safe
+from django.contrib.postgres.validators import (
+ ArrayMaxLengthValidator, ArrayMinLengthValidator,
+)
+from django.core.exceptions import ValidationError
from django.utils import six
+from django.utils.safestring import mark_safe
from django.utils.translation import string_concat, ugettext_lazy as _
diff --git a/django/contrib/postgres/forms/hstore.py b/django/contrib/postgres/forms/hstore.py
index 548be0f570..2c564ea53c 100644
--- a/django/contrib/postgres/forms/hstore.py
+++ b/django/contrib/postgres/forms/hstore.py
@@ -5,7 +5,6 @@ from django.core.exceptions import ValidationError
from django.utils import six
from django.utils.translation import ugettext_lazy as _
-
__all__ = ['HStoreField']
diff --git a/django/contrib/postgres/forms/ranges.py b/django/contrib/postgres/forms/ranges.py
index 23db4fe514..80ea8299c9 100644
--- a/django/contrib/postgres/forms/ranges.py
+++ b/django/contrib/postgres/forms/ranges.py
@@ -1,11 +1,10 @@
-from django.core import exceptions
+from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange
+
from django import forms
+from django.core import exceptions
from django.forms.widgets import MultiWidget
from django.utils.translation import ugettext_lazy as _
-from psycopg2.extras import NumericRange, DateRange, DateTimeTZRange
-
-
__all__ = ['IntegerRangeField', 'FloatRangeField', 'DateTimeRangeField', 'DateRangeField']
diff --git a/django/contrib/postgres/signals.py b/django/contrib/postgres/signals.py
index 602dd08700..183ba1d983 100644
--- a/django/contrib/postgres/signals.py
+++ b/django/contrib/postgres/signals.py
@@ -1,8 +1,8 @@
-from django.utils import six
-
from psycopg2 import ProgrammingError
from psycopg2.extras import register_hstore
+from django.utils import six
+
def register_hstore_handler(connection, **kwargs):
if connection.vendor != 'postgresql':
diff --git a/django/contrib/postgres/validators.py b/django/contrib/postgres/validators.py
index 49ec921db1..3f576873f4 100644
--- a/django/contrib/postgres/validators.py
+++ b/django/contrib/postgres/validators.py
@@ -2,11 +2,11 @@ import copy
from django.core.exceptions import ValidationError
from django.core.validators import (
- MaxLengthValidator, MinLengthValidator, MaxValueValidator,
+ MaxLengthValidator, MaxValueValidator, MinLengthValidator,
MinValueValidator,
)
from django.utils.deconstruct import deconstructible
-from django.utils.translation import ungettext_lazy, ugettext_lazy as _
+from django.utils.translation import ugettext_lazy as _, ungettext_lazy
class ArrayMaxLengthValidator(MaxLengthValidator):
diff --git a/django/contrib/redirects/apps.py b/django/contrib/redirects/apps.py
index 247d8b5177..f09437ed00 100644
--- a/django/contrib/redirects/apps.py
+++ b/django/contrib/redirects/apps.py
@@ -1,5 +1,4 @@
from django.apps import AppConfig
-
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/redirects/middleware.py b/django/contrib/redirects/middleware.py
index 6f0b6bc92e..903eb11abf 100644
--- a/django/contrib/redirects/middleware.py
+++ b/django/contrib/redirects/middleware.py
@@ -1,11 +1,11 @@
from __future__ import unicode_literals
+from django import http
from django.apps import apps
from django.conf import settings
from django.contrib.redirects.models import Redirect
from django.contrib.sites.shortcuts import get_current_site
from django.core.exceptions import ImproperlyConfigured
-from django import http
class RedirectFallbackMiddleware(object):
diff --git a/django/contrib/redirects/migrations/0001_initial.py b/django/contrib/redirects/migrations/0001_initial.py
index 6f16c47f14..49906348bf 100644
--- a/django/contrib/redirects/migrations/0001_initial.py
+++ b/django/contrib/redirects/migrations/0001_initial.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/redirects/models.py b/django/contrib/redirects/models.py
index 2051ac039a..2d26673121 100644
--- a/django/contrib/redirects/models.py
+++ b/django/contrib/redirects/models.py
@@ -1,7 +1,7 @@
-from django.db import models
from django.contrib.sites.models import Site
-from django.utils.translation import ugettext_lazy as _
+from django.db import models
from django.utils.encoding import python_2_unicode_compatible
+from django.utils.translation import ugettext_lazy as _
@python_2_unicode_compatible
diff --git a/django/contrib/sessions/apps.py b/django/contrib/sessions/apps.py
index 78110a477d..1e75a6fff8 100644
--- a/django/contrib/sessions/apps.py
+++ b/django/contrib/sessions/apps.py
@@ -1,5 +1,4 @@
from django.apps import AppConfig
-
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/sessions/backends/base.py b/django/contrib/sessions/backends/base.py
index c7819b220d..3b24b8d3d7 100644
--- a/django/contrib/sessions/backends/base.py
+++ b/django/contrib/sessions/backends/base.py
@@ -1,21 +1,20 @@
from __future__ import unicode_literals
import base64
-from datetime import datetime, timedelta
import logging
import string
+from datetime import datetime, timedelta
from django.conf import settings
+from django.contrib.sessions.exceptions import SuspiciousSession
from django.core.exceptions import SuspiciousOperation
-from django.utils.crypto import constant_time_compare
-from django.utils.crypto import get_random_string
-from django.utils.crypto import salted_hmac
from django.utils import timezone
+from django.utils.crypto import (
+ constant_time_compare, get_random_string, salted_hmac,
+)
from django.utils.encoding import force_bytes, force_text
from django.utils.module_loading import import_string
-from django.contrib.sessions.exceptions import SuspiciousSession
-
# session_key should not be case sensitive because some backends can store it
# on case insensitive file systems.
VALID_KEY_CHARS = string.ascii_lowercase + string.digits
diff --git a/django/contrib/sessions/backends/cache.py b/django/contrib/sessions/backends/cache.py
index 2cac8296d5..38b6112f51 100644
--- a/django/contrib/sessions/backends/cache.py
+++ b/django/contrib/sessions/backends/cache.py
@@ -1,5 +1,5 @@
from django.conf import settings
-from django.contrib.sessions.backends.base import SessionBase, CreateError
+from django.contrib.sessions.backends.base import CreateError, SessionBase
from django.core.cache import caches
from django.utils.six.moves import range
diff --git a/django/contrib/sessions/backends/cached_db.py b/django/contrib/sessions/backends/cached_db.py
index 71bf40d9c4..23e0a74bbf 100644
--- a/django/contrib/sessions/backends/cached_db.py
+++ b/django/contrib/sessions/backends/cached_db.py
@@ -83,4 +83,4 @@ class SessionStore(DBStore):
# At bottom to avoid circular import
-from django.contrib.sessions.models import Session
+from django.contrib.sessions.models import Session # isort:skip
diff --git a/django/contrib/sessions/backends/db.py b/django/contrib/sessions/backends/db.py
index a087061c1f..30e2675b3b 100644
--- a/django/contrib/sessions/backends/db.py
+++ b/django/contrib/sessions/backends/db.py
@@ -1,8 +1,8 @@
import logging
-from django.contrib.sessions.backends.base import SessionBase, CreateError
+from django.contrib.sessions.backends.base import CreateError, SessionBase
from django.core.exceptions import SuspiciousOperation
-from django.db import IntegrityError, transaction, router
+from django.db import IntegrityError, router, transaction
from django.utils import timezone
from django.utils.encoding import force_text
@@ -83,4 +83,4 @@ class SessionStore(SessionBase):
# At bottom to avoid circular import
-from django.contrib.sessions.models import Session
+from django.contrib.sessions.models import Session # isort:skip
diff --git a/django/contrib/sessions/backends/file.py b/django/contrib/sessions/backends/file.py
index 6569dafbe3..10d163acc4 100644
--- a/django/contrib/sessions/backends/file.py
+++ b/django/contrib/sessions/backends/file.py
@@ -6,13 +6,14 @@ import shutil
import tempfile
from django.conf import settings
-from django.contrib.sessions.backends.base import SessionBase, CreateError, VALID_KEY_CHARS
-from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured
+from django.contrib.sessions.backends.base import (
+ VALID_KEY_CHARS, CreateError, SessionBase,
+)
+from django.contrib.sessions.exceptions import InvalidSessionKey
+from django.core.exceptions import ImproperlyConfigured, SuspiciousOperation
from django.utils import timezone
from django.utils.encoding import force_text
-from django.contrib.sessions.exceptions import InvalidSessionKey
-
class SessionStore(SessionBase):
"""
diff --git a/django/contrib/sessions/backends/signed_cookies.py b/django/contrib/sessions/backends/signed_cookies.py
index 77a6750ce4..b51d3c3053 100644
--- a/django/contrib/sessions/backends/signed_cookies.py
+++ b/django/contrib/sessions/backends/signed_cookies.py
@@ -1,7 +1,6 @@
from django.conf import settings
-from django.core import signing
-
from django.contrib.sessions.backends.base import SessionBase
+from django.core import signing
class SessionStore(SessionBase):
diff --git a/django/contrib/sessions/middleware.py b/django/contrib/sessions/middleware.py
index d1595b1ae4..69ca669033 100644
--- a/django/contrib/sessions/middleware.py
+++ b/django/contrib/sessions/middleware.py
@@ -1,5 +1,5 @@
-from importlib import import_module
import time
+from importlib import import_module
from django.conf import settings
from django.utils.cache import patch_vary_headers
diff --git a/django/contrib/sessions/migrations/0001_initial.py b/django/contrib/sessions/migrations/0001_initial.py
index ade7ac6043..82b856ae62 100644
--- a/django/contrib/sessions/migrations/0001_initial.py
+++ b/django/contrib/sessions/migrations/0001_initial.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
import django.contrib.sessions.models
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/sessions/models.py b/django/contrib/sessions/models.py
index bd2b7dfcf4..ce9d609a9b 100644
--- a/django/contrib/sessions/models.py
+++ b/django/contrib/sessions/models.py
@@ -60,4 +60,4 @@ class Session(models.Model):
# At bottom to avoid circular import
-from django.contrib.sessions.backends.db import SessionStore
+from django.contrib.sessions.backends.db import SessionStore # isort:skip
diff --git a/django/contrib/sessions/serializers.py b/django/contrib/sessions/serializers.py
index 92a31c054b..b272c9c95d 100644
--- a/django/contrib/sessions/serializers.py
+++ b/django/contrib/sessions/serializers.py
@@ -1,4 +1,5 @@
from django.core.signing import JSONSerializer as BaseJSONSerializer
+
try:
from django.utils.six.moves import cPickle as pickle
except ImportError:
diff --git a/django/contrib/sessions/tests.py b/django/contrib/sessions/tests.py
index f39d46a8f6..112ac30d35 100644
--- a/django/contrib/sessions/tests.py
+++ b/django/contrib/sessions/tests.py
@@ -1,33 +1,35 @@
import base64
-from datetime import timedelta
import os
import shutil
import string
import tempfile
import unittest
+from datetime import timedelta
from django.conf import settings
-from django.contrib.sessions.backends.db import SessionStore as DatabaseSession
from django.contrib.sessions.backends.cache import SessionStore as CacheSession
-from django.contrib.sessions.backends.cached_db import SessionStore as CacheDBSession
+from django.contrib.sessions.backends.cached_db import \
+ SessionStore as CacheDBSession
+from django.contrib.sessions.backends.db import SessionStore as DatabaseSession
from django.contrib.sessions.backends.file import SessionStore as FileSession
-from django.contrib.sessions.backends.signed_cookies import SessionStore as CookieSession
-from django.contrib.sessions.models import Session
+from django.contrib.sessions.backends.signed_cookies import \
+ SessionStore as CookieSession
+from django.contrib.sessions.exceptions import InvalidSessionKey
from django.contrib.sessions.middleware import SessionMiddleware
+from django.contrib.sessions.models import Session
+from django.core import management
from django.core.cache import caches
from django.core.cache.backends.base import InvalidCacheBackendError
-from django.core import management
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpResponse
-from django.test import TestCase, RequestFactory, ignore_warnings, override_settings
+from django.test import (
+ RequestFactory, TestCase, ignore_warnings, override_settings,
+)
from django.test.utils import patch_logger
-from django.utils import six
-from django.utils import timezone
+from django.utils import six, timezone
from django.utils.encoding import force_text
from django.utils.six.moves import http_cookies
-from django.contrib.sessions.exceptions import InvalidSessionKey
-
class SessionTestsMixin(object):
# This does not inherit from TestCase to avoid any tests being run with this
diff --git a/django/contrib/sitemaps/apps.py b/django/contrib/sitemaps/apps.py
index 3749b5a759..e2abc70e24 100644
--- a/django/contrib/sitemaps/apps.py
+++ b/django/contrib/sitemaps/apps.py
@@ -1,5 +1,4 @@
from django.apps import AppConfig
-
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/sitemaps/management/commands/ping_google.py b/django/contrib/sitemaps/management/commands/ping_google.py
index f2e7c79856..d362372bed 100644
--- a/django/contrib/sitemaps/management/commands/ping_google.py
+++ b/django/contrib/sitemaps/management/commands/ping_google.py
@@ -1,5 +1,5 @@
-from django.core.management.base import BaseCommand
from django.contrib.sitemaps import ping_google
+from django.core.management.base import BaseCommand
class Command(BaseCommand):
diff --git a/django/contrib/sitemaps/tests/test_generic.py b/django/contrib/sitemaps/tests/test_generic.py
index 870e29886d..8dd8bdce09 100644
--- a/django/contrib/sitemaps/tests/test_generic.py
+++ b/django/contrib/sitemaps/tests/test_generic.py
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
from django.test import override_settings
-from .base import TestModel, SitemapTestsBase
+from .base import SitemapTestsBase, TestModel
@override_settings(ABSOLUTE_URL_OVERRIDES={})
diff --git a/django/contrib/sitemaps/tests/test_http.py b/django/contrib/sitemaps/tests/test_http.py
index dde9e97c01..d3885ac1f1 100644
--- a/django/contrib/sitemaps/tests/test_http.py
+++ b/django/contrib/sitemaps/tests/test_http.py
@@ -6,16 +6,16 @@ from unittest import skipUnless
from django.apps import apps
from django.conf import settings
-from django.contrib.sitemaps import Sitemap, GenericSitemap
+from django.contrib.sitemaps import GenericSitemap, Sitemap
from django.contrib.sites.models import Site
from django.core.exceptions import ImproperlyConfigured
from django.test import ignore_warnings, modify_settings, override_settings
+from django.utils._os import upath
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.formats import localize
-from django.utils._os import upath
from django.utils.translation import activate, deactivate
-from .base import TestModel, SitemapTestsBase
+from .base import SitemapTestsBase, TestModel
class HTTPSitemapTests(SitemapTestsBase):
diff --git a/django/contrib/sitemaps/tests/urls/http.py b/django/contrib/sitemaps/tests/urls/http.py
index c7bcc0fac0..052aec17c1 100644
--- a/django/contrib/sitemaps/tests/urls/http.py
+++ b/django/contrib/sitemaps/tests/urls/http.py
@@ -1,13 +1,13 @@
from datetime import date, datetime
+
from django.conf.urls import url
from django.conf.urls.i18n import i18n_patterns
-from django.contrib.sitemaps import Sitemap, GenericSitemap, views
+from django.contrib.sitemaps import GenericSitemap, Sitemap, views
+from django.contrib.sitemaps.tests.base import I18nTestModel, TestModel
from django.http import HttpResponse
from django.utils import timezone
from django.views.decorators.cache import cache_page
-from django.contrib.sitemaps.tests.base import I18nTestModel, TestModel
-
class SimpleSitemap(Sitemap):
changefreq = "never"
diff --git a/django/contrib/sitemaps/views.py b/django/contrib/sitemaps/views.py
index a743f6e614..e08a307c51 100644
--- a/django/contrib/sitemaps/views.py
+++ b/django/contrib/sitemaps/views.py
@@ -1,5 +1,5 @@
-from calendar import timegm
import datetime
+from calendar import timegm
from functools import wraps
from django.contrib.sites.shortcuts import get_current_site
diff --git a/django/contrib/sites/apps.py b/django/contrib/sites/apps.py
index c639c3053b..7d319e0199 100644
--- a/django/contrib/sites/apps.py
+++ b/django/contrib/sites/apps.py
@@ -1,5 +1,4 @@
from django.apps import AppConfig
-
from django.db.models.signals import post_migrate
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/sites/migrations/0001_initial.py b/django/contrib/sites/migrations/0001_initial.py
index 00ac06de10..84ad0cd408 100644
--- a/django/contrib/sites/migrations/0001_initial.py
+++ b/django/contrib/sites/migrations/0001_initial.py
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
-from django.contrib.sites.models import _simple_domain_name_validator
import django.contrib.sites.models
+from django.contrib.sites.models import _simple_domain_name_validator
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/django/contrib/sites/models.py b/django/contrib/sites/models.py
index 440cfb8b11..6f983dc009 100644
--- a/django/contrib/sites/models.py
+++ b/django/contrib/sites/models.py
@@ -4,11 +4,10 @@ import string
from django.core.exceptions import ImproperlyConfigured, ValidationError
from django.db import models
-from django.db.models.signals import pre_save, pre_delete
+from django.db.models.signals import pre_delete, pre_save
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import ugettext_lazy as _
-
SITE_CACHE = {}
diff --git a/django/contrib/sites/tests.py b/django/contrib/sites/tests.py
index c820b0247f..f58c807622 100644
--- a/django/contrib/sites/tests.py
+++ b/django/contrib/sites/tests.py
@@ -11,7 +11,7 @@ from django.test.utils import captured_stdout
from . import models
from .management import create_default_site
from .middleware import CurrentSiteMiddleware
-from .models import clear_site_cache, Site
+from .models import Site, clear_site_cache
from .requests import RequestSite
from .shortcuts import get_current_site
diff --git a/django/contrib/staticfiles/apps.py b/django/contrib/staticfiles/apps.py
index ae69667b7b..f406e16181 100644
--- a/django/contrib/staticfiles/apps.py
+++ b/django/contrib/staticfiles/apps.py
@@ -1,5 +1,4 @@
from django.apps import AppConfig
-
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/staticfiles/finders.py b/django/contrib/staticfiles/finders.py
index 3569f360b2..7c775e7f89 100644
--- a/django/contrib/staticfiles/finders.py
+++ b/django/contrib/staticfiles/finders.py
@@ -1,16 +1,17 @@
-from collections import OrderedDict
import os
+from collections import OrderedDict
from django.apps import apps
from django.conf import settings
+from django.contrib.staticfiles import utils
from django.core.exceptions import ImproperlyConfigured
-from django.core.files.storage import default_storage, Storage, FileSystemStorage
-from django.utils.functional import empty, LazyObject
-from django.utils.module_loading import import_string
+from django.core.files.storage import (
+ FileSystemStorage, Storage, default_storage,
+)
+from django.utils import lru_cache, six
from django.utils._os import safe_join
-from django.utils import six, lru_cache
-
-from django.contrib.staticfiles import utils
+from django.utils.functional import LazyObject, empty
+from django.utils.module_loading import import_string
# To keep track on which directories the finder has searched the static files.
searched_locations = []
diff --git a/django/contrib/staticfiles/handlers.py b/django/contrib/staticfiles/handlers.py
index e711f9a476..8dedd60ce8 100644
--- a/django/contrib/staticfiles/handlers.py
+++ b/django/contrib/staticfiles/handlers.py
@@ -1,10 +1,9 @@
from django.conf import settings
-from django.core.handlers.wsgi import get_path_info, WSGIHandler
-from django.utils.six.moves.urllib.parse import urlparse
-from django.utils.six.moves.urllib.request import url2pathname
-
from django.contrib.staticfiles import utils
from django.contrib.staticfiles.views import serve
+from django.core.handlers.wsgi import WSGIHandler, get_path_info
+from django.utils.six.moves.urllib.parse import urlparse
+from django.utils.six.moves.urllib.request import url2pathname
class StaticFilesHandler(WSGIHandler):
diff --git a/django/contrib/staticfiles/management/commands/collectstatic.py b/django/contrib/staticfiles/management/commands/collectstatic.py
index 10c8c8f8d9..1ed7127f96 100644
--- a/django/contrib/staticfiles/management/commands/collectstatic.py
+++ b/django/contrib/staticfiles/management/commands/collectstatic.py
@@ -3,15 +3,14 @@ from __future__ import unicode_literals
import os
from collections import OrderedDict
+from django.contrib.staticfiles.finders import get_finders
+from django.contrib.staticfiles.storage import staticfiles_storage
from django.core.files.storage import FileSystemStorage
-from django.core.management.base import CommandError, BaseCommand
+from django.core.management.base import BaseCommand, CommandError
from django.core.management.color import no_style
from django.utils.encoding import smart_text
from django.utils.six.moves import input
-from django.contrib.staticfiles.finders import get_finders
-from django.contrib.staticfiles.storage import staticfiles_storage
-
class Command(BaseCommand):
"""
diff --git a/django/contrib/staticfiles/management/commands/findstatic.py b/django/contrib/staticfiles/management/commands/findstatic.py
index 658ac3f248..2152035dbb 100644
--- a/django/contrib/staticfiles/management/commands/findstatic.py
+++ b/django/contrib/staticfiles/management/commands/findstatic.py
@@ -1,10 +1,10 @@
from __future__ import unicode_literals
import os
-from django.core.management.base import LabelCommand
-from django.utils.encoding import force_text
from django.contrib.staticfiles import finders
+from django.core.management.base import LabelCommand
+from django.utils.encoding import force_text
class Command(LabelCommand):
diff --git a/django/contrib/staticfiles/management/commands/runserver.py b/django/contrib/staticfiles/management/commands/runserver.py
index fd358bee3d..d42c773457 100644
--- a/django/contrib/staticfiles/management/commands/runserver.py
+++ b/django/contrib/staticfiles/management/commands/runserver.py
@@ -1,7 +1,7 @@
from django.conf import settings
-from django.core.management.commands.runserver import Command as RunserverCommand
-
from django.contrib.staticfiles.handlers import StaticFilesHandler
+from django.core.management.commands.runserver import \
+ Command as RunserverCommand
class Command(RunserverCommand):
diff --git a/django/contrib/staticfiles/storage.py b/django/contrib/staticfiles/storage.py
index 9046bb1d51..6a0a5407dd 100644
--- a/django/contrib/staticfiles/storage.py
+++ b/django/contrib/staticfiles/storage.py
@@ -1,22 +1,25 @@
from __future__ import unicode_literals
-from collections import OrderedDict
+
import hashlib
+import json
import os
import posixpath
import re
-import json
+from collections import OrderedDict
from django.conf import settings
-from django.core.cache import (caches, InvalidCacheBackendError,
- cache as default_cache)
+from django.contrib.staticfiles.utils import check_settings, matches_patterns
+from django.core.cache import (
+ InvalidCacheBackendError, cache as default_cache, caches,
+)
from django.core.exceptions import ImproperlyConfigured
from django.core.files.base import ContentFile
from django.core.files.storage import FileSystemStorage, get_storage_class
from django.utils.encoding import force_bytes, force_text
from django.utils.functional import LazyObject
-from django.utils.six.moves.urllib.parse import unquote, urlsplit, urlunsplit, urldefrag
-
-from django.contrib.staticfiles.utils import check_settings, matches_patterns
+from django.utils.six.moves.urllib.parse import (
+ unquote, urldefrag, urlsplit, urlunsplit,
+)
class StaticFilesStorage(FileSystemStorage):
diff --git a/django/contrib/staticfiles/templatetags/staticfiles.py b/django/contrib/staticfiles/templatetags/staticfiles.py
index b5466cab31..e666e3adba 100644
--- a/django/contrib/staticfiles/templatetags/staticfiles.py
+++ b/django/contrib/staticfiles/templatetags/staticfiles.py
@@ -1,6 +1,6 @@
from django import template
-from django.templatetags.static import StaticNode
from django.contrib.staticfiles.storage import staticfiles_storage
+from django.templatetags.static import StaticNode
register = template.Library()
diff --git a/django/contrib/staticfiles/testing.py b/django/contrib/staticfiles/testing.py
index 7b30499ece..4eb4adcd04 100644
--- a/django/contrib/staticfiles/testing.py
+++ b/django/contrib/staticfiles/testing.py
@@ -1,6 +1,5 @@
-from django.test import LiveServerTestCase
-
from django.contrib.staticfiles.handlers import StaticFilesHandler
+from django.test import LiveServerTestCase
class StaticLiveServerTestCase(LiveServerTestCase):
diff --git a/django/contrib/staticfiles/utils.py b/django/contrib/staticfiles/utils.py
index 92bca71d57..2c44bb7790 100644
--- a/django/contrib/staticfiles/utils.py
+++ b/django/contrib/staticfiles/utils.py
@@ -1,5 +1,6 @@
-import os
import fnmatch
+import os
+
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
diff --git a/django/contrib/staticfiles/views.py b/django/contrib/staticfiles/views.py
index 166879a0e5..cec1247e5e 100644
--- a/django/contrib/staticfiles/views.py
+++ b/django/contrib/staticfiles/views.py
@@ -7,12 +7,11 @@ import os
import posixpath
from django.conf import settings
+from django.contrib.staticfiles import finders
from django.http import Http404
from django.utils.six.moves.urllib.parse import unquote
from django.views import static
-from django.contrib.staticfiles import finders
-
def serve(request, path, insecure=False, **kwargs):
"""
diff --git a/django/contrib/syndication/apps.py b/django/contrib/syndication/apps.py
index 8a34fe18f8..27bda578a4 100644
--- a/django/contrib/syndication/apps.py
+++ b/django/contrib/syndication/apps.py
@@ -1,5 +1,4 @@
from django.apps import AppConfig
-
from django.utils.translation import ugettext_lazy as _
diff --git a/django/contrib/syndication/views.py b/django/contrib/syndication/views.py
index da38323b01..e8511ddfc9 100644
--- a/django/contrib/syndication/views.py
+++ b/django/contrib/syndication/views.py
@@ -5,13 +5,12 @@ from calendar import timegm
from django.conf import settings
from django.contrib.sites.shortcuts import get_current_site
from django.core.exceptions import ImproperlyConfigured, ObjectDoesNotExist
-from django.http import HttpResponse, Http404
-from django.template import loader, TemplateDoesNotExist
-from django.utils import feedgenerator
+from django.http import Http404, HttpResponse
+from django.template import TemplateDoesNotExist, loader
+from django.utils import feedgenerator, six
from django.utils.encoding import force_text, iri_to_uri, smart_text
from django.utils.html import escape
from django.utils.http import http_date
-from django.utils import six
from django.utils.timezone import get_default_timezone, is_naive, make_aware
diff --git a/django/contrib/webdesign/apps.py b/django/contrib/webdesign/apps.py
index b78e801795..9a332a2234 100644
--- a/django/contrib/webdesign/apps.py
+++ b/django/contrib/webdesign/apps.py
@@ -1,5 +1,4 @@
from django.apps import AppConfig
-
from django.utils.translation import ugettext_lazy as _
diff --git a/django/core/cache/backends/base.py b/django/core/cache/backends/base.py
index 4b7806fc29..7ac1e5bc32 100644
--- a/django/core/cache/backends/base.py
+++ b/django/core/cache/backends/base.py
@@ -4,7 +4,7 @@ from __future__ import unicode_literals
import time
import warnings
-from django.core.exceptions import ImproperlyConfigured, DjangoRuntimeWarning
+from django.core.exceptions import DjangoRuntimeWarning, ImproperlyConfigured
from django.utils.module_loading import import_string
diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py
index 99ce96d49e..f016179491 100644
--- a/django/core/cache/backends/db.py
+++ b/django/core/cache/backends/db.py
@@ -2,18 +2,18 @@
import base64
from datetime import datetime
+from django.conf import settings
+from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
+from django.db import DatabaseError, connections, router, transaction
+from django.db.backends.utils import typecast_timestamp
+from django.utils import six, timezone
+from django.utils.encoding import force_bytes
+
try:
from django.utils.six.moves import cPickle as pickle
except ImportError:
import pickle
-from django.conf import settings
-from django.core.cache.backends.base import BaseCache, DEFAULT_TIMEOUT
-from django.db import connections, transaction, router, DatabaseError
-from django.db.backends.utils import typecast_timestamp
-from django.utils import timezone, six
-from django.utils.encoding import force_bytes
-
class Options(object):
"""A class that will quack like a Django model _meta class.
diff --git a/django/core/cache/backends/dummy.py b/django/core/cache/backends/dummy.py
index eb21feebdf..d1aea0a325 100644
--- a/django/core/cache/backends/dummy.py
+++ b/django/core/cache/backends/dummy.py
@@ -1,6 +1,6 @@
"Dummy cache backend"
-from django.core.cache.backends.base import BaseCache, DEFAULT_TIMEOUT
+from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
class DummyCache(BaseCache):
diff --git a/django/core/cache/backends/filebased.py b/django/core/cache/backends/filebased.py
index 94fdfa9ed7..c35efce92c 100644
--- a/django/core/cache/backends/filebased.py
+++ b/django/core/cache/backends/filebased.py
@@ -8,9 +8,11 @@ import random
import tempfile
import time
import zlib
-from django.core.cache.backends.base import BaseCache, DEFAULT_TIMEOUT
+
+from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
from django.core.files.move import file_move_safe
from django.utils.encoding import force_bytes
+
try:
from django.utils.six.moves import cPickle as pickle
except ImportError:
diff --git a/django/core/cache/backends/locmem.py b/django/core/cache/backends/locmem.py
index edf0ff22a7..8916ad176c 100644
--- a/django/core/cache/backends/locmem.py
+++ b/django/core/cache/backends/locmem.py
@@ -1,15 +1,16 @@
"Thread-safe in-memory cache backend."
-from contextlib import contextmanager
import time
+from contextlib import contextmanager
+
+from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
+from django.utils.synch import RWLock
+
try:
from django.utils.six.moves import cPickle as pickle
except ImportError:
import pickle
-from django.core.cache.backends.base import BaseCache, DEFAULT_TIMEOUT
-from django.utils.synch import RWLock
-
# Global in-memory store of cache data. Keyed by name, to provide
# multiple named local memory caches.
diff --git a/django/core/cache/backends/memcached.py b/django/core/cache/backends/memcached.py
index d5058c1e73..af68885641 100644
--- a/django/core/cache/backends/memcached.py
+++ b/django/core/cache/backends/memcached.py
@@ -1,9 +1,9 @@
"Memcached cache backend"
-import time
import pickle
+import time
-from django.core.cache.backends.base import BaseCache, DEFAULT_TIMEOUT
+from django.core.cache.backends.base import DEFAULT_TIMEOUT, BaseCache
from django.utils import six
from django.utils.encoding import force_str
from django.utils.functional import cached_property
diff --git a/django/core/cache/utils.py b/django/core/cache/utils.py
index dd9ad4abd1..c40e4eba0c 100644
--- a/django/core/cache/utils.py
+++ b/django/core/cache/utils.py
@@ -1,6 +1,7 @@
from __future__ import unicode_literals
import hashlib
+
from django.utils.encoding import force_bytes
from django.utils.http import urlquote
diff --git a/django/core/checks/compatibility/django_1_7_0.py b/django/core/checks/compatibility/django_1_7_0.py
index d164241a55..878541d3e5 100644
--- a/django/core/checks/compatibility/django_1_7_0.py
+++ b/django/core/checks/compatibility/django_1_7_0.py
@@ -1,6 +1,6 @@
from __future__ import unicode_literals
-from .. import Warning, register, Tags
+from .. import Tags, Warning, register
@register(Tags.compatibility)
diff --git a/django/core/checks/messages.py b/django/core/checks/messages.py
index 6b5fd319a3..9245842039 100644
--- a/django/core/checks/messages.py
+++ b/django/core/checks/messages.py
@@ -1,8 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.utils.encoding import python_2_unicode_compatible, force_str
-
+from django.utils.encoding import force_str, python_2_unicode_compatible
# Levels
DEBUG = 10
diff --git a/django/core/checks/security/base.py b/django/core/checks/security/base.py
index 20fbd189b3..f740b63c7b 100644
--- a/django/core/checks/security/base.py
+++ b/django/core/checks/security/base.py
@@ -1,7 +1,6 @@
from django.conf import settings
-from .. import register, Tags, Warning
-
+from .. import Tags, Warning, register
SECRET_KEY_MIN_LENGTH = 50
SECRET_KEY_MIN_UNIQUE_CHARACTERS = 5
diff --git a/django/core/checks/security/csrf.py b/django/core/checks/security/csrf.py
index 79cb6d4fa4..3effbc4498 100644
--- a/django/core/checks/security/csrf.py
+++ b/django/core/checks/security/csrf.py
@@ -1,7 +1,6 @@
from django.conf import settings
-from .. import register, Tags, Warning
-
+from .. import Tags, Warning, register
W003 = Warning(
"You don't appear to be using Django's built-in "
diff --git a/django/core/checks/security/sessions.py b/django/core/checks/security/sessions.py
index b27aa1f9c2..7e857d74d8 100644
--- a/django/core/checks/security/sessions.py
+++ b/django/core/checks/security/sessions.py
@@ -1,6 +1,6 @@
from django.conf import settings
-from .. import register, Tags, Warning
+from .. import Tags, Warning, register
def add_session_cookie_message(message):
diff --git a/django/core/context_processors.py b/django/core/context_processors.py
index 19cc8b4def..f2303bec59 100644
--- a/django/core/context_processors.py
+++ b/django/core/context_processors.py
@@ -1,9 +1,8 @@
import warnings
-from django.template.context_processors import * # NOQA
+from django.template.context_processors import * # NOQA
from django.utils.deprecation import RemovedInDjango20Warning
-
warnings.warn(
"django.core.context_processors is deprecated in favor of "
"django.template.context_processors.",
diff --git a/django/core/files/move.py b/django/core/files/move.py
index 124529d9b9..f3972c5f98 100644
--- a/django/core/files/move.py
+++ b/django/core/files/move.py
@@ -10,7 +10,6 @@ from shutil import copystat
from django.core.files import locks
-
__all__ = ['file_move_safe']
diff --git a/django/core/files/storage.py b/django/core/files/storage.py
index 90ab1be27a..65b6d46463 100644
--- a/django/core/files/storage.py
+++ b/django/core/files/storage.py
@@ -1,23 +1,22 @@
-from datetime import datetime
import errno
-from inspect import getargspec
import os
import warnings
+from datetime import datetime
+from inspect import getargspec
from django.conf import settings
from django.core.exceptions import SuspiciousFileOperation
-from django.core.files import locks, File
+from django.core.files import File, locks
from django.core.files.move import file_move_safe
+from django.utils._os import abspathu, safe_join
from django.utils.crypto import get_random_string
-from django.utils.encoding import force_text, filepath_to_uri
+from django.utils.deconstruct import deconstructible
+from django.utils.deprecation import RemovedInDjango20Warning
+from django.utils.encoding import filepath_to_uri, force_text
from django.utils.functional import LazyObject
from django.utils.module_loading import import_string
from django.utils.six.moves.urllib.parse import urljoin
from django.utils.text import get_valid_filename
-from django.utils._os import safe_join, abspathu
-from django.utils.deconstruct import deconstructible
-from django.utils.deprecation import RemovedInDjango20Warning
-
__all__ = ('Storage', 'FileSystemStorage', 'DefaultStorage', 'default_storage')
diff --git a/django/core/files/temp.py b/django/core/files/temp.py
index 19849a4260..0791b8536e 100644
--- a/django/core/files/temp.py
+++ b/django/core/files/temp.py
@@ -18,6 +18,7 @@ full range of keyword arguments available in Python 2.6+ and 3.0+.
import os
import tempfile
+
from django.core.files.utils import FileProxyMixin
__all__ = ('NamedTemporaryFile', 'gettempdir',)
diff --git a/django/core/files/uploadedfile.py b/django/core/files/uploadedfile.py
index 9a94894424..20eaecea75 100644
--- a/django/core/files/uploadedfile.py
+++ b/django/core/files/uploadedfile.py
@@ -7,8 +7,8 @@ import os
from io import BytesIO
from django.conf import settings
-from django.core.files.base import File
from django.core.files import temp as tempfile
+from django.core.files.base import File
from django.utils.encoding import force_str
__all__ = ('UploadedFile', 'TemporaryUploadedFile', 'InMemoryUploadedFile',
diff --git a/django/core/files/uploadhandler.py b/django/core/files/uploadhandler.py
index c6fddce331..e5a2667342 100644
--- a/django/core/files/uploadhandler.py
+++ b/django/core/files/uploadhandler.py
@@ -7,7 +7,9 @@ from __future__ import unicode_literals
from io import BytesIO
from django.conf import settings
-from django.core.files.uploadedfile import TemporaryUploadedFile, InMemoryUploadedFile
+from django.core.files.uploadedfile import (
+ InMemoryUploadedFile, TemporaryUploadedFile,
+)
from django.utils.encoding import python_2_unicode_compatible
from django.utils.module_loading import import_string
diff --git a/django/core/handlers/base.py b/django/core/handlers/base.py
index eba7811529..e40eb2fa59 100644
--- a/django/core/handlers/base.py
+++ b/django/core/handlers/base.py
@@ -6,14 +6,15 @@ import types
from django import http
from django.conf import settings
-from django.core import urlresolvers
-from django.core import signals
-from django.core.exceptions import MiddlewareNotUsed, PermissionDenied, SuspiciousOperation
+from django.core import signals, urlresolvers
+from django.core.exceptions import (
+ MiddlewareNotUsed, PermissionDenied, SuspiciousOperation,
+)
from django.db import connections, transaction
from django.http.multipartparser import MultiPartParserError
+from django.utils import six
from django.utils.encoding import force_text
from django.utils.module_loading import import_string
-from django.utils import six
from django.views import debug
logger = logging.getLogger('django.request')
diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py
index 3f69bfaaae..df6afdd297 100644
--- a/django/core/handlers/wsgi.py
+++ b/django/core/handlers/wsgi.py
@@ -12,9 +12,9 @@ from django.conf import settings
from django.core import signals
from django.core.handlers import base
from django.core.urlresolvers import set_script_prefix
+from django.utils import six
from django.utils.encoding import force_str, force_text
from django.utils.functional import cached_property
-from django.utils import six
logger = logging.getLogger('django.request')
diff --git a/django/core/mail/backends/filebased.py b/django/core/mail/backends/filebased.py
index 277d4bc88c..cfe033fb48 100644
--- a/django/core/mail/backends/filebased.py
+++ b/django/core/mail/backends/filebased.py
@@ -5,7 +5,8 @@ import os
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
-from django.core.mail.backends.console import EmailBackend as ConsoleEmailBackend
+from django.core.mail.backends.console import \
+ EmailBackend as ConsoleEmailBackend
from django.utils import six
diff --git a/django/core/mail/backends/smtp.py b/django/core/mail/backends/smtp.py
index 620168eab2..432f3a64c4 100644
--- a/django/core/mail/backends/smtp.py
+++ b/django/core/mail/backends/smtp.py
@@ -5,8 +5,8 @@ import threading
from django.conf import settings
from django.core.mail.backends.base import BaseEmailBackend
-from django.core.mail.utils import DNS_NAME
from django.core.mail.message import sanitize_address
+from django.core.mail.utils import DNS_NAME
class EmailBackend(BaseEmailBackend):
diff --git a/django/core/mail/message.py b/django/core/mail/message.py
index b895cd6f78..76cd477595 100644
--- a/django/core/mail/message.py
+++ b/django/core/mail/message.py
@@ -5,21 +5,21 @@ import os
import random
import sys
import time
-from email import (charset as Charset, encoders as Encoders,
- message_from_string, generator)
+from email import (
+ charset as Charset, encoders as Encoders, generator, message_from_string,
+)
+from email.header import Header
from email.message import Message
-from email.mime.text import MIMEText
-from email.mime.multipart import MIMEMultipart
from email.mime.base import MIMEBase
from email.mime.message import MIMEMessage
-from email.header import Header
-from email.utils import formatdate, getaddresses, formataddr, parseaddr
+from email.mime.multipart import MIMEMultipart
+from email.mime.text import MIMEText
+from email.utils import formataddr, formatdate, getaddresses, parseaddr
from django.conf import settings
from django.core.mail.utils import DNS_NAME
-from django.utils.encoding import force_text
from django.utils import six
-
+from django.utils.encoding import force_text
# Don't BASE64-encode UTF-8 messages so that we avoid unwanted attention from
# some spam filters.
diff --git a/django/core/management/base.py b/django/core/management/base.py
index 51a2aed11f..564f15ebc5 100644
--- a/django/core/management/base.py
+++ b/django/core/management/base.py
@@ -1,16 +1,13 @@
# -*- coding: utf-8 -*-
-
-from __future__ import unicode_literals
-
"""
Base classes for writing management commands (named commands which can
be executed through ``django-admin`` or ``manage.py``).
"""
+from __future__ import unicode_literals
import os
import sys
import warnings
-
from argparse import ArgumentParser
from optparse import OptionParser
diff --git a/django/core/management/color.py b/django/core/management/color.py
index ce47f318ff..96dd557556 100644
--- a/django/core/management/color.py
+++ b/django/core/management/color.py
@@ -5,8 +5,7 @@ Sets up the terminal color scheme.
import os
import sys
-from django.utils import lru_cache
-from django.utils import termcolors
+from django.utils import lru_cache, termcolors
def supports_color():
diff --git a/django/core/management/commands/createcachetable.py b/django/core/management/commands/createcachetable.py
index da39e9ad1e..750e787200 100644
--- a/django/core/management/commands/createcachetable.py
+++ b/django/core/management/commands/createcachetable.py
@@ -2,7 +2,9 @@ from django.conf import settings
from django.core.cache import caches
from django.core.cache.backends.db import BaseDatabaseCache
from django.core.management.base import BaseCommand, CommandError
-from django.db import connections, router, transaction, models, DEFAULT_DB_ALIAS
+from django.db import (
+ DEFAULT_DB_ALIAS, connections, models, router, transaction,
+)
from django.db.utils import DatabaseError
from django.utils.encoding import force_text
diff --git a/django/core/management/commands/dbshell.py b/django/core/management/commands/dbshell.py
index b771585bef..9d6097eb47 100644
--- a/django/core/management/commands/dbshell.py
+++ b/django/core/management/commands/dbshell.py
@@ -1,5 +1,5 @@
from django.core.management.base import BaseCommand, CommandError
-from django.db import connections, DEFAULT_DB_ALIAS
+from django.db import DEFAULT_DB_ALIAS, connections
class Command(BaseCommand):
diff --git a/django/core/management/commands/dumpdata.py b/django/core/management/commands/dumpdata.py
index 94d2427304..a7c8bd7615 100644
--- a/django/core/management/commands/dumpdata.py
+++ b/django/core/management/commands/dumpdata.py
@@ -1,9 +1,9 @@
from collections import OrderedDict
from django.apps import apps
-from django.core.management.base import BaseCommand, CommandError
from django.core import serializers
-from django.db import router, DEFAULT_DB_ALIAS
+from django.core.management.base import BaseCommand, CommandError
+from django.db import DEFAULT_DB_ALIAS, router
class Command(BaseCommand):
diff --git a/django/core/management/commands/flush.py b/django/core/management/commands/flush.py
index 090e26357a..97c94501c4 100644
--- a/django/core/management/commands/flush.py
+++ b/django/core/management/commands/flush.py
@@ -4,12 +4,12 @@ import sys
from importlib import import_module
from django.apps import apps
-from django.db import connections, router, transaction, DEFAULT_DB_ALIAS
from django.core.management.base import BaseCommand, CommandError
from django.core.management.color import no_style
-from django.core.management.sql import sql_flush, emit_post_migrate_signal
-from django.utils.six.moves import input
+from django.core.management.sql import emit_post_migrate_signal, sql_flush
+from django.db import DEFAULT_DB_ALIAS, connections, router, transaction
from django.utils import six
+from django.utils.six.moves import input
class Command(BaseCommand):
diff --git a/django/core/management/commands/inspectdb.py b/django/core/management/commands/inspectdb.py
index e433e62854..40bfffe5d0 100644
--- a/django/core/management/commands/inspectdb.py
+++ b/django/core/management/commands/inspectdb.py
@@ -1,11 +1,11 @@
from __future__ import unicode_literals
-from collections import OrderedDict
import keyword
import re
+from collections import OrderedDict
from django.core.management.base import BaseCommand, CommandError
-from django.db import connections, DEFAULT_DB_ALIAS
+from django.db import DEFAULT_DB_ALIAS, connections
class Command(BaseCommand):
diff --git a/django/core/management/commands/loaddata.py b/django/core/management/commands/loaddata.py
index 15a90d727b..a07f6b7300 100644
--- a/django/core/management/commands/loaddata.py
+++ b/django/core/management/commands/loaddata.py
@@ -5,6 +5,7 @@ import gzip
import os
import warnings
import zipfile
+from itertools import product
from django.apps import apps
from django.conf import settings
@@ -12,13 +13,14 @@ from django.core import serializers
from django.core.exceptions import ImproperlyConfigured
from django.core.management.base import BaseCommand, CommandError
from django.core.management.color import no_style
-from django.db import (connections, router, transaction, DEFAULT_DB_ALIAS,
- IntegrityError, DatabaseError)
+from django.db import (
+ DEFAULT_DB_ALIAS, DatabaseError, IntegrityError, connections, router,
+ transaction,
+)
from django.utils import lru_cache
+from django.utils._os import upath
from django.utils.encoding import force_text
from django.utils.functional import cached_property
-from django.utils._os import upath
-from itertools import product
try:
import bz2
diff --git a/django/core/management/commands/makemessages.py b/django/core/management/commands/makemessages.py
index 4e46c66114..2796524dc9 100644
--- a/django/core/management/commands/makemessages.py
+++ b/django/core/management/commands/makemessages.py
@@ -11,14 +11,15 @@ from itertools import dropwhile
import django
from django.conf import settings
-from django.core.management.base import CommandError, BaseCommand
-from django.core.management.utils import (handle_extensions, find_command,
- popen_wrapper)
+from django.core.management.base import BaseCommand, CommandError
+from django.core.management.utils import (
+ find_command, handle_extensions, popen_wrapper,
+)
+from django.utils import six
from django.utils.encoding import force_str
from django.utils.functional import cached_property, total_ordering
-from django.utils import six
-from django.utils.text import get_text_list
from django.utils.jslex import prepare_js_for_gettext
+from django.utils.text import get_text_list
plural_forms_re = re.compile(r'^(?P<value>"Plural-Forms.+?\\n")\s*$', re.MULTILINE | re.DOTALL)
STATUS_OK = 0
diff --git a/django/core/management/commands/makemigrations.py b/django/core/management/commands/makemigrations.py
index 8cce2fae76..cb78107d33 100644
--- a/django/core/management/commands/makemigrations.py
+++ b/django/core/management/commands/makemigrations.py
@@ -1,13 +1,15 @@
-from itertools import takewhile
-import sys
import os
+import sys
+from itertools import takewhile
from django.apps import apps
from django.core.management.base import BaseCommand, CommandError
from django.db.migrations import Migration
-from django.db.migrations.loader import MigrationLoader
from django.db.migrations.autodetector import MigrationAutodetector
-from django.db.migrations.questioner import MigrationQuestioner, InteractiveMigrationQuestioner
+from django.db.migrations.loader import MigrationLoader
+from django.db.migrations.questioner import (
+ InteractiveMigrationQuestioner, MigrationQuestioner,
+)
from django.db.migrations.state import ProjectState
from django.db.migrations.writer import MigrationWriter
from django.utils.six import iteritems
diff --git a/django/core/management/commands/migrate.py b/django/core/management/commands/migrate.py
index 4034f3fe5a..d1aff756f0 100644
--- a/django/core/management/commands/migrate.py
+++ b/django/core/management/commands/migrate.py
@@ -1,20 +1,22 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from collections import OrderedDict
-from importlib import import_module
import time
import warnings
+from collections import OrderedDict
+from importlib import import_module
from django.apps import apps
from django.core.management import call_command
from django.core.management.base import BaseCommand, CommandError
-from django.core.management.sql import emit_post_migrate_signal, emit_pre_migrate_signal
-from django.db import connections, router, transaction, DEFAULT_DB_ALIAS
+from django.core.management.sql import (
+ emit_post_migrate_signal, emit_pre_migrate_signal,
+)
+from django.db import DEFAULT_DB_ALIAS, connections, router, transaction
+from django.db.migrations.autodetector import MigrationAutodetector
from django.db.migrations.executor import MigrationExecutor
from django.db.migrations.loader import AmbiguityError
from django.db.migrations.state import ProjectState
-from django.db.migrations.autodetector import MigrationAutodetector
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.module_loading import module_has_submodule
diff --git a/django/core/management/commands/runserver.py b/django/core/management/commands/runserver.py
index 7df5f15acf..fb388062e7 100644
--- a/django/core/management/commands/runserver.py
+++ b/django/core/management/commands/runserver.py
@@ -1,20 +1,19 @@
from __future__ import unicode_literals
-from datetime import datetime
import errno
import os
import re
-import sys
import socket
+import sys
+from datetime import datetime
+from django.core.exceptions import ImproperlyConfigured
from django.core.management.base import BaseCommand, CommandError
-from django.core.servers.basehttp import run, get_internal_wsgi_application
-from django.db import connections, DEFAULT_DB_ALIAS
+from django.core.servers.basehttp import get_internal_wsgi_application, run
+from django.db import DEFAULT_DB_ALIAS, connections
from django.db.migrations.executor import MigrationExecutor
-from django.utils import autoreload
+from django.utils import autoreload, six
from django.utils.encoding import force_text, get_system_encoding
-from django.utils import six
-from django.core.exceptions import ImproperlyConfigured
naiveip_re = re.compile(r"""^(?:
(?P<addr>
diff --git a/django/core/management/commands/showmigrations.py b/django/core/management/commands/showmigrations.py
index b6ef6a2ece..246bea588f 100644
--- a/django/core/management/commands/showmigrations.py
+++ b/django/core/management/commands/showmigrations.py
@@ -2,7 +2,7 @@
from __future__ import unicode_literals
from django.core.management.base import BaseCommand, CommandError
-from django.db import connections, DEFAULT_DB_ALIAS
+from django.db import DEFAULT_DB_ALIAS, connections
from django.db.migrations.loader import MigrationLoader
diff --git a/django/core/management/commands/sqlflush.py b/django/core/management/commands/sqlflush.py
index 530bdfd7e1..eba9197be7 100644
--- a/django/core/management/commands/sqlflush.py
+++ b/django/core/management/commands/sqlflush.py
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
from django.core.management.base import BaseCommand
from django.core.management.sql import sql_flush
-from django.db import connections, DEFAULT_DB_ALIAS
+from django.db import DEFAULT_DB_ALIAS, connections
class Command(BaseCommand):
diff --git a/django/core/management/commands/sqlmigrate.py b/django/core/management/commands/sqlmigrate.py
index 2358cd5259..14c2742c07 100644
--- a/django/core/management/commands/sqlmigrate.py
+++ b/django/core/management/commands/sqlmigrate.py
@@ -2,7 +2,7 @@
from __future__ import unicode_literals
from django.core.management.base import BaseCommand, CommandError
-from django.db import connections, DEFAULT_DB_ALIAS
+from django.db import DEFAULT_DB_ALIAS, connections
from django.db.migrations.executor import MigrationExecutor
from django.db.migrations.loader import AmbiguityError
diff --git a/django/core/management/commands/sqlsequencereset.py b/django/core/management/commands/sqlsequencereset.py
index 690ea902a4..ea7286c6ac 100644
--- a/django/core/management/commands/sqlsequencereset.py
+++ b/django/core/management/commands/sqlsequencereset.py
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
from django.core.management.base import AppCommand
-from django.db import connections, DEFAULT_DB_ALIAS
+from django.db import DEFAULT_DB_ALIAS, connections
class Command(AppCommand):
diff --git a/django/core/management/commands/squashmigrations.py b/django/core/management/commands/squashmigrations.py
index 13dcb6da67..0087a96007 100644
--- a/django/core/management/commands/squashmigrations.py
+++ b/django/core/management/commands/squashmigrations.py
@@ -1,11 +1,11 @@
-from django.core.management.base import BaseCommand, CommandError
from django.conf import settings
-from django.db import connections, DEFAULT_DB_ALIAS, migrations
-from django.db.migrations.loader import AmbiguityError
+from django.core.management.base import BaseCommand, CommandError
+from django.db import DEFAULT_DB_ALIAS, connections, migrations
from django.db.migrations.executor import MigrationExecutor
-from django.db.migrations.writer import MigrationWriter
-from django.db.migrations.optimizer import MigrationOptimizer
+from django.db.migrations.loader import AmbiguityError
from django.db.migrations.migration import SwappableTuple
+from django.db.migrations.optimizer import MigrationOptimizer
+from django.db.migrations.writer import MigrationWriter
from django.utils import six
from django.utils.version import get_docs_version
diff --git a/django/core/management/commands/test.py b/django/core/management/commands/test.py
index 8dbff62653..127ed5c846 100644
--- a/django/core/management/commands/test.py
+++ b/django/core/management/commands/test.py
@@ -1,6 +1,6 @@
import logging
-import sys
import os
+import sys
from django.conf import settings
from django.core.management.base import BaseCommand
diff --git a/django/core/management/templates.py b/django/core/management/templates.py
index b0bd7a7117..6648fafde9 100644
--- a/django/core/management/templates.py
+++ b/django/core/management/templates.py
@@ -8,18 +8,16 @@ import shutil
import stat
import sys
import tempfile
-
from os import path
import django
-from django.template import Template, Context
+from django.core.management.base import BaseCommand, CommandError
+from django.core.management.utils import handle_extensions
+from django.template import Context, Template
from django.utils import archive
-from django.utils.six.moves.urllib.request import urlretrieve
from django.utils._os import rmtree_errorhandler
+from django.utils.six.moves.urllib.request import urlretrieve
from django.utils.version import get_docs_version
-from django.core.management.base import BaseCommand, CommandError
-from django.core.management.utils import handle_extensions
-
_drive_re = re.compile('^([a-z]):', re.I)
_url_drive_re = re.compile('^([a-z])[:|]', re.I)
diff --git a/django/core/management/utils.py b/django/core/management/utils.py
index 7a823424a6..06ed04e377 100644
--- a/django/core/management/utils.py
+++ b/django/core/management/utils.py
@@ -1,11 +1,11 @@
from __future__ import unicode_literals
import os
-from subprocess import PIPE, Popen
import sys
+from subprocess import PIPE, Popen
-from django.utils.encoding import force_text, DEFAULT_LOCALE_ENCODING
from django.utils import six
+from django.utils.encoding import DEFAULT_LOCALE_ENCODING, force_text
from .base import CommandError
diff --git a/django/core/serializers/json.py b/django/core/serializers/json.py
index 614427f9a7..f67295edf9 100644
--- a/django/core/serializers/json.py
+++ b/django/core/serializers/json.py
@@ -3,8 +3,7 @@ Serialize data to/from JSON
"""
# Avoid shadowing the standard library json module
-from __future__ import absolute_import
-from __future__ import unicode_literals
+from __future__ import absolute_import, unicode_literals
import datetime
import decimal
@@ -12,8 +11,9 @@ import json
import sys
from django.core.serializers.base import DeserializationError
-from django.core.serializers.python import Serializer as PythonSerializer
-from django.core.serializers.python import Deserializer as PythonDeserializer
+from django.core.serializers.python import (
+ Deserializer as PythonDeserializer, Serializer as PythonSerializer,
+)
from django.utils import six
from django.utils.timezone import is_aware
diff --git a/django/core/serializers/python.py b/django/core/serializers/python.py
index f8dd7aebac..137dfc134e 100644
--- a/django/core/serializers/python.py
+++ b/django/core/serializers/python.py
@@ -9,8 +9,8 @@ from django.apps import apps
from django.conf import settings
from django.core.serializers import base
from django.db import DEFAULT_DB_ALIAS, models
-from django.utils.encoding import force_text, is_protected_type
from django.utils import six
+from django.utils.encoding import force_text, is_protected_type
class Serializer(base.Serializer):
diff --git a/django/core/serializers/pyyaml.py b/django/core/serializers/pyyaml.py
index 2d8bb187c1..105072b54e 100644
--- a/django/core/serializers/pyyaml.py
+++ b/django/core/serializers/pyyaml.py
@@ -5,14 +5,16 @@ Requires PyYaml (http://pyyaml.org/), but that's checked for in __init__.
"""
import decimal
-import yaml
import sys
from io import StringIO
-from django.db import models
+import yaml
+
from django.core.serializers.base import DeserializationError
-from django.core.serializers.python import Serializer as PythonSerializer
-from django.core.serializers.python import Deserializer as PythonDeserializer
+from django.core.serializers.python import (
+ Deserializer as PythonDeserializer, Serializer as PythonSerializer,
+)
+from django.db import models
from django.utils import six
# Use the C (faster) implementation if possible
diff --git a/django/core/serializers/xml_serializer.py b/django/core/serializers/xml_serializer.py
index 0b759799d2..73bed113b9 100644
--- a/django/core/serializers/xml_serializer.py
+++ b/django/core/serializers/xml_serializer.py
@@ -4,15 +4,16 @@ XML serializer.
from __future__ import unicode_literals
+from xml.dom import pulldom
+from xml.sax import handler
+from xml.sax.expatreader import ExpatParser as _ExpatParser
+
from django.apps import apps
from django.conf import settings
from django.core.serializers import base
-from django.db import models, DEFAULT_DB_ALIAS
-from django.utils.xmlutils import SimplerXMLGenerator
+from django.db import DEFAULT_DB_ALIAS, models
from django.utils.encoding import smart_text
-from xml.dom import pulldom
-from xml.sax import handler
-from xml.sax.expatreader import ExpatParser as _ExpatParser
+from django.utils.xmlutils import SimplerXMLGenerator
class Serializer(base.Serializer):
diff --git a/django/core/urlresolvers.py b/django/core/urlresolvers.py
index 702290b61d..42a9fbc2fe 100644
--- a/django/core/urlresolvers.py
+++ b/django/core/urlresolvers.py
@@ -9,13 +9,14 @@ a string) and returns a tuple in this format:
from __future__ import unicode_literals
import functools
-from importlib import import_module
import re
-from threading import local
import warnings
+from importlib import import_module
+from threading import local
-from django.http import Http404
from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist
+from django.http import Http404
+from django.utils import lru_cache, six
from django.utils.datastructures import MultiValueDict
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_str, force_text, iri_to_uri
@@ -23,10 +24,8 @@ from django.utils.functional import cached_property, lazy
from django.utils.http import RFC3986_SUBDELIMS, urlquote
from django.utils.module_loading import module_has_submodule
from django.utils.regex_helper import normalize
-from django.utils import six, lru_cache
from django.utils.translation import get_language
-
# SCRIPT_NAME prefixes for each thread are stored here. If there's no entry for
# the current thread (which is the only one we ever access), it is assumed to
# be empty.
diff --git a/django/core/validators.py b/django/core/validators.py
index 8d87cef412..bb8224f728 100644
--- a/django/core/validators.py
+++ b/django/core/validators.py
@@ -3,13 +3,12 @@ from __future__ import unicode_literals
import re
from django.core.exceptions import ValidationError
+from django.utils import six
from django.utils.deconstruct import deconstructible
-from django.utils.translation import ugettext_lazy as _, ungettext_lazy
from django.utils.encoding import force_text
from django.utils.ipv6 import is_valid_ipv6_address
-from django.utils import six
from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit
-
+from django.utils.translation import ugettext_lazy as _, ungettext_lazy
# These values, if given to validate(), will trigger the self.required check.
EMPTY_VALUES = (None, '', [], (), {})
diff --git a/django/db/backends/base/base.py b/django/db/backends/base/base.py
index cbc4983046..460fceab71 100644
--- a/django/db/backends/base/base.py
+++ b/django/db/backends/base/base.py
@@ -1,18 +1,17 @@
-from collections import deque
-from contextlib import contextmanager
import time
import warnings
+from collections import deque
+from contextlib import contextmanager
from django.conf import settings
from django.db import DEFAULT_DB_ALIAS
-from django.db.backends.signals import connection_created
from django.db.backends import utils
+from django.db.backends.signals import connection_created
from django.db.transaction import TransactionManagementError
from django.db.utils import DatabaseError, DatabaseErrorWrapper
from django.utils.functional import cached_property
from django.utils.six.moves import _thread as thread
-
NO_DB_ALIAS = '__no_db__'
diff --git a/django/db/backends/base/creation.py b/django/db/backends/base/creation.py
index 30e094cfe7..854e17b6c2 100644
--- a/django/db/backends/base/creation.py
+++ b/django/db/backends/base/creation.py
@@ -8,7 +8,6 @@ from django.db import router
from django.utils.six import StringIO
from django.utils.six.moves import input
-
# The prefix to put on the default database name when creating
# the test database.
TEST_DATABASE_PREFIX = 'test_'
diff --git a/django/db/backends/base/introspection.py b/django/db/backends/base/introspection.py
index d20bfa1df0..5f828b94cc 100644
--- a/django/db/backends/base/introspection.py
+++ b/django/db/backends/base/introspection.py
@@ -2,7 +2,6 @@ from collections import namedtuple
from django.utils import six
-
# Structure returned by DatabaseIntrospection.get_table_list()
TableInfo = namedtuple('TableInfo', ['name', 'type'])
diff --git a/django/db/backends/base/operations.py b/django/db/backends/base/operations.py
index 50f6c93a07..aebe4312c8 100644
--- a/django/db/backends/base/operations.py
+++ b/django/db/backends/base/operations.py
@@ -1,7 +1,7 @@
import datetime
import decimal
-from importlib import import_module
import warnings
+from importlib import import_module
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
diff --git a/django/db/backends/dummy/base.py b/django/db/backends/dummy/base.py
index e39d7e621e..ba8ad10210 100644
--- a/django/db/backends/dummy/base.py
+++ b/django/db/backends/dummy/base.py
@@ -12,8 +12,8 @@ from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.backends.base.client import BaseDatabaseClient
from django.db.backends.base.creation import BaseDatabaseCreation
from django.db.backends.base.features import BaseDatabaseFeatures
-from django.db.backends.base.operations import BaseDatabaseOperations
from django.db.backends.base.introspection import BaseDatabaseIntrospection
+from django.db.backends.base.operations import BaseDatabaseOperations
from django.db.backends.base.validation import BaseDatabaseValidation
diff --git a/django/db/backends/mysql/base.py b/django/db/backends/mysql/base.py
index f3413f43f3..515988babd 100644
--- a/django/db/backends/mysql/base.py
+++ b/django/db/backends/mysql/base.py
@@ -15,9 +15,9 @@ from django.conf import settings
from django.db import utils
from django.db.backends import utils as backend_utils
from django.db.backends.base.base import BaseDatabaseWrapper
-from django.utils.encoding import force_str
from django.db.backends.mysql.schema import DatabaseSchemaEditor
from django.utils import six, timezone
+from django.utils.encoding import force_str
from django.utils.functional import cached_property
from django.utils.safestring import SafeBytes, SafeText
@@ -27,16 +27,16 @@ except ImportError as e:
from django.core.exceptions import ImproperlyConfigured
raise ImproperlyConfigured("Error loading MySQLdb module: %s" % e)
-from MySQLdb.converters import conversions, Thing2Literal
-from MySQLdb.constants import FIELD_TYPE, CLIENT
+from MySQLdb.constants import CLIENT, FIELD_TYPE # isort:skip
+from MySQLdb.converters import Thing2Literal, conversions # isort:skip
# Some of these import MySQLdb, so import them after checking if it's installed.
-from .client import DatabaseClient
-from .creation import DatabaseCreation
-from .features import DatabaseFeatures
-from .introspection import DatabaseIntrospection
-from .operations import DatabaseOperations
-from .validation import DatabaseValidation
+from .client import DatabaseClient # isort:skip
+from .creation import DatabaseCreation # isort:skip
+from .features import DatabaseFeatures # isort:skip
+from .introspection import DatabaseIntrospection # isort:skip
+from .operations import DatabaseOperations # isort:skip
+from .validation import DatabaseValidation # isort:skip
# We want version (1, 2, 1, 'final', 2) or later. We can't just use
# lexicographic ordering in this check because then (1, 2, 1, 'gamma')
diff --git a/django/db/backends/mysql/introspection.py b/django/db/backends/mysql/introspection.py
index aa3c008d13..f40e8962f8 100644
--- a/django/db/backends/mysql/introspection.py
+++ b/django/db/backends/mysql/introspection.py
@@ -1,14 +1,14 @@
-from collections import namedtuple
import re
+from collections import namedtuple
+
+from MySQLdb.constants import FIELD_TYPE
-from django.utils.datastructures import OrderedSet
from django.db.backends.base.introspection import (
BaseDatabaseIntrospection, FieldInfo, TableInfo,
)
+from django.utils.datastructures import OrderedSet
from django.utils.encoding import force_text
-from MySQLdb.constants import FIELD_TYPE
-
FieldInfo = namedtuple('FieldInfo', FieldInfo._fields + ('extra', 'default'))
InfoLine = namedtuple('InfoLine', 'col_name data_type max_len num_prec num_scale extra column_default')
foreign_key_re = re.compile(r"\sCONSTRAINT `[^`]*` FOREIGN KEY \(`([^`]*)`\) REFERENCES `([^`]*)` \(`([^`]*)`\)")
diff --git a/django/db/backends/oracle/base.py b/django/db/backends/oracle/base.py
index 134321cecc..d79b582e82 100644
--- a/django/db/backends/oracle/base.py
+++ b/django/db/backends/oracle/base.py
@@ -55,13 +55,13 @@ except ImportError as e:
raise ImproperlyConfigured("Error loading cx_Oracle module: %s" % e)
# Some of these import cx_Oracle, so import them after checking if it's installed.
-from .client import DatabaseClient
-from .creation import DatabaseCreation
-from .features import DatabaseFeatures
-from .introspection import DatabaseIntrospection
-from .operations import DatabaseOperations
-from .schema import DatabaseSchemaEditor
-from .utils import convert_unicode, Oracle_datetime
+from .client import DatabaseClient # isort:skip
+from .creation import DatabaseCreation # isort:skip
+from .features import DatabaseFeatures # isort:skip
+from .introspection import DatabaseIntrospection # isort:skip
+from .operations import DatabaseOperations # isort:skip
+from .schema import DatabaseSchemaEditor # isort:skip
+from .utils import Oracle_datetime, convert_unicode # isort:skip
DatabaseError = Database.DatabaseError
IntegrityError = Database.IntegrityError
diff --git a/django/db/backends/oracle/creation.py b/django/db/backends/oracle/creation.py
index de9de2c5b1..1e999f8358 100644
--- a/django/db/backends/oracle/creation.py
+++ b/django/db/backends/oracle/creation.py
@@ -6,7 +6,6 @@ from django.db.backends.base.creation import BaseDatabaseCreation
from django.db.utils import DatabaseError
from django.utils.six.moves import input
-
TEST_DATABASE_PREFIX = 'test_'
PASSWORD = 'Im_a_lumberjack'
diff --git a/django/db/backends/oracle/operations.py b/django/db/backends/oracle/operations.py
index fe9c93ba90..1ba49909d8 100644
--- a/django/db/backends/oracle/operations.py
+++ b/django/db/backends/oracle/operations.py
@@ -11,7 +11,7 @@ from django.utils import six, timezone
from django.utils.encoding import force_bytes, force_text
from .base import Database
-from .utils import convert_unicode, InsertIdVar, Oracle_datetime
+from .utils import InsertIdVar, Oracle_datetime, convert_unicode
class DatabaseOperations(BaseDatabaseOperations):
diff --git a/django/db/backends/oracle/schema.py b/django/db/backends/oracle/schema.py
index 6b1dcf5343..fa710dc443 100644
--- a/django/db/backends/oracle/schema.py
+++ b/django/db/backends/oracle/schema.py
@@ -1,11 +1,11 @@
+import binascii
import copy
import datetime
-import binascii
-from django.utils import six
-from django.utils.text import force_text
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.db.utils import DatabaseError
+from django.utils import six
+from django.utils.text import force_text
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
diff --git a/django/db/backends/postgresql_psycopg2/base.py b/django/db/backends/postgresql_psycopg2/base.py
index a73d1f27bf..4410a173a0 100644
--- a/django/db/backends/postgresql_psycopg2/base.py
+++ b/django/db/backends/postgresql_psycopg2/base.py
@@ -9,7 +9,7 @@ from django.db.backends.base.base import BaseDatabaseWrapper
from django.db.backends.base.validation import BaseDatabaseValidation
from django.utils.encoding import force_str
from django.utils.functional import cached_property
-from django.utils.safestring import SafeText, SafeBytes
+from django.utils.safestring import SafeBytes, SafeText
try:
import psycopg2 as Database
@@ -20,14 +20,14 @@ except ImportError as e:
raise ImproperlyConfigured("Error loading psycopg2 module: %s" % e)
# Some of these import psycopg2, so import them after checking if it's installed.
-from .client import DatabaseClient
-from .creation import DatabaseCreation
-from .features import DatabaseFeatures
-from .introspection import DatabaseIntrospection
-from .operations import DatabaseOperations
-from .schema import DatabaseSchemaEditor
-from .utils import utc_tzinfo_factory
-from .version import get_version
+from .client import DatabaseClient # isort:skip
+from .creation import DatabaseCreation # isort:skip
+from .features import DatabaseFeatures # isort:skip
+from .introspection import DatabaseIntrospection # isort:skip
+from .operations import DatabaseOperations # isort:skip
+from .schema import DatabaseSchemaEditor # isort:skip
+from .utils import utc_tzinfo_factory # isort:skip
+from .version import get_version # isort:skip
DatabaseError = Database.DatabaseError
IntegrityError = Database.IntegrityError
diff --git a/django/db/backends/postgresql_psycopg2/introspection.py b/django/db/backends/postgresql_psycopg2/introspection.py
index 7236f5121f..32c69bc510 100644
--- a/django/db/backends/postgresql_psycopg2/introspection.py
+++ b/django/db/backends/postgresql_psycopg2/introspection.py
@@ -1,4 +1,5 @@
from __future__ import unicode_literals
+
from collections import namedtuple
from django.db.backends.base.introspection import (
@@ -6,7 +7,6 @@ from django.db.backends.base.introspection import (
)
from django.utils.encoding import force_text
-
FieldInfo = namedtuple('FieldInfo', FieldInfo._fields + ('default',))
diff --git a/django/db/backends/postgresql_psycopg2/operations.py b/django/db/backends/postgresql_psycopg2/operations.py
index ab9f60e927..7483d97aee 100644
--- a/django/db/backends/postgresql_psycopg2/operations.py
+++ b/django/db/backends/postgresql_psycopg2/operations.py
@@ -1,10 +1,10 @@
from __future__ import unicode_literals
+from psycopg2.extras import Inet
+
from django.conf import settings
from django.db.backends.base.operations import BaseDatabaseOperations
-from psycopg2.extras import Inet
-
class DatabaseOperations(BaseDatabaseOperations):
def unification_cast_sql(self, output_field):
diff --git a/django/db/backends/postgresql_psycopg2/schema.py b/django/db/backends/postgresql_psycopg2/schema.py
index c75123a349..8340059b26 100644
--- a/django/db/backends/postgresql_psycopg2/schema.py
+++ b/django/db/backends/postgresql_psycopg2/schema.py
@@ -1,7 +1,7 @@
-from django.db.backends.base.schema import BaseDatabaseSchemaEditor
-
import psycopg2
+from django.db.backends.base.schema import BaseDatabaseSchemaEditor
+
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
diff --git a/django/db/backends/sqlite3/base.py b/django/db/backends/sqlite3/base.py
index a71bae99b2..84d24e5bfe 100644
--- a/django/db/backends/sqlite3/base.py
+++ b/django/db/backends/sqlite3/base.py
@@ -36,13 +36,13 @@ except ImportError as exc:
raise ImproperlyConfigured("Error loading either pysqlite2 or sqlite3 modules (tried in that order): %s" % exc)
# Some of these import sqlite3, so import them after checking if it's installed.
-from .client import DatabaseClient
-from .creation import DatabaseCreation
-from .features import DatabaseFeatures
-from .introspection import DatabaseIntrospection
-from .operations import DatabaseOperations
-from .schema import DatabaseSchemaEditor
-from .utils import parse_datetime_with_timezone_support
+from .client import DatabaseClient # isort:skip
+from .creation import DatabaseCreation # isort:skip
+from .features import DatabaseFeatures # isort:skip
+from .introspection import DatabaseIntrospection # isort:skip
+from .operations import DatabaseOperations # isort:skip
+from .schema import DatabaseSchemaEditor # isort:skip
+from .utils import parse_datetime_with_timezone_support # isort:skip
DatabaseError = Database.DatabaseError
IntegrityError = Database.IntegrityError
diff --git a/django/db/backends/sqlite3/introspection.py b/django/db/backends/sqlite3/introspection.py
index a002b79933..5f3fb4a45d 100644
--- a/django/db/backends/sqlite3/introspection.py
+++ b/django/db/backends/sqlite3/introspection.py
@@ -5,7 +5,6 @@ from django.db.backends.base.introspection import (
BaseDatabaseIntrospection, FieldInfo, TableInfo,
)
-
field_size_re = re.compile(r'^\s*(?:var)?char\s*\(\s*(\d+)\s*\)\s*$')
FieldInfo = namedtuple('FieldInfo', FieldInfo._fields + ('default',))
diff --git a/django/db/backends/sqlite3/operations.py b/django/db/backends/sqlite3/operations.py
index cd29092cd7..5d974f36df 100644
--- a/django/db/backends/sqlite3/operations.py
+++ b/django/db/backends/sqlite3/operations.py
@@ -4,14 +4,14 @@ import datetime
import uuid
from django.conf import settings
-from django.core.exceptions import ImproperlyConfigured, FieldError
+from django.core.exceptions import FieldError, ImproperlyConfigured
from django.db import utils
from django.db.backends import utils as backend_utils
from django.db.backends.base.operations import BaseDatabaseOperations
-from django.db.models import fields, aggregates
+from django.db.models import aggregates, fields
+from django.utils import six, timezone
from django.utils.dateparse import parse_date, parse_time
from django.utils.duration import duration_string
-from django.utils import six, timezone
from .utils import parse_datetime_with_timezone_support
diff --git a/django/db/backends/sqlite3/schema.py b/django/db/backends/sqlite3/schema.py
index 031bf77840..0d101b0f27 100644
--- a/django/db/backends/sqlite3/schema.py
+++ b/django/db/backends/sqlite3/schema.py
@@ -2,12 +2,12 @@ import codecs
import copy
from decimal import Decimal
+import _sqlite3
+
from django.apps.registry import Apps
from django.db.backends.base.schema import BaseDatabaseSchemaEditor
from django.utils import six
-import _sqlite3
-
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
diff --git a/django/db/backends/utils.py b/django/db/backends/utils.py
index 7aa0cfdad5..84444548d3 100644
--- a/django/db/backends/utils.py
+++ b/django/db/backends/utils.py
@@ -10,7 +10,6 @@ from django.conf import settings
from django.utils.encoding import force_bytes
from django.utils.timezone import utc
-
logger = logging.getLogger('django.db.backends')
diff --git a/django/db/migrations/autodetector.py b/django/db/migrations/autodetector.py
index e86e9c5f68..16df9bfd91 100644
--- a/django/db/migrations/autodetector.py
+++ b/django/db/migrations/autodetector.py
@@ -1,18 +1,17 @@
from __future__ import unicode_literals
-import re
import datetime
-
+import re
from itertools import chain
-from django.utils import six
from django.conf import settings
from django.db import models
from django.db.migrations import operations
from django.db.migrations.migration import Migration
-from django.db.migrations.questioner import MigrationQuestioner
-from django.db.migrations.optimizer import MigrationOptimizer
from django.db.migrations.operations.models import AlterModelOptions
+from django.db.migrations.optimizer import MigrationOptimizer
+from django.db.migrations.questioner import MigrationQuestioner
+from django.utils import six
from .topological_sort import stable_topological_sort
diff --git a/django/db/migrations/executor.py b/django/db/migrations/executor.py
index cc38758f5a..8a55ed0d69 100644
--- a/django/db/migrations/executor.py
+++ b/django/db/migrations/executor.py
@@ -1,7 +1,8 @@
from __future__ import unicode_literals
-from django.db import migrations
from django.apps.registry import apps as global_apps
+from django.db import migrations
+
from .loader import MigrationLoader
from .recorder import MigrationRecorder
from .state import ProjectState
diff --git a/django/db/migrations/graph.py b/django/db/migrations/graph.py
index 0e3c5905d6..bf4d6b5252 100644
--- a/django/db/migrations/graph.py
+++ b/django/db/migrations/graph.py
@@ -1,4 +1,5 @@
from __future__ import unicode_literals
+
from collections import deque
from django.db.migrations.state import ProjectState
diff --git a/django/db/migrations/loader.py b/django/db/migrations/loader.py
index d7ee805bb1..26a89d492f 100644
--- a/django/db/migrations/loader.py
+++ b/django/db/migrations/loader.py
@@ -1,16 +1,15 @@
from __future__ import unicode_literals
-from importlib import import_module
import os
import sys
+from importlib import import_module
from django.apps import apps
+from django.conf import settings
from django.db import connection
-from django.db.migrations.recorder import MigrationRecorder
from django.db.migrations.graph import MigrationGraph, NodeNotFoundError
+from django.db.migrations.recorder import MigrationRecorder
from django.utils import six
-from django.conf import settings
-
MIGRATIONS_MODULE_NAME = 'migrations'
diff --git a/django/db/migrations/migration.py b/django/db/migrations/migration.py
index 71e662db67..1c3f560d6e 100644
--- a/django/db/migrations/migration.py
+++ b/django/db/migrations/migration.py
@@ -1,4 +1,5 @@
from __future__ import unicode_literals
+
from django.db.transaction import atomic
from django.utils.encoding import python_2_unicode_compatible
diff --git a/django/db/migrations/operations/base.py b/django/db/migrations/operations/base.py
index 04089938c2..557c956732 100644
--- a/django/db/migrations/operations/base.py
+++ b/django/db/migrations/operations/base.py
@@ -1,4 +1,5 @@
from __future__ import unicode_literals
+
from django.db import router
diff --git a/django/db/migrations/operations/fields.py b/django/db/migrations/operations/fields.py
index ea9dffff1f..70e7a0f296 100644
--- a/django/db/migrations/operations/fields.py
+++ b/django/db/migrations/operations/fields.py
@@ -3,6 +3,7 @@ from __future__ import unicode_literals
from django.db.models.fields import NOT_PROVIDED
from django.utils import six
from django.utils.functional import cached_property
+
from .base import Operation
diff --git a/django/db/migrations/operations/models.py b/django/db/migrations/operations/models.py
index cdc3c06e50..99df8a073e 100644
--- a/django/db/migrations/operations/models.py
+++ b/django/db/migrations/operations/models.py
@@ -1,9 +1,9 @@
from __future__ import unicode_literals
from django.db import models
-from django.db.models.options import normalize_together
-from django.db.migrations.state import ModelState
from django.db.migrations.operations.base import Operation
+from django.db.migrations.state import ModelState
+from django.db.models.options import normalize_together
from django.utils import six
from django.utils.functional import cached_property
diff --git a/django/db/migrations/state.py b/django/db/migrations/state.py
index 7eb1e5b8b9..2e2fbaa0f8 100644
--- a/django/db/migrations/state.py
+++ b/django/db/migrations/state.py
@@ -1,14 +1,15 @@
from __future__ import unicode_literals
-from collections import OrderedDict
+
import copy
+from collections import OrderedDict
from django.apps import AppConfig
from django.apps.registry import Apps, apps as global_apps
+from django.conf import settings
from django.db import models
-from django.db.models.options import DEFAULT_NAMES, normalize_together
-from django.db.models.fields.related import do_pending_lookups
from django.db.models.fields.proxy import OrderWrt
-from django.conf import settings
+from django.db.models.fields.related import do_pending_lookups
+from django.db.models.options import DEFAULT_NAMES, normalize_together
from django.utils import six
from django.utils.encoding import force_text, smart_text
from django.utils.functional import cached_property
diff --git a/django/db/migrations/writer.py b/django/db/migrations/writer.py
index 5a38861fc4..37f2c81838 100644
--- a/django/db/migrations/writer.py
+++ b/django/db/migrations/writer.py
@@ -3,16 +3,16 @@ from __future__ import unicode_literals
import collections
import datetime
import decimal
-from importlib import import_module
import inspect
import math
import os
import re
import sys
import types
+from importlib import import_module
from django.apps import apps
-from django.db import models, migrations
+from django.db import migrations, models
from django.db.migrations.loader import MigrationLoader
from django.utils import datetime_safe, six
from django.utils.encoding import force_text
@@ -20,7 +20,6 @@ from django.utils.functional import Promise
from django.utils.timezone import utc
from django.utils.version import get_docs_version
-
COMPILED_REGEX_TYPE = type(re.compile(''))
diff --git a/django/db/models/aggregates.py b/django/db/models/aggregates.py
index c1ddc75d4c..01ab61f71a 100644
--- a/django/db/models/aggregates.py
+++ b/django/db/models/aggregates.py
@@ -3,7 +3,7 @@ Classes to represent the definitions of aggregate functions.
"""
from django.core.exceptions import FieldError
from django.db.models.expressions import Func, Value
-from django.db.models.fields import IntegerField, FloatField
+from django.db.models.fields import FloatField, IntegerField
__all__ = [
'Aggregate', 'Avg', 'Count', 'Max', 'Min', 'StdDev', 'Sum', 'Variance',
diff --git a/django/db/models/base.py b/django/db/models/base.py
index 4f00a6f0ce..4faccd89f4 100644
--- a/django/db/models/base.py
+++ b/django/db/models/base.py
@@ -2,33 +2,40 @@ from __future__ import unicode_literals
import copy
import inspect
-from itertools import chain
import sys
import warnings
+from itertools import chain
from django.apps import apps
from django.apps.config import MODELS_MODULE_NAME
from django.conf import settings
from django.core import checks
-from django.core.exceptions import (FieldDoesNotExist, ObjectDoesNotExist,
- MultipleObjectsReturned, FieldError, ValidationError, NON_FIELD_ERRORS)
-from django.db import (router, connections, transaction, DatabaseError,
- DEFAULT_DB_ALIAS, DJANGO_VERSION_PICKLE_KEY)
+from django.core.exceptions import (
+ NON_FIELD_ERRORS, FieldDoesNotExist, FieldError, MultipleObjectsReturned,
+ ObjectDoesNotExist, ValidationError,
+)
+from django.db import (
+ DEFAULT_DB_ALIAS, DJANGO_VERSION_PICKLE_KEY, DatabaseError, connections,
+ router, transaction,
+)
from django.db.models import signals
from django.db.models.constants import LOOKUP_SEP
from django.db.models.deletion import Collector
from django.db.models.fields import AutoField
-from django.db.models.fields.related import (ForeignObjectRel, ManyToOneRel,
- OneToOneField, add_lazy_relation)
+from django.db.models.fields.related import (
+ ForeignObjectRel, ManyToOneRel, OneToOneField, add_lazy_relation,
+)
from django.db.models.manager import ensure_default_manager
from django.db.models.options import Options
from django.db.models.query import Q
-from django.db.models.query_utils import DeferredAttribute, deferred_class_factory
+from django.db.models.query_utils import (
+ DeferredAttribute, deferred_class_factory,
+)
from django.utils import six
from django.utils.encoding import force_str, force_text
from django.utils.functional import curry
from django.utils.six.moves import zip
-from django.utils.text import get_text_list, capfirst
+from django.utils.text import capfirst, get_text_list
from django.utils.translation import ugettext_lazy as _
from django.utils.version import get_version
diff --git a/django/db/models/deletion.py b/django/db/models/deletion.py
index 016fc5637e..431b15b0ef 100644
--- a/django/db/models/deletion.py
+++ b/django/db/models/deletion.py
@@ -2,7 +2,7 @@ from collections import OrderedDict
from itertools import chain
from operator import attrgetter
-from django.db import connections, transaction, IntegrityError
+from django.db import IntegrityError, connections, transaction
from django.db.models import signals, sql
from django.utils import six
diff --git a/django/db/models/expressions.py b/django/db/models/expressions.py
index 87a08ecc3b..c15b095bc2 100644
--- a/django/db/models/expressions.py
+++ b/django/db/models/expressions.py
@@ -6,7 +6,7 @@ from django.core.exceptions import FieldError
from django.db.backends import utils as backend_utils
from django.db.models import fields
from django.db.models.constants import LOOKUP_SEP
-from django.db.models.query_utils import refs_aggregate, Q
+from django.db.models.query_utils import Q, refs_aggregate
from django.utils import timezone
from django.utils.functional import cached_property
diff --git a/django/db/models/fields/files.py b/django/db/models/fields/files.py
index 301244bbef..5eb6e7845f 100644
--- a/django/db/models/fields/files.py
+++ b/django/db/models/fields/files.py
@@ -1,19 +1,19 @@
import datetime
-from inspect import getargspec
import os
import warnings
+from inspect import getargspec
from django import forms
-from django.db.models.fields import Field
from django.core import checks
from django.core.files.base import File
-from django.core.files.storage import default_storage
from django.core.files.images import ImageFile
+from django.core.files.storage import default_storage
from django.db.models import signals
-from django.utils.encoding import force_str, force_text
+from django.db.models.fields import Field
from django.utils import six
-from django.utils.translation import ugettext_lazy as _
from django.utils.deprecation import RemovedInDjango20Warning
+from django.utils.encoding import force_str, force_text
+from django.utils.translation import ugettext_lazy as _
class FieldFile(File):
diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py
index 40e1028f1c..c045391aaa 100644
--- a/django/db/models/fields/related.py
+++ b/django/db/models/fields/related.py
@@ -1,27 +1,28 @@
from __future__ import unicode_literals
-from operator import attrgetter
import warnings
+from operator import attrgetter
+from django import forms
from django.apps import apps
-from django.core import checks
+from django.core import checks, exceptions
from django.core.exceptions import FieldDoesNotExist
from django.db import connection, connections, router, transaction
from django.db.backends import utils
-from django.db.models import signals, Q
-from django.db.models.deletion import SET_NULL, SET_DEFAULT, CASCADE
-from django.db.models.fields import (AutoField, Field, IntegerField,
- PositiveIntegerField, PositiveSmallIntegerField, BLANK_CHOICE_DASH)
+from django.db.models import Q, signals
+from django.db.models.deletion import CASCADE, SET_DEFAULT, SET_NULL
+from django.db.models.fields import (
+ BLANK_CHOICE_DASH, AutoField, Field, IntegerField, PositiveIntegerField,
+ PositiveSmallIntegerField,
+)
from django.db.models.lookups import IsNull
from django.db.models.query import QuerySet
from django.db.models.query_utils import PathInfo
-from django.utils.encoding import force_text, smart_text
from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
+from django.utils.encoding import force_text, smart_text
+from django.utils.functional import cached_property, curry
from django.utils.translation import ugettext_lazy as _
-from django.utils.functional import curry, cached_property
-from django.core import exceptions
-from django import forms
RECURSIVE_RELATIONSHIP_CONSTANT = 'self'
diff --git a/django/db/models/lookups.py b/django/db/models/lookups.py
index f3bb0fcd33..de64129e19 100644
--- a/django/db/models/lookups.py
+++ b/django/db/models/lookups.py
@@ -1,5 +1,5 @@
-from copy import copy
import inspect
+from copy import copy
from django.conf import settings
from django.utils import timezone
diff --git a/django/db/models/manager.py b/django/db/models/manager.py
index aa2df3f0e8..e194e28feb 100644
--- a/django/db/models/manager.py
+++ b/django/db/models/manager.py
@@ -1,6 +1,6 @@
import copy
-from importlib import import_module
import inspect
+from importlib import import_module
from django.db import router
from django.db.models.query import QuerySet
diff --git a/django/db/models/options.py b/django/db/models/options.py
index fa9726556b..83f1eb036a 100644
--- a/django/db/models/options.py
+++ b/django/db/models/options.py
@@ -1,20 +1,22 @@
from __future__ import unicode_literals
+import warnings
from bisect import bisect
from collections import OrderedDict, defaultdict
from itertools import chain
-import warnings
from django.apps import apps
from django.conf import settings
from django.core.exceptions import FieldDoesNotExist
-from django.db.models.fields.related import ManyToManyField
from django.db.models.fields import AutoField
from django.db.models.fields.proxy import OrderWrt
+from django.db.models.fields.related import ManyToManyField
from django.utils import six
from django.utils.datastructures import ImmutableList, OrderedSet
from django.utils.deprecation import RemovedInDjango20Warning
-from django.utils.encoding import force_text, smart_text, python_2_unicode_compatible
+from django.utils.encoding import (
+ force_text, python_2_unicode_compatible, smart_text,
+)
from django.utils.functional import cached_property
from django.utils.lru_cache import lru_cache
from django.utils.text import camel_case_to_spaces
diff --git a/django/db/models/query.py b/django/db/models/query.py
index 57684bb23a..f7a49059bf 100644
--- a/django/db/models/query.py
+++ b/django/db/models/query.py
@@ -2,25 +2,28 @@
The main QuerySet implementation. This provides the public API for the ORM.
"""
-from collections import deque, OrderedDict
import copy
import sys
import warnings
+from collections import OrderedDict, deque
from django.conf import settings
from django.core import exceptions
-from django.db import (connections, router, transaction, IntegrityError,
- DJANGO_VERSION_PICKLE_KEY)
+from django.db import (
+ DJANGO_VERSION_PICKLE_KEY, IntegrityError, connections, router,
+ transaction,
+)
+from django.db.models import sql
from django.db.models.constants import LOOKUP_SEP
-from django.db.models.fields import AutoField
-from django.db.models.query_utils import Q, deferred_class_factory, InvalidQuery
from django.db.models.deletion import Collector
+from django.db.models.expressions import F, Date, DateTime
+from django.db.models.fields import AutoField
+from django.db.models.query_utils import (
+ Q, InvalidQuery, deferred_class_factory,
+)
from django.db.models.sql.constants import CURSOR
-from django.db.models import sql
-from django.db.models.expressions import Date, DateTime, F
+from django.utils import six, timezone
from django.utils.functional import partition
-from django.utils import six
-from django.utils import timezone
from django.utils.version import get_version
# The maximum number of items to display in a QuerySet.__repr__
diff --git a/django/db/models/query_utils.py b/django/db/models/query_utils.py
index 1d6e8f731b..005bd99956 100644
--- a/django/db/models/query_utils.py
+++ b/django/db/models/query_utils.py
@@ -13,9 +13,7 @@ from django.apps import apps
from django.core.exceptions import FieldDoesNotExist
from django.db.backends import utils
from django.db.models.constants import LOOKUP_SEP
-from django.utils import six
-from django.utils import tree
-
+from django.utils import six, tree
# PathInfo is used when converting lookups (fk__somecol). The contents
# describe the relation in Model terms (model Options and Fields for both
diff --git a/django/db/models/sql/aggregates.py b/django/db/models/sql/aggregates.py
index 713f530a91..0ebe10e83f 100644
--- a/django/db/models/sql/aggregates.py
+++ b/django/db/models/sql/aggregates.py
@@ -4,12 +4,11 @@ Classes to represent the default SQL aggregate functions
import copy
import warnings
-from django.db.models.fields import IntegerField, FloatField
+from django.db.models.fields import FloatField, IntegerField
from django.db.models.lookups import RegisterLookupMixin
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.functional import cached_property
-
__all__ = ['Aggregate', 'Avg', 'Count', 'Max', 'Min', 'StdDev', 'Sum', 'Variance']
diff --git a/django/db/models/sql/compiler.py b/django/db/models/sql/compiler.py
index 210ca742f6..3ca2d6d675 100644
--- a/django/db/models/sql/compiler.py
+++ b/django/db/models/sql/compiler.py
@@ -1,15 +1,16 @@
-from itertools import chain
import re
import warnings
+from itertools import chain
from django.core.exceptions import FieldError
from django.db.models.constants import LOOKUP_SEP
from django.db.models.expressions import OrderBy, Random, RawSQL, Ref
-from django.db.models.query_utils import select_related_descend, QueryWrapper
-from django.db.models.sql.constants import (CURSOR, SINGLE, MULTI, NO_RESULTS,
- ORDER_DIR, GET_ITERATOR_CHUNK_SIZE)
+from django.db.models.query_utils import QueryWrapper, select_related_descend
+from django.db.models.sql.constants import (
+ CURSOR, GET_ITERATOR_CHUNK_SIZE, MULTI, NO_RESULTS, ORDER_DIR, SINGLE,
+)
from django.db.models.sql.datastructures import EmptyResultSet
-from django.db.models.sql.query import get_order_dir, Query
+from django.db.models.sql.query import Query, get_order_dir
from django.db.transaction import TransactionManagementError
from django.db.utils import DatabaseError
from django.utils.deprecation import RemovedInDjango20Warning
diff --git a/django/db/models/sql/query.py b/django/db/models/sql/query.py
index 5335d27570..9dede765f7 100644
--- a/django/db/models/sql/query.py
+++ b/django/db/models/sql/query.py
@@ -6,26 +6,27 @@ themselves do not have to (and could be backed by things other than SQL
databases). The abstraction barrier only works one way: this module has to know
all about the internals of models in order to get the information it needs.
"""
-from string import ascii_uppercase
-from itertools import count, product
-
-from collections import Mapping, OrderedDict
import copy
-from itertools import chain
import warnings
+from collections import Mapping, OrderedDict
+from itertools import chain, count, product
+from string import ascii_uppercase
from django.core.exceptions import FieldDoesNotExist, FieldError
-from django.db import connections, DEFAULT_DB_ALIAS
+from django.db import DEFAULT_DB_ALIAS, connections
from django.db.models.aggregates import Count
from django.db.models.constants import LOOKUP_SEP
from django.db.models.expressions import Col, Ref
-from django.db.models.query_utils import PathInfo, Q, refs_aggregate
-from django.db.models.sql.constants import (QUERY_TERMS, ORDER_DIR, SINGLE,
- ORDER_PATTERN, INNER, LOUTER)
+from django.db.models.query_utils import Q, PathInfo, refs_aggregate
+from django.db.models.sql.constants import (
+ INNER, LOUTER, ORDER_DIR, ORDER_PATTERN, QUERY_TERMS, SINGLE,
+)
from django.db.models.sql.datastructures import (
- EmptyResultSet, Empty, MultiJoin, Join, BaseTable)
-from django.db.models.sql.where import (WhereNode, ExtraWhere, AND, OR,
- NothingNode)
+ BaseTable, Empty, EmptyResultSet, Join, MultiJoin,
+)
+from django.db.models.sql.where import (
+ AND, OR, ExtraWhere, NothingNode, WhereNode,
+)
from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text
diff --git a/django/db/models/sql/subqueries.py b/django/db/models/sql/subqueries.py
index 727eabc5f5..14739dea0e 100644
--- a/django/db/models/sql/subqueries.py
+++ b/django/db/models/sql/subqueries.py
@@ -9,7 +9,6 @@ from django.db.models.sql.constants import GET_ITERATOR_CHUNK_SIZE, NO_RESULTS
from django.db.models.sql.query import Query
from django.utils import six
-
__all__ = ['DeleteQuery', 'UpdateQuery', 'InsertQuery', 'AggregateQuery']
diff --git a/django/db/models/sql/where.py b/django/db/models/sql/where.py
index de51e1db04..9836da8735 100644
--- a/django/db/models/sql/where.py
+++ b/django/db/models/sql/where.py
@@ -6,7 +6,6 @@ from django.db.models.sql.datastructures import EmptyResultSet
from django.utils import tree
from django.utils.functional import cached_property
-
# Connection types
AND = 'AND'
OR = 'OR'
diff --git a/django/db/transaction.py b/django/db/transaction.py
index 6d2bff52f4..d1388675d5 100644
--- a/django/db/transaction.py
+++ b/django/db/transaction.py
@@ -1,6 +1,6 @@
from django.db import (
- connections, DEFAULT_DB_ALIAS,
- DatabaseError, Error, ProgrammingError)
+ DEFAULT_DB_ALIAS, DatabaseError, Error, ProgrammingError, connections,
+)
from django.utils.decorators import ContextDecorator
diff --git a/django/db/utils.py b/django/db/utils.py
index ea622cddc6..0480adf2dc 100644
--- a/django/db/utils.py
+++ b/django/db/utils.py
@@ -1,15 +1,14 @@
-from importlib import import_module
import os
import pkgutil
+from importlib import import_module
from threading import local
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
+from django.utils import six
+from django.utils._os import upath
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
-from django.utils._os import upath
-from django.utils import six
-
DEFAULT_DB_ALIAS = 'default'
DJANGO_VERSION_PICKLE_KEY = '_django_version'
diff --git a/django/dispatch/weakref_backports.py b/django/dispatch/weakref_backports.py
index 4647436891..edc86936de 100644
--- a/django/dispatch/weakref_backports.py
+++ b/django/dispatch/weakref_backports.py
@@ -66,4 +66,3 @@ class WeakMethod(ref):
return True
__hash__ = ref.__hash__
-
diff --git a/django/forms/fields.py b/django/forms/fields.py
index 59490a318a..cca2091ffa 100644
--- a/django/forms/fields.py
+++ b/django/forms/fields.py
@@ -16,20 +16,24 @@ from io import BytesIO
from django.core import validators
from django.core.exceptions import ValidationError
+# Provide this import for backwards compatibility.
+from django.core.validators import EMPTY_VALUES # NOQA
from django.forms.utils import from_current_timezone, to_current_timezone
from django.forms.widgets import (
- TextInput, NumberInput, EmailInput, URLInput, HiddenInput,
- MultipleHiddenInput, ClearableFileInput, CheckboxInput, Select,
- NullBooleanSelect, SelectMultiple, DateInput, DateTimeInput, TimeInput,
- SplitDateTimeWidget, SplitHiddenDateTimeWidget, FILE_INPUT_CONTRADICTION
+ FILE_INPUT_CONTRADICTION, CheckboxInput, ClearableFileInput, DateInput,
+ DateTimeInput, EmailInput, HiddenInput, MultipleHiddenInput,
+ NullBooleanSelect, NumberInput, Select, SelectMultiple,
+ SplitDateTimeWidget, SplitHiddenDateTimeWidget, TextInput, TimeInput,
+ URLInput,
)
-from django.utils import formats
-from django.utils.encoding import smart_text, force_str, force_text
-from django.utils.ipv6 import clean_ipv6_address
+from django.utils import formats, six
from django.utils.dateparse import parse_duration
-from django.utils.deprecation import RemovedInDjango20Warning, RenameMethodsBase
+from django.utils.deprecation import (
+ RemovedInDjango20Warning, RenameMethodsBase,
+)
from django.utils.duration import duration_string
-from django.utils import six
+from django.utils.encoding import force_str, force_text, smart_text
+from django.utils.ipv6 import clean_ipv6_address
from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit
from django.utils.translation import ugettext_lazy as _, ungettext_lazy
diff --git a/django/forms/forms.py b/django/forms/forms.py
index c9b8cf2242..64405079d8 100644
--- a/django/forms/forms.py
+++ b/django/forms/forms.py
@@ -4,20 +4,21 @@ Form classes
from __future__ import unicode_literals
-from collections import OrderedDict
import copy
import datetime
+from collections import OrderedDict
-from django.core.exceptions import ValidationError, NON_FIELD_ERRORS
+from django.core.exceptions import NON_FIELD_ERRORS, ValidationError
from django.forms.fields import Field, FileField
-from django.forms.utils import flatatt, ErrorDict, ErrorList
-from django.forms.widgets import Media, MediaDefiningClass, TextInput, Textarea
-from django.utils.encoding import smart_text, force_text, python_2_unicode_compatible
+from django.forms.utils import ErrorDict, ErrorList, flatatt
+from django.forms.widgets import Media, MediaDefiningClass, Textarea, TextInput
+from django.utils import six
+from django.utils.encoding import (
+ force_text, python_2_unicode_compatible, smart_text,
+)
from django.utils.html import conditional_escape, format_html
from django.utils.safestring import mark_safe
from django.utils.translation import ugettext as _
-from django.utils import six
-
__all__ = ('BaseForm', 'Form')
diff --git a/django/forms/formsets.py b/django/forms/formsets.py
index 566269beb5..adacd00fdc 100644
--- a/django/forms/formsets.py
+++ b/django/forms/formsets.py
@@ -2,16 +2,15 @@ from __future__ import unicode_literals
from django.core.exceptions import ValidationError
from django.forms import Form
-from django.forms.fields import IntegerField, BooleanField
+from django.forms.fields import BooleanField, IntegerField
from django.forms.utils import ErrorList
from django.forms.widgets import HiddenInput
+from django.utils import six
from django.utils.encoding import python_2_unicode_compatible
from django.utils.functional import cached_property
from django.utils.safestring import mark_safe
-from django.utils import six
from django.utils.six.moves import range
-from django.utils.translation import ungettext, ugettext as _
-
+from django.utils.translation import ugettext as _, ungettext
__all__ = ('BaseFormSet', 'formset_factory', 'all_valid')
diff --git a/django/forms/models.py b/django/forms/models.py
index 7d5473276c..c861eed321 100644
--- a/django/forms/models.py
+++ b/django/forms/models.py
@@ -9,18 +9,19 @@ from collections import OrderedDict
from itertools import chain
from django.core.exceptions import (
- ImproperlyConfigured, ValidationError, NON_FIELD_ERRORS, FieldError)
-from django.forms.fields import Field, ChoiceField
-from django.forms.forms import DeclarativeFieldsMetaclass, BaseForm
+ NON_FIELD_ERRORS, FieldError, ImproperlyConfigured, ValidationError,
+)
+from django.forms.fields import ChoiceField, Field
+from django.forms.forms import BaseForm, DeclarativeFieldsMetaclass
from django.forms.formsets import BaseFormSet, formset_factory
from django.forms.utils import ErrorList
-from django.forms.widgets import (SelectMultiple, HiddenInput,
- MultipleHiddenInput)
+from django.forms.widgets import (
+ HiddenInput, MultipleHiddenInput, SelectMultiple,
+)
from django.utils import six
-from django.utils.encoding import smart_text, force_text
-from django.utils.text import get_text_list, capfirst
-from django.utils.translation import ugettext_lazy as _, ugettext
-
+from django.utils.encoding import force_text, smart_text
+from django.utils.text import capfirst, get_text_list
+from django.utils.translation import ugettext, ugettext_lazy as _
__all__ = (
'ModelForm', 'BaseModelForm', 'model_to_dict', 'fields_for_model',
diff --git a/django/forms/utils.py b/django/forms/utils.py
index 19c27f9b8c..ab0c80769b 100644
--- a/django/forms/utils.py
+++ b/django/forms/utils.py
@@ -3,21 +3,17 @@ from __future__ import unicode_literals
import json
import sys
-try:
- from collections import UserList
-except ImportError: # Python 2
- from UserList import UserList
-
from django.conf import settings
+from django.core.exceptions import ValidationError # backwards compatibility
+from django.utils import six, timezone
from django.utils.encoding import force_text, python_2_unicode_compatible
-from django.utils.html import format_html, format_html_join, escape
-from django.utils import timezone
+from django.utils.html import escape, format_html, format_html_join
from django.utils.translation import ugettext_lazy as _
-from django.utils import six
-# Import ValidationError so that it can be imported from this
-# module to maintain backwards compatibility.
-from django.core.exceptions import ValidationError
+try:
+ from collections import UserList
+except ImportError: # Python 2
+ from UserList import UserList
def flatatt(attrs):
diff --git a/django/forms/widgets.py b/django/forms/widgets.py
index c434ecf0a1..fedd78c838 100644
--- a/django/forms/widgets.py
+++ b/django/forms/widgets.py
@@ -6,15 +6,17 @@ from __future__ import unicode_literals
import copy
import datetime
-from itertools import chain
import re
+from itertools import chain
from django.conf import settings
from django.forms.utils import flatatt, to_current_timezone
from django.utils import datetime_safe, formats, six
from django.utils.datastructures import MultiValueDict
from django.utils.dates import MONTHS
-from django.utils.encoding import force_str, force_text, python_2_unicode_compatible
+from django.utils.encoding import (
+ force_str, force_text, python_2_unicode_compatible,
+)
from django.utils.formats import get_format
from django.utils.html import conditional_escape, format_html
from django.utils.safestring import mark_safe
diff --git a/django/http/cookie.py b/django/http/cookie.py
index 3bd9065d3a..a3dbd2a0b2 100644
--- a/django/http/cookie.py
+++ b/django/http/cookie.py
@@ -1,11 +1,11 @@
from __future__ import unicode_literals
+
import sys
-from django.utils.encoding import force_str
from django.utils import six
+from django.utils.encoding import force_str
from django.utils.six.moves import http_cookies
-
# Some versions of Python 2.7 and later won't need this encoding bug fix:
_cookie_encodes_correctly = http_cookies.SimpleCookie().value_encode(';') == (';', '"\\073"')
# See ticket #13007, http://bugs.python.org/issue2193 and http://trac.edgewall.org/ticket/2256
diff --git a/django/http/multipartparser.py b/django/http/multipartparser.py
index e1de03f8b1..53e4149519 100644
--- a/django/http/multipartparser.py
+++ b/django/http/multipartparser.py
@@ -13,12 +13,14 @@ import sys
from django.conf import settings
from django.core.exceptions import SuspiciousMultipartForm
+from django.core.files.uploadhandler import (
+ SkipFile, StopFutureHandlers, StopUpload,
+)
+from django.utils import six
from django.utils.datastructures import MultiValueDict
from django.utils.encoding import force_text
-from django.utils import six
from django.utils.six.moves.urllib.parse import unquote
from django.utils.text import unescape_entities
-from django.core.files.uploadhandler import StopUpload, SkipFile, StopFutureHandlers
__all__ = ('MultiPartParser', 'MultiPartParserError', 'InputStreamExhausted')
diff --git a/django/http/request.py b/django/http/request.py
index ea32574c68..398cf20dfb 100644
--- a/django/http/request.py
+++ b/django/http/request.py
@@ -14,12 +14,13 @@ from django.core.exceptions import DisallowedHost, ImproperlyConfigured
from django.core.files import uploadhandler
from django.http.multipartparser import MultiPartParser, MultiPartParserError
from django.utils import six
-from django.utils.datastructures import MultiValueDict, ImmutableList
+from django.utils.datastructures import ImmutableList, MultiValueDict
from django.utils.encoding import (
- force_bytes, force_text, force_str, escape_uri_path, iri_to_uri,
+ escape_uri_path, force_bytes, force_str, force_text, iri_to_uri,
+)
+from django.utils.six.moves.urllib.parse import (
+ parse_qsl, quote, urlencode, urljoin, urlsplit,
)
-from django.utils.six.moves.urllib.parse import parse_qsl, urlencode, quote, urljoin, urlsplit
-
RAISE_ERROR = object()
host_validation_re = re.compile(r"^([a-z0-9.-]+|\[[a-f0-9]*:[a-f0-9:]+\])(:\d+)?$")
diff --git a/django/http/response.py b/django/http/response.py
index 0386ec3a94..a317f96eb4 100644
--- a/django/http/response.py
+++ b/django/http/response.py
@@ -8,19 +8,19 @@ import time
from email.header import Header
from django.conf import settings
-from django.core import signals
-from django.core import signing
+from django.core import signals, signing
from django.core.exceptions import DisallowedRedirect
from django.core.serializers.json import DjangoJSONEncoder
from django.http.cookie import SimpleCookie
from django.utils import six, timezone
-from django.utils.encoding import force_bytes, force_text, force_str, iri_to_uri
+from django.utils.encoding import (
+ force_bytes, force_str, force_text, iri_to_uri,
+)
from django.utils.http import cookie_date
from django.utils.six.moves import map
from django.utils.six.moves.http_client import responses
from django.utils.six.moves.urllib.parse import urlparse
-
_charset_from_content_type_re = re.compile(r';\s*charset=(?P<charset>[^\s;]+)', re.I)
diff --git a/django/middleware/cache.py b/django/middleware/cache.py
index 7fab78f3dc..79202adda3 100644
--- a/django/middleware/cache.py
+++ b/django/middleware/cache.py
@@ -44,9 +44,11 @@ More details about how the caching works:
"""
from django.conf import settings
-from django.core.cache import caches, DEFAULT_CACHE_ALIAS
-from django.utils.cache import (get_cache_key, get_max_age, has_vary_header,
- learn_cache_key, patch_response_headers)
+from django.core.cache import DEFAULT_CACHE_ALIAS, caches
+from django.utils.cache import (
+ get_cache_key, get_max_age, has_vary_header, learn_cache_key,
+ patch_response_headers,
+)
class UpdateCacheMiddleware(object):
diff --git a/django/middleware/common.py b/django/middleware/common.py
index 0531d31908..c1414db375 100644
--- a/django/middleware/common.py
+++ b/django/middleware/common.py
@@ -2,14 +2,13 @@ import hashlib
import logging
import re
+from django import http
from django.conf import settings
-from django.core.mail import mail_managers
from django.core import urlresolvers
-from django import http
+from django.core.mail import mail_managers
+from django.utils import six
from django.utils.encoding import force_text
from django.utils.http import urlquote
-from django.utils import six
-
logger = logging.getLogger('django.request')
diff --git a/django/middleware/csrf.py b/django/middleware/csrf.py
index 7cbec6c772..f12126fa9f 100644
--- a/django/middleware/csrf.py
+++ b/django/middleware/csrf.py
@@ -12,10 +12,9 @@ import re
from django.conf import settings
from django.core.urlresolvers import get_callable
from django.utils.cache import patch_vary_headers
+from django.utils.crypto import constant_time_compare, get_random_string
from django.utils.encoding import force_text
from django.utils.http import same_origin
-from django.utils.crypto import constant_time_compare, get_random_string
-
logger = logging.getLogger('django.request')
diff --git a/django/middleware/gzip.py b/django/middleware/gzip.py
index 8548c083e3..e772cb326d 100644
--- a/django/middleware/gzip.py
+++ b/django/middleware/gzip.py
@@ -1,7 +1,7 @@
import re
-from django.utils.text import compress_sequence, compress_string
from django.utils.cache import patch_vary_headers
+from django.utils.text import compress_sequence, compress_string
re_accepts_gzip = re.compile(r'\bgzip\b')
diff --git a/django/middleware/locale.py b/django/middleware/locale.py
index 996b2d4c5b..9719150d59 100644
--- a/django/middleware/locale.py
+++ b/django/middleware/locale.py
@@ -1,11 +1,12 @@
"This is the locale selecting middleware that will look at accept headers"
from django.conf import settings
-from django.core.urlresolvers import (is_valid_path, get_resolver, get_script_prefix,
- LocaleRegexURLResolver)
+from django.core.urlresolvers import (
+ LocaleRegexURLResolver, get_resolver, get_script_prefix, is_valid_path,
+)
from django.http import HttpResponseRedirect
-from django.utils.cache import patch_vary_headers
from django.utils import translation
+from django.utils.cache import patch_vary_headers
class LocaleMiddleware(object):
diff --git a/django/shortcuts.py b/django/shortcuts.py
index bbfc99299f..415e51887e 100644
--- a/django/shortcuts.py
+++ b/django/shortcuts.py
@@ -6,16 +6,18 @@ for convenience's sake.
import warnings
-from django.template import loader, RequestContext
-from django.template.context import _current_app_undefined
-from django.template.engine import (
- _context_instance_undefined, _dictionary_undefined, _dirs_undefined)
-from django.http import HttpResponse, Http404
-from django.http import HttpResponseRedirect, HttpResponsePermanentRedirect
+from django.core import urlresolvers
from django.db.models.base import ModelBase
from django.db.models.manager import Manager
from django.db.models.query import QuerySet
-from django.core import urlresolvers
+from django.http import (
+ Http404, HttpResponse, HttpResponsePermanentRedirect, HttpResponseRedirect,
+)
+from django.template import RequestContext, loader
+from django.template.context import _current_app_undefined
+from django.template.engine import (
+ _context_instance_undefined, _dictionary_undefined, _dirs_undefined,
+)
from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text
diff --git a/django/template/backends/base.py b/django/template/backends/base.py
index 25a7dd2a15..00b5fc4b2b 100644
--- a/django/template/backends/base.py
+++ b/django/template/backends/base.py
@@ -2,7 +2,8 @@
from __future__ import absolute_import
from django.core.exceptions import (
- ImproperlyConfigured, SuspiciousFileOperation)
+ ImproperlyConfigured, SuspiciousFileOperation,
+)
from django.template.utils import get_app_template_dirs
from django.utils._os import safe_join
from django.utils.functional import cached_property
diff --git a/django/template/backends/django.py b/django/template/backends/django.py
index 2fe3227237..942445d367 100644
--- a/django/template/backends/django.py
+++ b/django/template/backends/django.py
@@ -5,10 +5,9 @@ import warnings
from django.conf import settings
from django.template.context import Context, RequestContext
-from django.template.engine import _dirs_undefined, Engine
+from django.template.engine import Engine, _dirs_undefined
from django.utils.deprecation import RemovedInDjango20Warning
-
from .base import BaseEngine
diff --git a/django/template/backends/jinja2.py b/django/template/backends/jinja2.py
index cc99a745cf..b26cb391f2 100644
--- a/django/template/backends/jinja2.py
+++ b/django/template/backends/jinja2.py
@@ -3,13 +3,13 @@ from __future__ import absolute_import
import sys
+import jinja2
+
from django.conf import settings
from django.template import TemplateDoesNotExist, TemplateSyntaxError
from django.utils import six
from django.utils.module_loading import import_string
-import jinja2
-
from .base import BaseEngine
from .utils import csrf_input_lazy, csrf_token_lazy
diff --git a/django/template/base.py b/django/template/base.py
index 775b5d8238..16b76f51fd 100644
--- a/django/template/base.py
+++ b/django/template/base.py
@@ -52,31 +52,34 @@ u'<html></html>'
from __future__ import unicode_literals
import re
+import warnings
from functools import partial
from importlib import import_module
from inspect import getargspec, getcallargs
-import warnings
from django.apps import apps
-from django.template.context import (BaseContext, Context, RequestContext, # NOQA: imported for backwards compatibility
- ContextPopException)
-from django.utils import lru_cache
-from django.utils.deprecation import (RemovedInDjango20Warning,
- RemovedInDjango21Warning)
-from django.utils.itercompat import is_iterable
-from django.utils.text import (smart_split, unescape_string_literal,
- get_text_list)
-from django.utils.encoding import force_str, force_text
-from django.utils.translation import ugettext_lazy, pgettext_lazy
-from django.utils.safestring import (SafeData, EscapeData, mark_safe,
- mark_for_escaping)
+from django.template.context import ( # NOQA: imported for backwards compatibility
+ BaseContext, Context, ContextPopException, RequestContext,
+)
+from django.utils import lru_cache, six
+from django.utils.deprecation import (
+ RemovedInDjango20Warning, RemovedInDjango21Warning,
+)
+from django.utils.encoding import (
+ force_str, force_text, python_2_unicode_compatible,
+)
from django.utils.formats import localize
from django.utils.html import conditional_escape
+from django.utils.itercompat import is_iterable
from django.utils.module_loading import module_has_submodule
-from django.utils import six
+from django.utils.safestring import (
+ EscapeData, SafeData, mark_for_escaping, mark_safe,
+)
+from django.utils.text import (
+ get_text_list, smart_split, unescape_string_literal,
+)
from django.utils.timezone import template_localtime
-from django.utils.encoding import python_2_unicode_compatible
-
+from django.utils.translation import pgettext_lazy, ugettext_lazy
TOKEN_TEXT = 0
TOKEN_VAR = 1
diff --git a/django/template/context.py b/django/template/context.py
index 9543931cec..aff8aa2e1c 100644
--- a/django/template/context.py
+++ b/django/template/context.py
@@ -1,9 +1,8 @@
-from copy import copy
import warnings
+from copy import copy
from django.utils.deprecation import RemovedInDjango20Warning
-
# Hard-coded processor for easier use of CSRF protection.
_builtin_context_processors = ('django.template.context_processors.csrf',)
diff --git a/django/template/debug.py b/django/template/debug.py
index 465d7ff926..7f2cbc585a 100644
--- a/django/template/debug.py
+++ b/django/template/debug.py
@@ -1,8 +1,10 @@
-from django.template.base import Lexer, Parser, tag_re, NodeList, VariableNode, TemplateSyntaxError
+from django.template.base import (
+ Lexer, NodeList, Parser, TemplateSyntaxError, VariableNode, tag_re,
+)
from django.utils.encoding import force_text
-from django.utils.html import conditional_escape
-from django.utils.safestring import SafeData, EscapeData
from django.utils.formats import localize
+from django.utils.html import conditional_escape
+from django.utils.safestring import EscapeData, SafeData
from django.utils.timezone import template_localtime
diff --git a/django/template/defaultfilters.py b/django/template/defaultfilters.py
index 16a3d4d6e9..57a4a7f1f9 100644
--- a/django/template/defaultfilters.py
+++ b/django/template/defaultfilters.py
@@ -1,29 +1,30 @@
"""Default variable filters."""
from __future__ import unicode_literals
-import re
import random as random_module
-from decimal import Decimal, InvalidOperation, Context, ROUND_HALF_UP
+import re
+import warnings
+from decimal import ROUND_HALF_UP, Context, Decimal, InvalidOperation
from functools import wraps
from pprint import pformat
-import warnings
-from django.template.base import Variable, Library, VariableDoesNotExist
from django.conf import settings
-from django.utils import formats
+from django.template.base import Library, Variable, VariableDoesNotExist
+from django.utils import formats, six
from django.utils.dateformat import format, time_format
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text, iri_to_uri
-from django.utils.html import (conditional_escape, escapejs,
- escape, urlize as _urlize, linebreaks, strip_tags, avoid_wrapping,
- remove_tags)
+from django.utils.html import (
+ avoid_wrapping, conditional_escape, escape, escapejs, linebreaks,
+ remove_tags, strip_tags, urlize as _urlize,
+)
from django.utils.http import urlquote
-from django.utils.text import Truncator, wrap, phone2numeric
-from django.utils.safestring import mark_safe, SafeData, mark_for_escaping
-from django.utils import six
+from django.utils.safestring import SafeData, mark_for_escaping, mark_safe
+from django.utils.text import (
+ Truncator, normalize_newlines, phone2numeric, slugify as _slugify, wrap,
+)
from django.utils.timesince import timesince, timeuntil
from django.utils.translation import ugettext, ungettext
-from django.utils.text import normalize_newlines, slugify as _slugify
register = Library()
diff --git a/django/template/defaulttags.py b/django/template/defaulttags.py
index b65bed7bf8..a75248332c 100644
--- a/django/template/defaulttags.py
+++ b/django/template/defaulttags.py
@@ -2,28 +2,29 @@
from __future__ import unicode_literals
import os
-import sys
import re
-from datetime import datetime
-from itertools import groupby, cycle as itertools_cycle
+import sys
import warnings
+from datetime import datetime
+from itertools import cycle as itertools_cycle, groupby
from django.conf import settings
-from django.template.base import (Node, NodeList, Template, Context, 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,
- VARIABLE_ATTRIBUTE_SEPARATOR, get_library, token_kwargs, kwarg_re,
- render_value_in_context)
-from django.template.smartif import IfParser, Literal
+from django.template.base import (
+ BLOCK_TAG_END, BLOCK_TAG_START, COMMENT_TAG_END, COMMENT_TAG_START,
+ SINGLE_BRACE_END, SINGLE_BRACE_START, VARIABLE_ATTRIBUTE_SEPARATOR,
+ VARIABLE_TAG_END, VARIABLE_TAG_START, Context, InvalidTemplateLibrary,
+ Library, Node, NodeList, Template, TemplateSyntaxError,
+ VariableDoesNotExist, get_library, kwarg_re, render_value_in_context,
+ token_kwargs,
+)
from django.template.defaultfilters import date
+from django.template.smartif import IfParser, Literal
+from django.utils import six, timezone
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text, smart_text
-from django.utils.lorem_ipsum import words, paragraphs
-from django.utils.safestring import mark_safe
from django.utils.html import format_html
-from django.utils import six
-from django.utils import timezone
+from django.utils.lorem_ipsum import paragraphs, words
+from django.utils.safestring import mark_safe
register = Library()
diff --git a/django/template/engine.py b/django/template/engine.py
index b346f41f8b..9e7f88aeb4 100644
--- a/django/template/engine.py
+++ b/django/template/engine.py
@@ -1,8 +1,7 @@
import warnings
from django.core.exceptions import ImproperlyConfigured
-from django.utils import lru_cache
-from django.utils import six
+from django.utils import lru_cache, six
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
@@ -10,7 +9,6 @@ from django.utils.module_loading import import_string
from .base import Context, Lexer, Parser, Template, TemplateDoesNotExist
from .context import _builtin_context_processors
-
_context_instance_undefined = object()
_dictionary_undefined = object()
_dirs_undefined = object()
diff --git a/django/template/loader.py b/django/template/loader.py
index c03690fbd1..c8fb16bf92 100644
--- a/django/template/loader.py
+++ b/django/template/loader.py
@@ -6,7 +6,9 @@ from . import engines
from .backends.django import DjangoTemplates
from .base import Origin, TemplateDoesNotExist
from .engine import (
- _context_instance_undefined, _dictionary_undefined, _dirs_undefined)
+ _context_instance_undefined, _dictionary_undefined, _dirs_undefined,
+)
+from .loaders import base
class LoaderOrigin(Origin):
@@ -142,10 +144,6 @@ def _engine_list(using=None):
return engines.all() if using is None else [engines[using]]
-# This line must remain at the bottom to avoid import loops.
-from .loaders import base
-
-
class BaseLoader(base.Loader):
_accepts_engine_in_init = False
diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py
index b41b1ea4c3..f1c08ee955 100644
--- a/django/template/loader_tags.py
+++ b/django/template/loader_tags.py
@@ -1,9 +1,10 @@
from collections import defaultdict
-from django.template.base import TemplateSyntaxError, Library, Node, TextNode,\
- token_kwargs, Variable
-from django.utils.safestring import mark_safe
+from django.template.base import (
+ Library, Node, TemplateSyntaxError, TextNode, Variable, token_kwargs,
+)
from django.utils import six
+from django.utils.safestring import mark_safe
register = Library()
diff --git a/django/template/loaders/cached.py b/django/template/loaders/cached.py
index 5c53b0a658..188268e92e 100644
--- a/django/template/loaders/cached.py
+++ b/django/template/loaders/cached.py
@@ -4,6 +4,7 @@ to load templates from them in order, caching the result.
"""
import hashlib
+
from django.template.base import Template, TemplateDoesNotExist
from django.utils.encoding import force_bytes
diff --git a/django/template/loaders/eggs.py b/django/template/loaders/eggs.py
index 4ced12936f..14a586877d 100644
--- a/django/template/loaders/eggs.py
+++ b/django/template/loaders/eggs.py
@@ -1,17 +1,17 @@
# Wrapper for loading templates from eggs via pkg_resources.resource_string.
from __future__ import unicode_literals
-try:
- from pkg_resources import resource_string
-except ImportError:
- resource_string = None
-
from django.apps import apps
from django.template.base import TemplateDoesNotExist
from django.utils import six
from .base import Loader as BaseLoader
+try:
+ from pkg_resources import resource_string
+except ImportError:
+ resource_string = None
+
class Loader(BaseLoader):
diff --git a/django/template/response.py b/django/template/response.py
index 48295c5e05..094907ed97 100644
--- a/django/template/response.py
+++ b/django/template/response.py
@@ -1,7 +1,7 @@
import warnings
from django.http import HttpResponse
-from django.template import loader, Context, RequestContext, Template
+from django.template import Context, RequestContext, Template, loader
from django.template.backends.django import Template as BackendTemplate
from django.template.context import _current_app_undefined
from django.utils import six
diff --git a/django/template/utils.py b/django/template/utils.py
index be2166810c..f9b322fea9 100644
--- a/django/template/utils.py
+++ b/django/template/utils.py
@@ -1,13 +1,12 @@
-from collections import Counter, OrderedDict
import os
import sys
import warnings
+from collections import Counter, OrderedDict
from django.apps import apps
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
-from django.utils import lru_cache
-from django.utils import six
+from django.utils import lru_cache, six
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.functional import cached_property
from django.utils.module_loading import import_string
diff --git a/django/templatetags/cache.py b/django/templatetags/cache.py
index 994868e43a..997e03fc99 100644
--- a/django/templatetags/cache.py
+++ b/django/templatetags/cache.py
@@ -1,8 +1,10 @@
from __future__ import unicode_literals
-from django.core.cache import caches, InvalidCacheBackendError
+from django.core.cache import InvalidCacheBackendError, caches
from django.core.cache.utils import make_template_fragment_key
-from django.template import Library, Node, TemplateSyntaxError, VariableDoesNotExist
+from django.template import (
+ Library, Node, TemplateSyntaxError, VariableDoesNotExist,
+)
register = Library()
diff --git a/django/templatetags/future.py b/django/templatetags/future.py
index d584a1dd2b..257bd9ac6c 100644
--- a/django/templatetags/future.py
+++ b/django/templatetags/future.py
@@ -1,7 +1,6 @@
import warnings
-from django.template import Library
-from django.template import defaulttags
+from django.template import Library, defaulttags
from django.utils.deprecation import RemovedInDjango20Warning
register = Library()
diff --git a/django/templatetags/i18n.py b/django/templatetags/i18n.py
index aa0a34ef40..2a2b433508 100644
--- a/django/templatetags/i18n.py
+++ b/django/templatetags/i18n.py
@@ -1,14 +1,15 @@
from __future__ import unicode_literals
+
import re
import sys
from django.conf import settings
from django.template import Library, Node, TemplateSyntaxError, Variable
-from django.template.base import render_value_in_context, TokenParser, TOKEN_TEXT, TOKEN_VAR
+from django.template.base import (
+ TOKEN_TEXT, TOKEN_VAR, TokenParser, render_value_in_context,
+)
from django.template.defaulttags import token_kwargs
-from django.utils import six
-from django.utils import translation
-
+from django.utils import six, translation
register = Library()
diff --git a/django/templatetags/l10n.py b/django/templatetags/l10n.py
index 31dae9b105..cbc47bcb94 100644
--- a/django/templatetags/l10n.py
+++ b/django/templatetags/l10n.py
@@ -1,5 +1,4 @@
-from django.template import Node
-from django.template import TemplateSyntaxError, Library
+from django.template import Library, Node, TemplateSyntaxError
from django.utils import formats
from django.utils.encoding import force_text
diff --git a/django/templatetags/tz.py b/django/templatetags/tz.py
index 05088e1a89..2af165e7ab 100644
--- a/django/templatetags/tz.py
+++ b/django/templatetags/tz.py
@@ -1,14 +1,13 @@
from datetime import datetime, tzinfo
+from django.template import Library, Node, TemplateSyntaxError
+from django.utils import six, timezone
+
try:
import pytz
except ImportError:
pytz = None
-from django.template import Node
-from django.template import TemplateSyntaxError, Library
-from django.utils import six
-from django.utils import timezone
register = Library()
diff --git a/django/test/client.py b/django/test/client.py
index a19970f02e..d845fe76a7 100644
--- a/django/test/client.py
+++ b/django/test/client.py
@@ -1,9 +1,9 @@
from __future__ import unicode_literals
-import sys
+import mimetypes
import os
import re
-import mimetypes
+import sys
from copy import copy
from importlib import import_module
from io import BytesIO
@@ -12,20 +12,21 @@ from django.apps import apps
from django.conf import settings
from django.core import urlresolvers
from django.core.handlers.base import BaseHandler
-from django.core.handlers.wsgi import WSGIRequest, ISO_8859_1, UTF_8
-from django.core.signals import (request_started, request_finished,
- got_request_exception)
+from django.core.handlers.wsgi import ISO_8859_1, UTF_8, WSGIRequest
+from django.core.signals import (
+ got_request_exception, request_finished, request_started,
+)
from django.db import close_old_connections
-from django.http import SimpleCookie, HttpRequest, QueryDict
+from django.http import HttpRequest, QueryDict, SimpleCookie
from django.template import TemplateDoesNotExist
from django.test import signals
-from django.utils.functional import curry, SimpleLazyObject
+from django.test.utils import ContextList
+from django.utils import six
from django.utils.encoding import force_bytes, force_str, uri_to_iri
+from django.utils.functional import SimpleLazyObject, curry
from django.utils.http import urlencode
from django.utils.itercompat import is_iterable
-from django.utils import six
from django.utils.six.moves.urllib.parse import urlparse, urlsplit
-from django.test.utils import ContextList
__all__ = ('Client', 'RedirectCycleError', 'RequestFactory', 'encode_file', 'encode_multipart')
diff --git a/django/test/html.py b/django/test/html.py
index cca4a48491..28db398cf7 100644
--- a/django/test/html.py
+++ b/django/test/html.py
@@ -5,11 +5,10 @@ Comparing two html documents.
from __future__ import unicode_literals
import re
-from django.utils.encoding import force_text
-from django.utils.html_parser import HTMLParser, HTMLParseError
-from django.utils import six
-from django.utils.encoding import python_2_unicode_compatible
+from django.utils import six
+from django.utils.encoding import force_text, python_2_unicode_compatible
+from django.utils.html_parser import HTMLParseError, HTMLParser
WHITESPACE = re.compile('\s+')
diff --git a/django/test/runner.py b/django/test/runner.py
index 73a5a9d175..1106c52803 100644
--- a/django/test/runner.py
+++ b/django/test/runner.py
@@ -1,7 +1,7 @@
-from importlib import import_module
import logging
import os
import unittest
+from importlib import import_module
from unittest import TestSuite, defaultTestLoader
from django.conf import settings
diff --git a/django/test/signals.py b/django/test/signals.py
index 56a8945e01..d2bb209dbf 100644
--- a/django/test/signals.py
+++ b/django/test/signals.py
@@ -1,13 +1,13 @@
import os
-import time
import threading
+import time
import warnings
from django.conf import settings
from django.core.signals import setting_changed
from django.db import connections, router
from django.db.utils import ConnectionRouter
-from django.dispatch import receiver, Signal
+from django.dispatch import Signal, receiver
from django.utils import timezone
from django.utils.functional import empty
diff --git a/django/test/testcases.py b/django/test/testcases.py
index 5195145998..853ac7b4d5 100644
--- a/django/test/testcases.py
+++ b/django/test/testcases.py
@@ -1,10 +1,7 @@
from __future__ import unicode_literals
-from collections import Counter
-from copy import copy
import difflib
import errno
-from functools import wraps
import json
import os
import posixpath
@@ -14,34 +11,40 @@ import sys
import threading
import unittest
import warnings
+from collections import Counter
+from copy import copy
+from functools import wraps
from unittest.util import safe_repr
from django.apps import apps
from django.conf import settings
from django.core import mail
-from django.core.exceptions import ValidationError, ImproperlyConfigured
-from django.core.handlers.wsgi import get_path_info, WSGIHandler
+from django.core.exceptions import ImproperlyConfigured, ValidationError
+from django.core.handlers.wsgi import WSGIHandler, get_path_info
from django.core.management import call_command
from django.core.management.color import no_style
from django.core.management.commands import flush
from django.core.servers.basehttp import WSGIRequestHandler, WSGIServer
from django.core.urlresolvers import clear_url_caches, set_urlconf
-from django.db import connection, connections, DEFAULT_DB_ALIAS, transaction
+from django.db import DEFAULT_DB_ALIAS, connection, connections, transaction
from django.forms.fields import CharField
from django.http import QueryDict
from django.test.client import Client
from django.test.html import HTMLParseError, parse_html
from django.test.signals import setting_changed, template_rendered
-from django.test.utils import (CaptureQueriesContext, ContextList,
- override_settings, modify_settings, compare_xml)
+from django.test.utils import (
+ CaptureQueriesContext, ContextList, compare_xml, modify_settings,
+ override_settings,
+)
+from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text
-from django.utils import six
-from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit, urlparse, unquote
+from django.utils.six.moves.urllib.parse import (
+ unquote, urlparse, urlsplit, urlunsplit,
+)
from django.utils.six.moves.urllib.request import url2pathname
from django.views.static import serve
-
__all__ = ('TestCase', 'TransactionTestCase',
'SimpleTestCase', 'skipIfDBFeature', 'skipUnlessDBFeature')
diff --git a/django/test/utils.py b/django/test/utils.py
index f0d8993a40..5224bcfb71 100644
--- a/django/test/utils.py
+++ b/django/test/utils.py
@@ -1,21 +1,21 @@
-from contextlib import contextmanager
import logging
import re
import sys
import time
-from unittest import skipIf, skipUnless
import warnings
+from contextlib import contextmanager
from functools import wraps
-from xml.dom.minidom import parseString, Node
+from unittest import skipIf, skipUnless
+from xml.dom.minidom import Node, parseString
from django.apps import apps
-from django.conf import settings, UserSettingsHolder
+from django.conf import UserSettingsHolder, settings
from django.core import mail
from django.core.signals import request_started
from django.db import reset_queries
from django.http import request
from django.template import Template
-from django.test.signals import template_rendered, setting_changed
+from django.test.signals import setting_changed, template_rendered
from django.utils import six
from django.utils.encoding import force_str
from django.utils.translation import deactivate
diff --git a/django/utils/_os.py b/django/utils/_os.py
index bcfe3de636..679b206e18 100644
--- a/django/utils/_os.py
+++ b/django/utils/_os.py
@@ -2,11 +2,11 @@ import os
import stat
import sys
import tempfile
-from os.path import join, normcase, normpath, abspath, isabs, sep, dirname
+from os.path import abspath, dirname, isabs, join, normcase, normpath, sep
from django.core.exceptions import SuspiciousFileOperation
-from django.utils.encoding import force_text
from django.utils import six
+from django.utils.encoding import force_text
try:
WindowsError = WindowsError
diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py
index 0fa6ee2855..9c3e0bf5ef 100644
--- a/django/utils/autoreload.py
+++ b/django/utils/autoreload.py
@@ -28,7 +28,8 @@
# OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
# OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-from __future__ import absolute_import # Avoid importing `importlib` from this package.
+# Avoid importing `import importlib` from this package
+from __future__ import absolute_import
import os
import signal
diff --git a/django/utils/cache.py b/django/utils/cache.py
index 365733fedf..e48e159910 100644
--- a/django/utils/cache.py
+++ b/django/utils/cache.py
@@ -24,7 +24,7 @@ import time
from django.conf import settings
from django.core.cache import caches
-from django.utils.encoding import iri_to_uri, force_bytes, force_text
+from django.utils.encoding import force_bytes, force_text, iri_to_uri
from django.utils.http import http_date
from django.utils.timezone import get_current_timezone_name
from django.utils.translation import get_language
diff --git a/django/utils/crypto.py b/django/utils/crypto.py
index a2a64052b7..b364762275 100644
--- a/django/utils/crypto.py
+++ b/django/utils/crypto.py
@@ -3,14 +3,19 @@ Django's standard crypto functions and utilities.
"""
from __future__ import unicode_literals
+import binascii
+import hashlib
import hmac
+import random
import struct
-import hashlib
-import binascii
import time
+from django.conf import settings
+from django.utils import six
+from django.utils.encoding import force_bytes
+from django.utils.six.moves import range
+
# Use the system PRNG if possible
-import random
try:
random = random.SystemRandom()
using_sysrandom = True
@@ -20,11 +25,6 @@ except NotImplementedError:
'on your system. Falling back to Mersenne Twister.')
using_sysrandom = False
-from django.conf import settings
-from django.utils.encoding import force_bytes
-from django.utils import six
-from django.utils.six.moves import range
-
def salted_hmac(key_salt, value, secret=None):
"""
diff --git a/django/utils/dateformat.py b/django/utils/dateformat.py
index 1640f9ae5a..f4de4e7f7c 100644
--- a/django/utils/dateformat.py
+++ b/django/utils/dateformat.py
@@ -12,16 +12,18 @@ Usage:
"""
from __future__ import unicode_literals
-import re
-import time
import calendar
import datetime
+import re
+import time
-from django.utils.dates import MONTHS, MONTHS_3, MONTHS_ALT, MONTHS_AP, WEEKDAYS, WEEKDAYS_ABBR
-from django.utils.translation import ugettext as _
-from django.utils.encoding import force_text
from django.utils import six
+from django.utils.dates import (
+ MONTHS, MONTHS_3, MONTHS_ALT, MONTHS_AP, WEEKDAYS, WEEKDAYS_ABBR,
+)
+from django.utils.encoding import force_text
from django.utils.timezone import get_default_timezone, is_aware, is_naive
+from django.utils.translation import ugettext as _
re_formatchars = re.compile(r'(?<!\\)([aAbBcdDeEfFgGhHiIjlLmMnNoOPrsStTUuwWyYzZ])')
re_escaped = re.compile(r'\\(.)')
diff --git a/django/utils/dateparse.py b/django/utils/dateparse.py
index 2c749f015c..a3c760e8fb 100644
--- a/django/utils/dateparse.py
+++ b/django/utils/dateparse.py
@@ -7,9 +7,9 @@
import datetime
import re
-from django.utils import six
-from django.utils.timezone import utc, get_fixed_timezone
+from django.utils import six
+from django.utils.timezone import get_fixed_timezone, utc
date_re = re.compile(
r'(?P<year>\d{4})-(?P<month>\d{1,2})-(?P<day>\d{1,2})$'
diff --git a/django/utils/dates.py b/django/utils/dates.py
index 25f092e618..680415fccb 100644
--- a/django/utils/dates.py
+++ b/django/utils/dates.py
@@ -1,6 +1,6 @@
"Commonly-used date structures"
-from django.utils.translation import ugettext_lazy as _, pgettext_lazy
+from django.utils.translation import pgettext_lazy, ugettext_lazy as _
WEEKDAYS = {
0: _('Monday'), 1: _('Tuesday'), 2: _('Wednesday'), 3: _('Thursday'), 4: _('Friday'),
diff --git a/django/utils/datetime_safe.py b/django/utils/datetime_safe.py
index 51cdfe31ef..d2e5b95241 100644
--- a/django/utils/datetime_safe.py
+++ b/django/utils/datetime_safe.py
@@ -7,9 +7,11 @@
# >>> datetime_safe.date(1850, 8, 2).strftime("%Y/%m/%d was a %A")
# '1850/08/02 was a Friday'
-from datetime import date as real_date, time as real_time, datetime as real_datetime
import re
import time as ttime
+from datetime import (
+ date as real_date, datetime as real_datetime, time as real_time,
+)
class date(real_date):
diff --git a/django/utils/deconstruct.py b/django/utils/deconstruct.py
index e0713a6d61..a94d242f61 100644
--- a/django/utils/deconstruct.py
+++ b/django/utils/deconstruct.py
@@ -1,4 +1,6 @@
-from __future__ import absolute_import # Avoid importing `importlib` from this package.
+# Avoid importing `importlib` from this package.
+from __future__ import absolute_import
+
from importlib import import_module
from django.utils.version import get_docs_version
diff --git a/django/utils/decorators.py b/django/utils/decorators.py
index ba951a9ebc..10ad1ce506 100644
--- a/django/utils/decorators.py
+++ b/django/utils/decorators.py
@@ -5,7 +5,7 @@ try:
except ImportError:
ContextDecorator = None
-from functools import wraps, update_wrapper, WRAPPER_ASSIGNMENTS
+from functools import WRAPPER_ASSIGNMENTS, update_wrapper, wraps
from django.utils import six
diff --git a/django/utils/encoding.py b/django/utils/encoding.py
index 40096741a7..99c9da843a 100644
--- a/django/utils/encoding.py
+++ b/django/utils/encoding.py
@@ -3,12 +3,13 @@ from __future__ import unicode_literals
import codecs
import datetime
-from decimal import Decimal
import locale
+from decimal import Decimal
-from django.utils.functional import Promise
from django.utils import six
+from django.utils.functional import Promise
from django.utils.six.moves.urllib.parse import quote, unquote
+
if six.PY3:
from urllib.parse import unquote_to_bytes
diff --git a/django/utils/feedgenerator.py b/django/utils/feedgenerator.py
index 5578ddf46f..d870b50435 100644
--- a/django/utils/feedgenerator.py
+++ b/django/utils/feedgenerator.py
@@ -24,13 +24,13 @@ http://web.archive.org/web/20110718035220/http://diveintomark.org/archives/2004/
from __future__ import unicode_literals
import datetime
-from django.utils.xmlutils import SimplerXMLGenerator
+
+from django.utils import datetime_safe, six
from django.utils.encoding import force_text, iri_to_uri
-from django.utils import datetime_safe
-from django.utils import six
from django.utils.six import StringIO
from django.utils.six.moves.urllib.parse import urlparse
from django.utils.timezone import is_aware
+from django.utils.xmlutils import SimplerXMLGenerator
def rfc2822_date(date):
diff --git a/django/utils/formats.py b/django/utils/formats.py
index 855b1a1cc0..c40e542e7d 100644
--- a/django/utils/formats.py
+++ b/django/utils/formats.py
@@ -1,17 +1,19 @@
-from __future__ import absolute_import # Avoid importing `importlib` from this package.
+# Avoid importing `importlib` from this package.
+from __future__ import absolute_import
-import decimal
import datetime
-from importlib import import_module
+import decimal
import unicodedata
+from importlib import import_module
from django.conf import settings
-from django.utils import dateformat, numberformat, datetime_safe
+from django.utils import dateformat, datetime_safe, numberformat, six
from django.utils.encoding import force_str
from django.utils.functional import lazy
from django.utils.safestring import mark_safe
-from django.utils import six
-from django.utils.translation import get_language, to_locale, check_for_language
+from django.utils.translation import (
+ check_for_language, get_language, to_locale,
+)
# format_cache is a mapping from (format_type, lang) to the format string.
# By using the cache, it is possible to avoid running get_format_modules
diff --git a/django/utils/functional.py b/django/utils/functional.py
index 4c085d9c6d..50ff8824f9 100644
--- a/django/utils/functional.py
+++ b/django/utils/functional.py
@@ -1,7 +1,7 @@
import copy
import operator
-from functools import wraps
import sys
+from functools import wraps
from django.utils import six
from django.utils.six.moves import copyreg
diff --git a/django/utils/html.py b/django/utils/html.py
index 758d458f40..569ac74e96 100644
--- a/django/utils/html.py
+++ b/django/utils/html.py
@@ -5,17 +5,18 @@ from __future__ import unicode_literals
import re
import warnings
+from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
-from django.utils.encoding import force_text, force_str
+from django.utils.encoding import force_str, force_text
from django.utils.functional import allow_lazy
from django.utils.http import RFC3986_GENDELIMS, RFC3986_SUBDELIMS
from django.utils.safestring import SafeData, SafeText, mark_safe
-from django.utils import six
-from django.utils.six.moves.urllib.parse import parse_qsl, quote, unquote, urlencode, urlsplit, urlunsplit
+from django.utils.six.moves.urllib.parse import (
+ parse_qsl, quote, unquote, urlencode, urlsplit, urlunsplit,
+)
from django.utils.text import normalize_newlines
-from .html_parser import HTMLParser, HTMLParseError
-
+from .html_parser import HTMLParseError, HTMLParser
# Configuration for urlize() function.
TRAILING_PUNCTUATION = ['.', ',', ':', ';', '.)', '"', '\'', '!']
diff --git a/django/utils/html_parser.py b/django/utils/html_parser.py
index 4aff4a9a78..e7f7c11571 100644
--- a/django/utils/html_parser.py
+++ b/django/utils/html_parser.py
@@ -1,7 +1,8 @@
-from django.utils.six.moves import html_parser as _html_parser
import re
import sys
+from django.utils.six.moves import html_parser as _html_parser
+
current_version = sys.version_info
use_workaround = current_version < (2, 7, 3)
diff --git a/django/utils/http.py b/django/utils/http.py
index 431f83df21..d732a9c825 100644
--- a/django/utils/http.py
+++ b/django/utils/http.py
@@ -5,17 +5,17 @@ import calendar
import datetime
import re
import sys
-
from binascii import Error as BinasciiError
from email.utils import formatdate
+from django.utils import six
from django.utils.datastructures import MultiValueDict
from django.utils.encoding import force_bytes, force_str, force_text
from django.utils.functional import allow_lazy
-from django.utils import six
from django.utils.six.moves.urllib.parse import (
- quote, quote_plus, unquote, unquote_plus, urlparse,
- urlencode as original_urlencode)
+ quote, quote_plus, unquote, unquote_plus, urlencode as original_urlencode,
+ urlparse,
+)
ETAG_MATCH = re.compile(r'(?:W/)?"((?:\\.|[^"])*)"')
diff --git a/django/utils/ipv6.py b/django/utils/ipv6.py
index 54ccc73b94..94e9dcf50e 100644
--- a/django/utils/ipv6.py
+++ b/django/utils/ipv6.py
@@ -2,8 +2,8 @@
# Copyright 2007 Google Inc. http://code.google.com/p/ipaddr-py/
# Licensed under the Apache License, Version 2.0 (the "License").
from django.core.exceptions import ValidationError
-from django.utils.translation import ugettext_lazy as _
from django.utils.six.moves import range
+from django.utils.translation import ugettext_lazy as _
def clean_ipv6_address(ip_str, unpack_ipv4=False,
diff --git a/django/utils/jslex.py b/django/utils/jslex.py
index 35bdc57e1a..cfc8654432 100644
--- a/django/utils/jslex.py
+++ b/django/utils/jslex.py
@@ -1,6 +1,7 @@
"""JsLex: a lexer for Javascript"""
# Originally from https://bitbucket.org/ned/jslex
from __future__ import unicode_literals
+
import re
diff --git a/django/utils/module_loading.py b/django/utils/module_loading.py
index a4e255842d..568493ba96 100644
--- a/django/utils/module_loading.py
+++ b/django/utils/module_loading.py
@@ -1,9 +1,10 @@
-from __future__ import absolute_import # Avoid importing `importlib` from this package.
+# Avoid importing `importlib` from this package.
+from __future__ import absolute_import
import copy
-from importlib import import_module
import os
import sys
+from importlib import import_module
from django.utils import six
diff --git a/django/utils/numberformat.py b/django/utils/numberformat.py
index c3cf55bca5..dcccc99e0b 100644
--- a/django/utils/numberformat.py
+++ b/django/utils/numberformat.py
@@ -1,8 +1,8 @@
from decimal import Decimal
from django.conf import settings
-from django.utils.safestring import mark_safe
from django.utils import six
+from django.utils.safestring import mark_safe
def format(number, decimal_sep, decimal_pos=None, grouping=0, thousand_sep='',
diff --git a/django/utils/safestring.py b/django/utils/safestring.py
index ab4d8149c9..3d3bf1b62a 100644
--- a/django/utils/safestring.py
+++ b/django/utils/safestring.py
@@ -4,8 +4,8 @@ without further escaping in HTML. Marking something as a "safe string" means
that the producer of the string has already turned characters that should not
be interpreted by the HTML engine (e.g. '<') into the appropriate entities.
"""
-from django.utils.functional import curry, Promise
from django.utils import six
+from django.utils.functional import Promise, curry
class EscapeData(object):
diff --git a/django/utils/text.py b/django/utils/text.py
index ad549c349d..5d1f4a0998 100644
--- a/django/utils/text.py
+++ b/django/utils/text.py
@@ -5,12 +5,12 @@ import unicodedata
from gzip import GzipFile
from io import BytesIO
-from django.utils.encoding import force_text
-from django.utils.functional import allow_lazy, SimpleLazyObject
from django.utils import six
-from django.utils.six.moves import html_entities
-from django.utils.translation import ugettext_lazy, ugettext as _, pgettext
+from django.utils.encoding import force_text
+from django.utils.functional import SimpleLazyObject, allow_lazy
from django.utils.safestring import SafeText, mark_safe
+from django.utils.six.moves import html_entities
+from django.utils.translation import pgettext, ugettext as _, ugettext_lazy
if six.PY2:
# Import force_unicode even though this module doesn't use it, because some
diff --git a/django/utils/timezone.py b/django/utils/timezone.py
index a45a72f2f9..dbda90c64a 100644
--- a/django/utils/timezone.py
+++ b/django/utils/timezone.py
@@ -4,20 +4,20 @@ Timezone-related classes and functions.
This module uses pytz when it's available and fallbacks when it isn't.
"""
-from datetime import datetime, timedelta, tzinfo
-from threading import local
import sys
import time as _time
+from datetime import datetime, timedelta, tzinfo
+from threading import local
+
+from django.conf import settings
+from django.utils import lru_cache, six
+from django.utils.decorators import ContextDecorator
try:
import pytz
except ImportError:
pytz = None
-from django.conf import settings
-from django.utils import lru_cache
-from django.utils import six
-from django.utils.decorators import ContextDecorator
__all__ = [
'utc', 'get_fixed_timezone',
diff --git a/django/utils/translation/trans_real.py b/django/utils/translation/trans_real.py
index 18bb84b1de..9cdf02f3fd 100644
--- a/django/utils/translation/trans_real.py
+++ b/django/utils/translation/trans_real.py
@@ -1,13 +1,13 @@
"""Translation helper functions."""
from __future__ import unicode_literals
-from collections import OrderedDict
+import gettext as gettext_module
import os
import re
import sys
-import gettext as gettext_module
-from threading import local
import warnings
+from collections import OrderedDict
+from threading import local
from django.apps import apps
from django.conf import settings
@@ -15,12 +15,14 @@ from django.conf.locale import LANG_INFO
from django.core.exceptions import AppRegistryNotReady
from django.core.signals import setting_changed
from django.dispatch import receiver
-from django.utils.encoding import force_text
+from django.utils import lru_cache, six
from django.utils._os import upath
-from django.utils.safestring import mark_safe, SafeData
-from django.utils import six, lru_cache
+from django.utils.encoding import force_text
+from django.utils.safestring import SafeData, mark_safe
from django.utils.six import StringIO
-from django.utils.translation import TranslatorCommentWarning, trim_whitespace, LANGUAGE_SESSION_KEY
+from django.utils.translation import (
+ LANGUAGE_SESSION_KEY, TranslatorCommentWarning, trim_whitespace,
+)
# Translations are cached in a dictionary for every language.
# The active translations are stored by threadid to make them thread local.
diff --git a/django/views/csrf.py b/django/views/csrf.py
index a709e5fc1c..aa227d3b6e 100644
--- a/django/views/csrf.py
+++ b/django/views/csrf.py
@@ -4,6 +4,7 @@ from django.template import Context, Template
from django.utils.translation import ugettext as _
from django.utils.version import get_docs_version
+
# We include the template inline since we need to be able to reliably display
# this error message, especially for the sake of developers, and there isn't any
# other way of making it available independent of what is in the settings file.
diff --git a/django/views/debug.py b/django/views/debug.py
index 19254c5cf2..0a4aa8f74d 100644
--- a/django/views/debug.py
+++ b/django/views/debug.py
@@ -7,20 +7,19 @@ import sys
import types
from django.conf import settings
-from django.core.urlresolvers import resolve, Resolver404
-from django.http import (HttpResponse, HttpResponseNotFound, HttpRequest,
- build_request_repr)
+from django.core.urlresolvers import Resolver404, resolve
+from django.http import (
+ HttpRequest, HttpResponse, HttpResponseNotFound, build_request_repr,
+)
from django.template import Context, Engine, TemplateDoesNotExist
from django.template.defaultfilters import force_escape, pprint
+from django.utils import lru_cache, six
from django.utils.datastructures import MultiValueDict
-from django.utils.html import escape
from django.utils.encoding import force_bytes, smart_text
-from django.utils import lru_cache
+from django.utils.html import escape
from django.utils.module_loading import import_string
-from django.utils import six
from django.utils.translation import ugettext as _
-
# Minimal Django templates engine to render the error templates
# regardless of the project's TEMPLATES setting.
DEBUG_ENGINE = Engine(debug=True)
diff --git a/django/views/decorators/cache.py b/django/views/decorators/cache.py
index f52169db4f..07e0e70946 100644
--- a/django/views/decorators/cache.py
+++ b/django/views/decorators/cache.py
@@ -1,7 +1,10 @@
from functools import wraps
-from django.utils.decorators import decorator_from_middleware_with_args, available_attrs
-from django.utils.cache import patch_cache_control, add_never_cache_headers
+
from django.middleware.cache import CacheMiddleware
+from django.utils.cache import add_never_cache_headers, patch_cache_control
+from django.utils.decorators import (
+ available_attrs, decorator_from_middleware_with_args,
+)
def cache_page(*args, **kwargs):
diff --git a/django/views/decorators/csrf.py b/django/views/decorators/csrf.py
index 1ebed2a6a1..d8c89c176c 100644
--- a/django/views/decorators/csrf.py
+++ b/django/views/decorators/csrf.py
@@ -1,7 +1,8 @@
-from django.middleware.csrf import CsrfViewMiddleware, get_token
-from django.utils.decorators import decorator_from_middleware, available_attrs
from functools import wraps
+from django.middleware.csrf import CsrfViewMiddleware, get_token
+from django.utils.decorators import available_attrs, decorator_from_middleware
+
csrf_protect = decorator_from_middleware(CsrfViewMiddleware)
csrf_protect.__name__ = "csrf_protect"
csrf_protect.__doc__ = """
diff --git a/django/views/decorators/gzip.py b/django/views/decorators/gzip.py
index f5b009db4a..96d6aa805e 100644
--- a/django/views/decorators/gzip.py
+++ b/django/views/decorators/gzip.py
@@ -1,5 +1,5 @@
-from django.utils.decorators import decorator_from_middleware
from django.middleware.gzip import GZipMiddleware
+from django.utils.decorators import decorator_from_middleware
gzip_page = decorator_from_middleware(GZipMiddleware)
gzip_page.__doc__ = "Decorator for views that gzips pages if the client supports it."
diff --git a/django/views/decorators/http.py b/django/views/decorators/http.py
index 990c3770db..4399182fbd 100644
--- a/django/views/decorators/http.py
+++ b/django/views/decorators/http.py
@@ -6,10 +6,14 @@ import logging
from calendar import timegm
from functools import wraps
-from django.utils.decorators import decorator_from_middleware, available_attrs
-from django.utils.http import http_date, parse_http_date_safe, parse_etags, quote_etag
+from django.http import (
+ HttpResponse, HttpResponseNotAllowed, HttpResponseNotModified,
+)
from django.middleware.http import ConditionalGetMiddleware
-from django.http import HttpResponseNotAllowed, HttpResponseNotModified, HttpResponse
+from django.utils.decorators import available_attrs, decorator_from_middleware
+from django.utils.http import (
+ http_date, parse_etags, parse_http_date_safe, quote_etag,
+)
conditional_page = decorator_from_middleware(ConditionalGetMiddleware)
diff --git a/django/views/decorators/vary.py b/django/views/decorators/vary.py
index 056669278b..df92c65c5c 100644
--- a/django/views/decorators/vary.py
+++ b/django/views/decorators/vary.py
@@ -1,4 +1,5 @@
from functools import wraps
+
from django.utils.cache import patch_vary_headers
from django.utils.decorators import available_attrs
diff --git a/django/views/defaults.py b/django/views/defaults.py
index e71756d1dd..35d42830a4 100644
--- a/django/views/defaults.py
+++ b/django/views/defaults.py
@@ -1,5 +1,5 @@
from django import http
-from django.template import loader, Context, Engine, TemplateDoesNotExist
+from django.template import Context, Engine, TemplateDoesNotExist, loader
from django.views.decorators.csrf import requires_csrf_token
diff --git a/django/views/generic/base.py b/django/views/generic/base.py
index 88b6608fd2..5bc610355a 100644
--- a/django/views/generic/base.py
+++ b/django/views/generic/base.py
@@ -5,10 +5,10 @@ from functools import update_wrapper
from django import http
from django.core.exceptions import ImproperlyConfigured
-from django.core.urlresolvers import reverse, NoReverseMatch
+from django.core.urlresolvers import NoReverseMatch, reverse
from django.template.response import TemplateResponse
-from django.utils.decorators import classonlymethod
from django.utils import six
+from django.utils.decorators import classonlymethod
logger = logging.getLogger('django.request')
diff --git a/django/views/generic/dates.py b/django/views/generic/dates.py
index 27f0ba1065..2a63db2fe9 100644
--- a/django/views/generic/dates.py
+++ b/django/views/generic/dates.py
@@ -1,17 +1,22 @@
from __future__ import unicode_literals
import datetime
+
from django.conf import settings
-from django.db import models
from django.core.exceptions import ImproperlyConfigured
+from django.db import models
from django.http import Http404
+from django.utils import timezone
from django.utils.encoding import force_str, force_text
from django.utils.functional import cached_property
from django.utils.translation import ugettext as _
-from django.utils import timezone
from django.views.generic.base import View
-from django.views.generic.detail import BaseDetailView, SingleObjectTemplateResponseMixin
-from django.views.generic.list import MultipleObjectMixin, MultipleObjectTemplateResponseMixin
+from django.views.generic.detail import (
+ BaseDetailView, SingleObjectTemplateResponseMixin,
+)
+from django.views.generic.list import (
+ MultipleObjectMixin, MultipleObjectTemplateResponseMixin,
+)
class YearMixin(object):
diff --git a/django/views/generic/detail.py b/django/views/generic/detail.py
index a40e93a7f5..13649a318b 100644
--- a/django/views/generic/detail.py
+++ b/django/views/generic/detail.py
@@ -4,7 +4,7 @@ from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.http import Http404
from django.utils.translation import ugettext as _
-from django.views.generic.base import TemplateResponseMixin, ContextMixin, View
+from django.views.generic.base import ContextMixin, TemplateResponseMixin, View
class SingleObjectMixin(ContextMixin):
diff --git a/django/views/generic/edit.py b/django/views/generic/edit.py
index a4329a25b0..2a2590263f 100644
--- a/django/views/generic/edit.py
+++ b/django/views/generic/edit.py
@@ -8,9 +8,10 @@ from django.http import HttpResponseRedirect
from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.encoding import force_text
-from django.views.generic.base import TemplateResponseMixin, ContextMixin, View
-from django.views.generic.detail import (SingleObjectMixin,
- SingleObjectTemplateResponseMixin, BaseDetailView)
+from django.views.generic.base import ContextMixin, TemplateResponseMixin, View
+from django.views.generic.detail import (
+ BaseDetailView, SingleObjectMixin, SingleObjectTemplateResponseMixin,
+)
PERCENT_PLACEHOLDER_REGEX = re.compile(r'%\([^\)]+\)') # RemovedInDjango20Warning
diff --git a/django/views/generic/list.py b/django/views/generic/list.py
index 2243bcec4a..ccb2185524 100644
--- a/django/views/generic/list.py
+++ b/django/views/generic/list.py
@@ -1,12 +1,12 @@
from __future__ import unicode_literals
-from django.core.paginator import Paginator, InvalidPage
from django.core.exceptions import ImproperlyConfigured
+from django.core.paginator import InvalidPage, Paginator
from django.db.models.query import QuerySet
from django.http import Http404
from django.utils import six
from django.utils.translation import ugettext as _
-from django.views.generic.base import TemplateResponseMixin, ContextMixin, View
+from django.views.generic.base import ContextMixin, TemplateResponseMixin, View
class MultipleObjectMixin(ContextMixin):
diff --git a/django/views/i18n.py b/django/views/i18n.py
index 7278f6ce1b..11ce8c6293 100644
--- a/django/views/i18n.py
+++ b/django/views/i18n.py
@@ -1,18 +1,20 @@
+import gettext as gettext_module
import importlib
import json
import os
-import gettext as gettext_module
from django import http
from django.apps import apps
from django.conf import settings
from django.template import Context, Template
-from django.utils.translation import check_for_language, to_locale, get_language, LANGUAGE_SESSION_KEY
-from django.utils.encoding import smart_text
-from django.utils.formats import get_format_modules, get_format
+from django.utils import six
from django.utils._os import upath
+from django.utils.encoding import smart_text
+from django.utils.formats import get_format, get_format_modules
from django.utils.http import is_safe_url
-from django.utils import six
+from django.utils.translation import (
+ LANGUAGE_SESSION_KEY, check_for_language, get_language, to_locale,
+)
def set_language(request):
diff --git a/django/views/static.py b/django/views/static.py
index 75e81eccd3..1ff36bc8e9 100644
--- a/django/views/static.py
+++ b/django/views/static.py
@@ -6,13 +6,15 @@ from __future__ import unicode_literals
import mimetypes
import os
-import stat
import posixpath
import re
+import stat
-from django.http import (Http404, HttpResponse, HttpResponseRedirect,
- HttpResponseNotModified, FileResponse)
-from django.template import loader, Template, Context, TemplateDoesNotExist
+from django.http import (
+ FileResponse, Http404, HttpResponse, HttpResponseNotModified,
+ HttpResponseRedirect,
+)
+from django.template import Context, Template, TemplateDoesNotExist, loader
from django.utils.http import http_date, parse_http_date
from django.utils.six.moves.urllib.parse import unquote
from django.utils.translation import ugettext as _, ugettext_lazy
diff --git a/docs/_ext/applyxrefs.py b/docs/_ext/applyxrefs.py
index 513c17d84e..2dbebde0a3 100644
--- a/docs/_ext/applyxrefs.py
+++ b/docs/_ext/applyxrefs.py
@@ -1,7 +1,7 @@
"""Adds xref targets to the top of files."""
-import sys
import os
+import sys
testing = False
diff --git a/docs/_ext/djangodocs.py b/docs/_ext/djangodocs.py
index af419fa953..38f11dfd98 100644
--- a/docs/_ext/djangodocs.py
+++ b/docs/_ext/djangodocs.py
@@ -7,13 +7,12 @@ import re
from docutils import nodes
from docutils.parsers.rst import directives
-
-from sphinx import addnodes, __version__ as sphinx_ver
+from sphinx import __version__ as sphinx_ver, addnodes
from sphinx.builders.html import StandaloneHTMLBuilder
-from sphinx.writers.html import SmartyPantsHTMLTranslator
-from sphinx.util.console import bold
from sphinx.util.compat import Directive
+from sphinx.util.console import bold
from sphinx.util.nodes import set_source_info
+from sphinx.writers.html import SmartyPantsHTMLTranslator
# RE for option descriptions without a '--' prefix
simple_option_desc_re = re.compile(
diff --git a/docs/_ext/literals_to_xrefs.py b/docs/_ext/literals_to_xrefs.py
index c3bd2628e8..7c3f16131f 100644
--- a/docs/_ext/literals_to_xrefs.py
+++ b/docs/_ext/literals_to_xrefs.py
@@ -4,8 +4,8 @@ with new-style references.
"""
import re
-import sys
import shelve
+import sys
refre = re.compile(r'``([^`\s]+?)``')
diff --git a/scripts/manage_translations.py b/scripts/manage_translations.py
index bedb3d82b3..546c4f87da 100644
--- a/scripts/manage_translations.py
+++ b/scripts/manage_translations.py
@@ -18,13 +18,12 @@
#
# $ python scripts/manage_translations.py lang_stats --language=es --resources=admin
-from argparse import ArgumentParser
import os
-from subprocess import call, Popen, PIPE
+from argparse import ArgumentParser
+from subprocess import PIPE, Popen, call
from django.core.management import call_command
-
HAVE_JS = ['admin']
diff --git a/setup.cfg b/setup.cfg
index ef96c071b6..a29bd9e153 100644
--- a/setup.cfg
+++ b/setup.cfg
@@ -7,6 +7,13 @@ exclude=build,.git,./django/utils/lru_cache.py,./django/utils/six.py,./django/co
ignore=E123,E128,E265,E501,W601
max-line-length = 119
+[isort]
+combine_as_imports = true
+default_section = THIRDPARTY
+include_trailing_comma = true
+known_first_party = django
+multi_line_output = 5
+
[metadata]
license-file = LICENSE
diff --git a/setup.py b/setup.py
index afe299abd8..ac6997841f 100644
--- a/setup.py
+++ b/setup.py
@@ -1,9 +1,9 @@
import os
import sys
-
-from setuptools import setup, find_packages
from distutils.sysconfig import get_python_lib
+from setuptools import find_packages, setup
+
# Warn if we are installing over top of an existing installation. This can
# cause issues where files that were deleted from a more recent Django are
# still present in site-packages. See #18115.
diff --git a/tests/admin_autodiscover/admin.py b/tests/admin_autodiscover/admin.py
index e7d1a080c2..e2b941ac93 100644
--- a/tests/admin_autodiscover/admin.py
+++ b/tests/admin_autodiscover/admin.py
@@ -2,6 +2,5 @@ from django.contrib import admin
from .models import Story
-
admin.site.register(Story)
raise Exception("Bad admin module")
diff --git a/tests/admin_changelist/admin.py b/tests/admin_changelist/admin.py
index b2bd578e80..926a45d518 100644
--- a/tests/admin_changelist/admin.py
+++ b/tests/admin_changelist/admin.py
@@ -1,10 +1,9 @@
from django.contrib import admin
-from django.core.paginator import Paginator
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
+from django.core.paginator import Paginator
-from .models import Event, Child, Parent, Swallow
-
+from .models import Child, Event, Parent, Swallow
site = admin.AdminSite(name="admin")
diff --git a/tests/admin_changelist/tests.py b/tests/admin_changelist/tests.py
index 16b56aef86..8647ff7e2c 100644
--- a/tests/admin_changelist/tests.py
+++ b/tests/admin_changelist/tests.py
@@ -5,25 +5,28 @@ import datetime
from django.contrib import admin
from django.contrib.admin.options import IncorrectLookupParameters
from django.contrib.admin.templatetags.admin_list import pagination
-from django.contrib.admin.views.main import ChangeList, SEARCH_VAR, ALL_VAR
from django.contrib.admin.tests import AdminSeleniumWebDriverTestCase
+from django.contrib.admin.views.main import ALL_VAR, SEARCH_VAR, ChangeList
from django.contrib.auth.models import User
from django.core.urlresolvers import reverse
from django.template import Context, Template
from django.test import TestCase, override_settings
from django.test.client import RequestFactory
-from django.utils import formats
-from django.utils import six
-
-from .admin import (ChildAdmin, QuartetAdmin, BandAdmin, ChordsBandAdmin,
- GroupAdmin, ParentAdmin, DynamicListDisplayChildAdmin,
- DynamicListDisplayLinksChildAdmin, CustomPaginationAdmin,
- FilteredChildAdmin, CustomPaginator, site as custom_site,
- SwallowAdmin, DynamicListFilterChildAdmin, InvitationAdmin,
- DynamicSearchFieldsChildAdmin, NoListDisplayLinksParentAdmin)
-from .models import (Event, Child, Parent, Genre, Band, Musician, Group,
- Quartet, Membership, ChordsMusician, ChordsBand, Invitation, Swallow,
- UnorderedObject, OrderedObject, CustomIdUser)
+from django.utils import formats, six
+
+from .admin import (
+ BandAdmin, ChildAdmin, ChordsBandAdmin, CustomPaginationAdmin,
+ CustomPaginator, DynamicListDisplayChildAdmin,
+ DynamicListDisplayLinksChildAdmin, DynamicListFilterChildAdmin,
+ DynamicSearchFieldsChildAdmin, FilteredChildAdmin, GroupAdmin,
+ InvitationAdmin, NoListDisplayLinksParentAdmin, ParentAdmin, QuartetAdmin,
+ SwallowAdmin, site as custom_site,
+)
+from .models import (
+ Band, Child, ChordsBand, ChordsMusician, CustomIdUser, Event, Genre, Group,
+ Invitation, Membership, Musician, OrderedObject, Parent, Quartet, Swallow,
+ UnorderedObject,
+)
@override_settings(ROOT_URLCONF="admin_changelist.urls")
diff --git a/tests/admin_changelist/urls.py b/tests/admin_changelist/urls.py
index b73893b2ae..4da326ccc4 100644
--- a/tests/admin_changelist/urls.py
+++ b/tests/admin_changelist/urls.py
@@ -2,7 +2,6 @@ from django.conf.urls import include, url
from . import admin
-
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
]
diff --git a/tests/admin_checks/models.py b/tests/admin_checks/models.py
index 6c34d95ab8..dbb5931c8c 100644
--- a/tests/admin_checks/models.py
+++ b/tests/admin_checks/models.py
@@ -2,10 +2,10 @@
Tests of ModelAdmin system checks logic.
"""
+from django.contrib.contenttypes.fields import GenericForeignKey
+from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
-from django.contrib.contenttypes.models import ContentType
-from django.contrib.contenttypes.fields import GenericForeignKey
class Album(models.Model):
diff --git a/tests/admin_checks/tests.py b/tests/admin_checks/tests.py
index 4f5bd5e48a..864609a6c7 100644
--- a/tests/admin_checks/tests.py
+++ b/tests/admin_checks/tests.py
@@ -6,7 +6,7 @@ from django.contrib.contenttypes.admin import GenericStackedInline
from django.core import checks
from django.test import TestCase, override_settings
-from .models import Song, Book, Album, TwoAlbumFKAndAnE, City, State, Influence
+from .models import Album, Book, City, Influence, Song, State, TwoAlbumFKAndAnE
class SongForm(forms.ModelForm):
diff --git a/tests/admin_custom_urls/tests.py b/tests/admin_custom_urls/tests.py
index 56827c08c4..3260bc603c 100644
--- a/tests/admin_custom_urls/tests.py
+++ b/tests/admin_custom_urls/tests.py
@@ -5,7 +5,7 @@ from django.core.urlresolvers import reverse
from django.template.response import TemplateResponse
from django.test import TestCase, override_settings
-from .models import Action, Person, Car
+from .models import Action, Car, Person
@override_settings(PASSWORD_HASHERS=['django.contrib.auth.hashers.SHA1PasswordHasher'],
diff --git a/tests/admin_custom_urls/urls.py b/tests/admin_custom_urls/urls.py
index 1d14a09161..eb91d283d4 100644
--- a/tests/admin_custom_urls/urls.py
+++ b/tests/admin_custom_urls/urls.py
@@ -1,7 +1,6 @@
from django.conf.urls import include, url
from django.contrib import admin
-
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
]
diff --git a/tests/admin_docs/tests.py b/tests/admin_docs/tests.py
index 5ba0e2a0bc..60e35569d9 100644
--- a/tests/admin_docs/tests.py
+++ b/tests/admin_docs/tests.py
@@ -2,14 +2,14 @@ import sys
import unittest
from django.conf import settings
-from django.contrib.sites.models import Site
from django.contrib.admindocs import utils
from django.contrib.admindocs.views import get_return_data_type
from django.contrib.auth.models import User
+from django.contrib.sites.models import Site
from django.core.urlresolvers import reverse
from django.test import TestCase, modify_settings, override_settings
-from .models import Person, Company
+from .models import Company, Person
@override_settings(
diff --git a/tests/admin_docs/views.py b/tests/admin_docs/views.py
index 9a2f81d45c..31d253f7e2 100644
--- a/tests/admin_docs/views.py
+++ b/tests/admin_docs/views.py
@@ -1,7 +1,7 @@
+from django.contrib.admindocs.middleware import XViewMiddleware
from django.http import HttpResponse
from django.utils.decorators import decorator_from_middleware
from django.views.generic import View
-from django.contrib.admindocs.middleware import XViewMiddleware
xview_dec = decorator_from_middleware(XViewMiddleware)
diff --git a/tests/admin_filters/models.py b/tests/admin_filters/models.py
index 36e098e62a..588d90ea48 100644
--- a/tests/admin_filters/models.py
+++ b/tests/admin_filters/models.py
@@ -1,7 +1,9 @@
from __future__ import unicode_literals
from django.contrib.auth.models import User
-from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
+from django.contrib.contenttypes.fields import (
+ GenericForeignKey, GenericRelation,
+)
from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
diff --git a/tests/admin_filters/tests.py b/tests/admin_filters/tests.py
index 2b9836f5d1..f01f9dff10 100644
--- a/tests/admin_filters/tests.py
+++ b/tests/admin_filters/tests.py
@@ -2,17 +2,19 @@ from __future__ import unicode_literals
import datetime
-from django.contrib.admin import (site, ModelAdmin, SimpleListFilter,
- BooleanFieldListFilter, AllValuesFieldListFilter, RelatedOnlyFieldListFilter)
+from django.contrib.admin import (
+ AllValuesFieldListFilter, BooleanFieldListFilter, ModelAdmin,
+ RelatedOnlyFieldListFilter, SimpleListFilter, site,
+)
from django.contrib.admin.views.main import ChangeList
from django.contrib.auth.admin import UserAdmin
from django.contrib.auth.models import User
from django.core.exceptions import ImproperlyConfigured
-from django.test import TestCase, RequestFactory, override_settings
-from django.utils.encoding import force_text
+from django.test import RequestFactory, TestCase, override_settings
from django.utils import six
+from django.utils.encoding import force_text
-from .models import Book, Department, Employee, Bookmark, TaggedItem
+from .models import Book, Bookmark, Department, Employee, TaggedItem
def select_by(dictlist, key, value):
diff --git a/tests/admin_inlines/admin.py b/tests/admin_inlines/admin.py
index 4fc7478132..136cf3a96c 100644
--- a/tests/admin_inlines/admin.py
+++ b/tests/admin_inlines/admin.py
@@ -1,5 +1,5 @@
-from django.contrib import admin
from django import forms
+from django.contrib import admin
from .models import (
Author, BinaryTree, CapoFamiglia, Chapter, ChildModel1, ChildModel2,
diff --git a/tests/admin_inlines/models.py b/tests/admin_inlines/models.py
index 0ad59a07bf..d1003f607a 100644
--- a/tests/admin_inlines/models.py
+++ b/tests/admin_inlines/models.py
@@ -3,11 +3,12 @@ Testing of admin inline formsets.
"""
from __future__ import unicode_literals
+
import random
-from django.db import models
from django.contrib.contenttypes.fields import GenericForeignKey
from django.contrib.contenttypes.models import ContentType
+from django.db import models
from django.utils.encoding import python_2_unicode_compatible
diff --git a/tests/admin_inlines/tests.py b/tests/admin_inlines/tests.py
index fe481994d0..78889be30e 100644
--- a/tests/admin_inlines/tests.py
+++ b/tests/admin_inlines/tests.py
@@ -2,21 +2,22 @@ from __future__ import unicode_literals
import warnings
-from django.contrib.admin import TabularInline, ModelAdmin
-from django.contrib.admin.tests import AdminSeleniumWebDriverTestCase
+from django.contrib.admin import ModelAdmin, TabularInline
from django.contrib.admin.helpers import InlineAdminForm
-from django.contrib.auth.models import User, Permission
+from django.contrib.admin.tests import AdminSeleniumWebDriverTestCase
+from django.contrib.auth.models import Permission, User
from django.contrib.contenttypes.models import ContentType
-from django.test import TestCase, override_settings, RequestFactory
+from django.test import RequestFactory, TestCase, override_settings
from django.utils.encoding import force_text
-# local test models
from .admin import InnerInline, site as admin_site
-from .models import (Holder, Inner, Holder2, Inner2, Holder3, Inner3, Person,
- OutfitItem, Fashionista, Teacher, Parent, Child, Author, Book, Profile,
- ProfileCollection, ParentModelWithCustomPk, ChildModel1, ChildModel2,
- Sighting, Novel, Chapter, FootNote, BinaryTree, SomeParentModel,
- SomeChildModel, Poll, Question, Inner4Stacked, Inner4Tabular, Holder4)
+from .models import (
+ Author, BinaryTree, Book, Chapter, Child, ChildModel1, ChildModel2,
+ Fashionista, FootNote, Holder, Holder2, Holder3, Holder4, Inner, Inner2,
+ Inner3, Inner4Stacked, Inner4Tabular, Novel, OutfitItem, Parent,
+ ParentModelWithCustomPk, Person, Poll, Profile, ProfileCollection,
+ Question, Sighting, SomeChildModel, SomeParentModel, Teacher,
+)
INLINE_CHANGELINK_HTML = 'class="inlinechangelink">Change</a>'
diff --git a/tests/admin_inlines/urls.py b/tests/admin_inlines/urls.py
index b73893b2ae..4da326ccc4 100644
--- a/tests/admin_inlines/urls.py
+++ b/tests/admin_inlines/urls.py
@@ -2,7 +2,6 @@ from django.conf.urls import include, url
from . import admin
-
urlpatterns = [
url(r'^admin/', include(admin.site.urls)),
]
diff --git a/tests/admin_ordering/tests.py b/tests/admin_ordering/tests.py
index 1bd06e6e5a..e984395469 100644
--- a/tests/admin_ordering/tests.py
+++ b/tests/admin_ordering/tests.py
@@ -3,10 +3,12 @@ from __future__ import unicode_literals
from django.contrib import admin
from django.contrib.admin.options import ModelAdmin
from django.contrib.auth.models import User
-from django.test import TestCase, RequestFactory
+from django.test import RequestFactory, TestCase
-from .models import (Band, Song, SongInlineDefaultOrdering,
- SongInlineNewOrdering, DynOrderingBandAdmin)
+from .models import (
+ Band, DynOrderingBandAdmin, Song, SongInlineDefaultOrdering,
+ SongInlineNewOrdering,
+)
class MockRequest(object):
diff --git a/tests/admin_registration/tests.py b/tests/admin_registration/tests.py
index 98a509fc42..355aa3960c 100644
--- a/tests/admin_registration/tests.py
+++ b/tests/admin_registration/tests.py
@@ -6,7 +6,7 @@ from django.contrib.admin.sites import site
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase
-from .models import Person, Place, Location, Traveler
+from .models import Location, Person, Place, Traveler
class NameAdmin(admin.ModelAdmin):
diff --git a/tests/admin_scripts/app_with_import/models.py b/tests/admin_scripts/app_with_import/models.py
index 89125c386f..3741541628 100644
--- a/tests/admin_scripts/app_with_import/models.py
+++ b/tests/admin_scripts/app_with_import/models.py
@@ -1,5 +1,5 @@
-from django.db import models
from django.contrib.auth.models import User
+from django.db import models
# Regression for #13368. This is an example of a model
diff --git a/tests/admin_scripts/complex_app/admin/foo.py b/tests/admin_scripts/complex_app/admin/foo.py
index 09ceba05aa..adf22b330c 100644
--- a/tests/admin_scripts/complex_app/admin/foo.py
+++ b/tests/admin_scripts/complex_app/admin/foo.py
@@ -2,5 +2,4 @@ from django.contrib import admin
from ..models.foo import Foo
-
admin.site.register(Foo)
diff --git a/tests/admin_scripts/tests.py b/tests/admin_scripts/tests.py
index c7603e3914..319bd47407 100644
--- a/tests/admin_scripts/tests.py
+++ b/tests/admin_scripts/tests.py
@@ -1,11 +1,10 @@
# -*- coding: utf-8 -*-
-from __future__ import unicode_literals
-
"""
A series of tests to establish that the command-line management tools work as
-advertised - especially with regards to the handling of the DJANGO_SETTINGS_MODULE
-and default settings.py files.
+advertised - especially with regards to the handling of the
+DJANGO_SETTINGS_MODULE and default settings.py files.
"""
+from __future__ import unicode_literals
import codecs
import os
@@ -19,13 +18,14 @@ import unittest
import django
from django import conf, get_version
from django.conf import settings
-from django.core.management import BaseCommand, CommandError, call_command, color
-from django.utils.encoding import force_text
-from django.utils._os import npath, upath
-from django.utils.six import StringIO
+from django.core.management import (
+ BaseCommand, CommandError, call_command, color,
+)
from django.test import LiveServerTestCase, TestCase, mock, override_settings
from django.test.runner import DiscoverRunner
-
+from django.utils._os import npath, upath
+from django.utils.encoding import force_text
+from django.utils.six import StringIO
test_dir = os.path.realpath(os.path.join(os.environ['DJANGO_TEST_TEMP_DIR'], 'test_project'))
if not os.path.exists(test_dir):
diff --git a/tests/admin_scripts/urls.py b/tests/admin_scripts/urls.py
index b3f4eef15b..d258641fbe 100644
--- a/tests/admin_scripts/urls.py
+++ b/tests/admin_scripts/urls.py
@@ -1,4 +1,5 @@
import os
+
from django.conf.urls import url
from django.utils._os import upath
from django.views.static import serve
diff --git a/tests/admin_utils/tests.py b/tests/admin_utils/tests.py
index 01710e51ce..5720fbb64d 100644
--- a/tests/admin_utils/tests.py
+++ b/tests/admin_utils/tests.py
@@ -2,20 +2,24 @@ from __future__ import unicode_literals
from datetime import datetime
+from django import forms
from django.conf import settings
from django.contrib import admin
from django.contrib.admin import helpers
-from django.contrib.admin.utils import (display_for_field, flatten,
- flatten_fieldsets, label_for_field, lookup_field, NestedObjects)
+from django.contrib.admin.utils import (
+ NestedObjects, display_for_field, flatten, flatten_fieldsets,
+ label_for_field, lookup_field,
+)
from django.contrib.admin.views.main import EMPTY_CHANGELIST_VALUE
-from django.db import models, DEFAULT_DB_ALIAS
-from django import forms
+from django.db import DEFAULT_DB_ALIAS, models
from django.test import TestCase
+from django.utils import six
from django.utils.formats import localize
from django.utils.safestring import mark_safe
-from django.utils import six
-from .models import Site, Article, Count, Event, Location, EventGuide, Vehicle, Car
+from .models import (
+ Article, Car, Count, Event, EventGuide, Location, Site, Vehicle,
+)
class NestedObjectsTests(TestCase):
diff --git a/tests/admin_views/admin.py b/tests/admin_views/admin.py
index dd49a0c0da..c044a6ac21 100644
--- a/tests/admin_views/admin.py
+++ b/tests/admin_views/admin.py
@@ -1,45 +1,46 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-import tempfile
import os
+import tempfile
from wsgiref.util import FileWrapper
from django import forms
+from django.conf.urls import url
from django.contrib import admin
+from django.contrib.admin import BooleanFieldListFilter
from django.contrib.admin.views.main import ChangeList
+from django.contrib.auth.admin import GroupAdmin, UserAdmin
+from django.contrib.auth.models import Group, User
from django.core.exceptions import ValidationError
from django.core.files.storage import FileSystemStorage
from django.core.mail import EmailMessage
-from django.conf.urls import url
from django.forms.models import BaseModelFormSet
from django.http import HttpResponse, StreamingHttpResponse
-from django.contrib.admin import BooleanFieldListFilter
from django.utils.safestring import mark_safe
from django.utils.six import StringIO
from .models import (
- Article, Chapter, Child, Parent, Picture, Widget,
- DooHickey, Grommet, Whatsit, FancyDoodad, Category, Link,
- PrePopulatedPost, PrePopulatedSubPost, CustomArticle, Section,
- ModelWithStringPrimaryKey, Color, Thing, Actor, Inquisition, Sketch,
- Person, Persona, FooAccount, BarAccount, Subscriber, ExternalSubscriber,
- OldSubscriber, Podcast, Vodcast, EmptyModel, Fabric, Gallery, Language,
- Recommendation, Recommender, Collector, Post, Gadget, Villain,
- SuperVillain, Plot, PlotDetails, CyclicOne, CyclicTwo, WorkHour,
- Reservation, FoodDelivery, RowLevelChangePermissionModel, Paper,
- CoverLetter, Story, OtherStory, Book, Promo, ChapterXtra1, Pizza, Topping,
- Album, Question, Answer, ComplexSortedPerson, PluggableSearchPerson,
- PrePopulatedPostLargeSlug, AdminOrderedField, AdminOrderedModelMethod,
- AdminOrderedAdminMethod, AdminOrderedCallable, Report, Color2,
- UnorderedObject, MainPrepopulated, RelatedPrepopulated, UndeletableObject,
- UnchangeableObject, UserMessenger, Simple, Choice, ShortMessage, Telegram,
- FilteredManager, EmptyModelHidden, EmptyModelVisible, EmptyModelMixin,
- State, City, Restaurant, Worker, ParentWithDependentChildren,
- DependentChild, StumpJoke, FieldOverridePost, FunkyTag,
- ReferencedByParent, ChildOfReferer, ReferencedByInline,
- InlineReference, InlineReferer, Recipe, Ingredient, NotReferenced,
- ExplicitlyProvidedPK, ImplicitlyGeneratedPK,
+ Actor, AdminOrderedAdminMethod, AdminOrderedCallable, AdminOrderedField,
+ AdminOrderedModelMethod, Album, Answer, Article, BarAccount, Book,
+ Category, Chapter, ChapterXtra1, Child, ChildOfReferer, Choice, City,
+ Collector, Color, Color2, ComplexSortedPerson, CoverLetter, CustomArticle,
+ CyclicOne, CyclicTwo, DependentChild, DooHickey, EmptyModel,
+ EmptyModelHidden, EmptyModelMixin, EmptyModelVisible, ExplicitlyProvidedPK,
+ ExternalSubscriber, Fabric, FancyDoodad, FieldOverridePost,
+ FilteredManager, FooAccount, FoodDelivery, FunkyTag, Gadget, Gallery,
+ Grommet, ImplicitlyGeneratedPK, Ingredient, InlineReference, InlineReferer,
+ Inquisition, Language, Link, MainPrepopulated, ModelWithStringPrimaryKey,
+ NotReferenced, OldSubscriber, OtherStory, Paper, Parent,
+ ParentWithDependentChildren, Person, Persona, Picture, Pizza, Plot,
+ PlotDetails, PluggableSearchPerson, Podcast, Post, PrePopulatedPost,
+ PrePopulatedPostLargeSlug, PrePopulatedSubPost, Promo, Question, Recipe,
+ Recommendation, Recommender, ReferencedByInline, ReferencedByParent,
+ RelatedPrepopulated, Report, Reservation, Restaurant,
+ RowLevelChangePermissionModel, Section, ShortMessage, Simple, Sketch,
+ State, Story, StumpJoke, Subscriber, SuperVillain, Telegram, Thing,
+ Topping, UnchangeableObject, UndeletableObject, UnorderedObject,
+ UserMessenger, Villain, Vodcast, Whatsit, Widget, Worker, WorkHour,
)
@@ -969,8 +970,6 @@ site.register(ExplicitlyProvidedPK, GetFormsetsArgumentCheckingAdmin)
site.register(ImplicitlyGeneratedPK, GetFormsetsArgumentCheckingAdmin)
# Register core models we need in our tests
-from django.contrib.auth.models import User, Group
-from django.contrib.auth.admin import UserAdmin, GroupAdmin
site.register(User, UserAdmin)
site.register(Group, GroupAdmin)
diff --git a/tests/admin_views/custom_has_permission_admin.py b/tests/admin_views/custom_has_permission_admin.py
index 6c15a9805a..a578895b5a 100644
--- a/tests/admin_views/custom_has_permission_admin.py
+++ b/tests/admin_views/custom_has_permission_admin.py
@@ -7,7 +7,7 @@ from django.contrib import admin
from django.contrib.auth import get_permission_codename
from django.contrib.auth.forms import AuthenticationForm
-from . import models, admin as base_admin
+from . import admin as base_admin, models
PERMISSION_NAME = 'admin_views.%s' % get_permission_codename('change', models.Article._meta)
diff --git a/tests/admin_views/customadmin.py b/tests/admin_views/customadmin.py
index 3276a3091d..7941b7c897 100644
--- a/tests/admin_views/customadmin.py
+++ b/tests/admin_views/customadmin.py
@@ -5,11 +5,11 @@ from __future__ import unicode_literals
from django.conf.urls import url
from django.contrib import admin
-from django.http import HttpResponse
-from django.contrib.auth.models import User
from django.contrib.auth.admin import UserAdmin
+from django.contrib.auth.models import User
+from django.http import HttpResponse
-from . import models, forms, admin as base_admin
+from . import admin as base_admin, forms, models
class Admin2(admin.AdminSite):
diff --git a/tests/admin_views/models.py b/tests/admin_views/models.py
index 8a78514cec..c4d247d56c 100644
--- a/tests/admin_views/models.py
+++ b/tests/admin_views/models.py
@@ -2,12 +2,12 @@
from __future__ import unicode_literals
import datetime
-import tempfile
import os
+import tempfile
from django.contrib.auth.models import User
from django.contrib.contenttypes.fields import (
- GenericForeignKey, GenericRelation
+ GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.core.files.storage import FileSystemStorage
diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py
index de3861d551..7faa2d4e4f 100644
--- a/tests/admin_views/tests.py
+++ b/tests/admin_views/tests.py
@@ -1,61 +1,61 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
+import datetime
import os
import re
-import datetime
import unittest
-from django.core import mail
-from django.core.checks import Error
-from django.core.files import temp as tempfile
-from django.core.urlresolvers import (NoReverseMatch,
- get_script_prefix, resolve, reverse, set_script_prefix)
-# Register auth models with the admin.
-from django.contrib.auth import get_permission_codename
from django.contrib.admin import ModelAdmin
from django.contrib.admin.helpers import ACTION_CHECKBOX_NAME
-from django.contrib.admin.models import LogEntry, DELETION
+from django.contrib.admin.models import DELETION, LogEntry
from django.contrib.admin.options import TO_FIELD_VAR
from django.contrib.admin.templatetags.admin_static import static
from django.contrib.admin.templatetags.admin_urls import add_preserved_filters
from django.contrib.admin.tests import AdminSeleniumWebDriverTestCase
from django.contrib.admin.utils import quote
from django.contrib.admin.views.main import IS_POPUP_VAR
-from django.contrib.auth import REDIRECT_FIELD_NAME
-from django.contrib.auth.models import Group, User, Permission
+from django.contrib.auth import REDIRECT_FIELD_NAME, get_permission_codename
+from django.contrib.auth.models import Group, Permission, User
from django.contrib.contenttypes.models import ContentType
from django.contrib.staticfiles.storage import staticfiles_storage
+from django.core import mail
+from django.core.checks import Error
+from django.core.files import temp as tempfile
+from django.core.urlresolvers import (
+ NoReverseMatch, get_script_prefix, resolve, reverse, set_script_prefix,
+)
from django.forms.utils import ErrorList
from django.template.response import TemplateResponse
-from django.test import TestCase, skipUnlessDBFeature
+from django.test import (
+ TestCase, modify_settings, override_settings, skipUnlessDBFeature,
+)
from django.test.utils import patch_logger
-from django.test import modify_settings, override_settings
-from django.utils import formats
-from django.utils import translation
+from django.utils import formats, six, translation
+from django.utils._os import upath
from django.utils.cache import get_max_age
-from django.utils.encoding import iri_to_uri, force_bytes, force_text
+from django.utils.encoding import force_bytes, force_text, iri_to_uri
from django.utils.html import escape
from django.utils.http import urlencode
from django.utils.six.moves.urllib.parse import parse_qsl, urljoin, urlparse
-from django.utils._os import upath
-from django.utils import six
-
-# local test models
-from .models import (Article, BarAccount, CustomArticle, EmptyModel, FooAccount,
- Gallery, ModelWithStringPrimaryKey, Person, Persona, Picture, Podcast,
- Section, Subscriber, Vodcast, Language, Collector, Widget, Grommet,
- DooHickey, FancyDoodad, Whatsit, Category, Post, Plot, FunkyTag, Chapter,
- Book, Promo, WorkHour, Employee, Question, Answer, Inquisition, Actor,
- FoodDelivery, RowLevelChangePermissionModel, Paper, CoverLetter, Story,
- OtherStory, ComplexSortedPerson, PluggableSearchPerson, Parent, Child, AdminOrderedField,
- AdminOrderedModelMethod, AdminOrderedAdminMethod, AdminOrderedCallable,
- Report, MainPrepopulated, RelatedPrepopulated, UnorderedObject,
- Simple, UndeletableObject, UnchangeableObject, Choice, ShortMessage,
- Telegram, Pizza, Topping, FilteredManager, City, Restaurant, Worker,
- ParentWithDependentChildren, Character, FieldOverridePost, Color2)
+
from . import customadmin
-from .admin import site, site2, CityAdmin
+from .admin import CityAdmin, site, site2
+from .models import (
+ Actor, AdminOrderedAdminMethod, AdminOrderedCallable, AdminOrderedField,
+ AdminOrderedModelMethod, Answer, Article, BarAccount, Book, Category,
+ Chapter, Character, Child, Choice, City, Collector, Color2,
+ ComplexSortedPerson, CoverLetter, CustomArticle, DooHickey, Employee,
+ EmptyModel, FancyDoodad, FieldOverridePost, FilteredManager, FooAccount,
+ FoodDelivery, FunkyTag, Gallery, Grommet, Inquisition, Language,
+ MainPrepopulated, ModelWithStringPrimaryKey, OtherStory, Paper, Parent,
+ ParentWithDependentChildren, Person, Persona, Picture, Pizza, Plot,
+ PluggableSearchPerson, Podcast, Post, Promo, Question, RelatedPrepopulated,
+ Report, Restaurant, RowLevelChangePermissionModel, Section, ShortMessage,
+ Simple, Story, Subscriber, Telegram, Topping, UnchangeableObject,
+ UndeletableObject, UnorderedObject, Vodcast, Whatsit, Widget, Worker,
+ WorkHour,
+)
ERROR_MESSAGE = "Please enter the correct username and password \
diff --git a/tests/admin_views/urls.py b/tests/admin_views/urls.py
index 6c2442d520..17dc02d102 100644
--- a/tests/admin_views/urls.py
+++ b/tests/admin_views/urls.py
@@ -1,7 +1,6 @@
from django.conf.urls import include, url
-from . import views, customadmin, custom_has_permission_admin, admin
-
+from . import admin, custom_has_permission_admin, customadmin, views
urlpatterns = [
url(r'^test_admin/admin/doc/', include('django.contrib.admindocs.urls')),
diff --git a/tests/admin_widgets/models.py b/tests/admin_widgets/models.py
index 5d65dcd174..5f990bdce3 100644
--- a/tests/admin_widgets/models.py
+++ b/tests/admin_widgets/models.py
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
-from django.db import models
from django.contrib.auth.models import User
+from django.db import models
from django.utils.encoding import python_2_unicode_compatible
diff --git a/tests/admin_widgets/tests.py b/tests/admin_widgets/tests.py
index 37ca50794c..8949aecd22 100644
--- a/tests/admin_widgets/tests.py
+++ b/tests/admin_widgets/tests.py
@@ -1,17 +1,12 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from datetime import datetime, timedelta
import gettext
-from importlib import import_module
import os
+from datetime import datetime, timedelta
+from importlib import import_module
from unittest import TestCase, skipIf
-try:
- import pytz
-except ImportError:
- pytz = None
-
from django import forms
from django.conf import settings
from django.contrib import admin
@@ -20,14 +15,16 @@ from django.contrib.admin.tests import AdminSeleniumWebDriverTestCase
from django.core.files.storage import default_storage
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db.models import CharField, DateField
-from django.test import TestCase as DjangoTestCase
-from django.test import override_settings
-from django.utils import six
-from django.utils import translation
+from django.test import TestCase as DjangoTestCase, override_settings
+from django.utils import six, translation
from . import models
from .widgetadmin import site as widget_admin_site
+try:
+ import pytz
+except ImportError:
+ pytz = None
admin_static_prefix = lambda: {
'ADMIN_STATIC_PREFIX': "%sadmin/" % settings.STATIC_URL,
diff --git a/tests/admin_widgets/urls.py b/tests/admin_widgets/urls.py
index 3b3e9b1488..7f4721c57e 100644
--- a/tests/admin_widgets/urls.py
+++ b/tests/admin_widgets/urls.py
@@ -2,7 +2,6 @@ from django.conf.urls import include, url
from . import widgetadmin
-
urlpatterns = [
url(r'^', include(widgetadmin.site.urls)),
]
diff --git a/tests/aggregation/tests.py b/tests/aggregation/tests.py
index 7e500dfb0e..9282c7e10c 100644
--- a/tests/aggregation/tests.py
+++ b/tests/aggregation/tests.py
@@ -1,22 +1,21 @@
from __future__ import unicode_literals
import datetime
-from decimal import Decimal
import re
+from decimal import Decimal
from django.core.exceptions import FieldError
from django.db import connection
from django.db.models import (
- Avg, Sum, Count, Max, Min,
- Aggregate, F, Value, Func,
- IntegerField, FloatField, DecimalField)
+ F, Aggregate, Avg, Count, DecimalField, FloatField, Func, IntegerField,
+ Max, Min, Sum, Value,
+)
from django.test import TestCase, ignore_warnings
-from django.test.utils import Approximate
-from django.test.utils import CaptureQueriesContext
+from django.test.utils import Approximate, CaptureQueriesContext
from django.utils import six, timezone
from django.utils.deprecation import RemovedInDjango20Warning
-from .models import Author, Publisher, Book, Store
+from .models import Author, Book, Publisher, Store
class BaseAggregateTestCase(TestCase):
diff --git a/tests/aggregation_regress/models.py b/tests/aggregation_regress/models.py
index e8714668ba..2cad0a5486 100644
--- a/tests/aggregation_regress/models.py
+++ b/tests/aggregation_regress/models.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
from django.contrib.contenttypes.fields import (
- GenericForeignKey, GenericRelation
+ GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
diff --git a/tests/aggregation_regress/tests.py b/tests/aggregation_regress/tests.py
index e7a457fb58..530f2e7894 100644
--- a/tests/aggregation_regress/tests.py
+++ b/tests/aggregation_regress/tests.py
@@ -5,15 +5,17 @@ import pickle
from decimal import Decimal
from operator import attrgetter
-from django.core.exceptions import FieldError
from django.contrib.contenttypes.models import ContentType
-from django.db.models import Count, Max, Avg, Sum, StdDev, Variance, F, Q
+from django.core.exceptions import FieldError
+from django.db.models import F, Q, Avg, Count, Max, StdDev, Sum, Variance
from django.test import TestCase, skipUnlessDBFeature
from django.test.utils import Approximate
from django.utils import six
-from .models import (Author, Book, Publisher, Clues, Entries, HardbackBook,
- ItemTag, WithManualPK, Alfa, Bravo, Charlie)
+from .models import (
+ Alfa, Author, Book, Bravo, Charlie, Clues, Entries, HardbackBook, ItemTag,
+ Publisher, WithManualPK,
+)
class AggregationTests(TestCase):
diff --git a/tests/annotations/tests.py b/tests/annotations/tests.py
index 90a9c13048..2bf441716b 100644
--- a/tests/annotations/tests.py
+++ b/tests/annotations/tests.py
@@ -1,16 +1,16 @@
from __future__ import unicode_literals
+
import datetime
from decimal import Decimal
from django.core.exceptions import FieldDoesNotExist, FieldError
from django.db.models import (
- Sum, Count,
- F, Value, Func,
- IntegerField, BooleanField, CharField)
+ F, BooleanField, CharField, Count, Func, IntegerField, Sum, Value,
+)
from django.test import TestCase
from django.utils import six
-from .models import Author, Book, Store, DepartmentStore, Company, Employee
+from .models import Author, Book, Company, DepartmentStore, Employee, Store
def cxOracle_513_py3_bug(func):
diff --git a/tests/app_loading/tests.py b/tests/app_loading/tests.py
index 71f1a49b63..d9bead4d61 100644
--- a/tests/app_loading/tests.py
+++ b/tests/app_loading/tests.py
@@ -5,8 +5,8 @@ import os
from django.apps import apps
from django.test import TestCase
from django.test.utils import extend_sys_path
-from django.utils._os import upath
from django.utils import six
+from django.utils._os import upath
class EggLoadingTest(TestCase):
diff --git a/tests/apps/models.py b/tests/apps/models.py
index d6907eced1..733be35d2e 100644
--- a/tests/apps/models.py
+++ b/tests/apps/models.py
@@ -3,7 +3,6 @@ from __future__ import unicode_literals
from django.apps.registry import Apps
from django.db import models
-
# We're testing app registry presence on load, so this is handy.
new_apps = Apps(['apps'])
diff --git a/tests/apps/tests.py b/tests/apps/tests.py
index b7652ed355..5e23ddb9d1 100644
--- a/tests/apps/tests.py
+++ b/tests/apps/tests.py
@@ -2,22 +2,21 @@ from __future__ import unicode_literals
import os
import sys
-from unittest import skipUnless
import warnings
+from unittest import skipUnless
-from django.apps import apps, AppConfig
+from django.apps import AppConfig, apps
from django.apps.registry import Apps
from django.contrib.admin.models import LogEntry
from django.core.exceptions import ImproperlyConfigured
from django.db import models
from django.test import TestCase, override_settings
from django.test.utils import extend_sys_path
-from django.utils._os import upath
from django.utils import six
+from django.utils._os import upath
from .default_config_app.apps import CustomConfig
-from .models import TotallyNormal, SoAlternative, new_apps
-
+from .models import SoAlternative, TotallyNormal, new_apps
# Small list with a variety of cases for tests that iterate on installed apps.
# Intentionally not in alphabetical order to check if the order is preserved.
diff --git a/tests/backends/models.py b/tests/backends/models.py
index b550212d0b..d69416962d 100644
--- a/tests/backends/models.py
+++ b/tests/backends/models.py
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
from django.contrib.contenttypes.fields import (
- GenericForeignKey, GenericRelation
+ GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
diff --git a/tests/backends/tests.py b/tests/backends/tests.py
index 05ffb288d0..a9f8f26618 100644
--- a/tests/backends/tests.py
+++ b/tests/backends/tests.py
@@ -4,26 +4,30 @@ from __future__ import unicode_literals
import copy
import datetime
-from decimal import Decimal, Rounded
import re
import threading
import unittest
import warnings
+from decimal import Decimal, Rounded
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.management.color import no_style
-from django.db import (connection, connections, DEFAULT_DB_ALIAS,
- DatabaseError, IntegrityError, reset_queries, transaction)
+from django.db import (
+ DEFAULT_DB_ALIAS, DatabaseError, IntegrityError, connection, connections,
+ reset_queries, transaction,
+)
from django.db.backends.base.base import BaseDatabaseWrapper
-from django.db.backends.signals import connection_created
from django.db.backends.postgresql_psycopg2 import version as pg_version
-from django.db.backends.utils import format_number, CursorWrapper
-from django.db.models import Sum, Avg, Variance, StdDev
+from django.db.backends.signals import connection_created
+from django.db.backends.utils import CursorWrapper, format_number
+from django.db.models import Avg, StdDev, Sum, Variance
from django.db.models.sql.constants import CURSOR
from django.db.utils import ConnectionHandler
-from django.test import (TestCase, TransactionTestCase, mock, override_settings,
- skipUnlessDBFeature, skipIfDBFeature)
+from django.test import (
+ TestCase, TransactionTestCase, mock, override_settings, skipIfDBFeature,
+ skipUnlessDBFeature,
+)
from django.test.utils import str_prefix
from django.utils import six
from django.utils.six.moves import range
diff --git a/tests/basic/tests.py b/tests/basic/tests.py
index ad21b2b1c1..d851d858de 100644
--- a/tests/basic/tests.py
+++ b/tests/basic/tests.py
@@ -1,21 +1,22 @@
from __future__ import unicode_literals
-from datetime import datetime, timedelta
import threading
import warnings
+from datetime import datetime, timedelta
-from django.core.exceptions import ObjectDoesNotExist, MultipleObjectsReturned
-from django.db import connections, DEFAULT_DB_ALIAS
-from django.db import DatabaseError
+from django.core.exceptions import MultipleObjectsReturned, ObjectDoesNotExist
+from django.db import DEFAULT_DB_ALIAS, DatabaseError, connections
from django.db.models.fields import Field
from django.db.models.fields.related import ForeignObjectRel
from django.db.models.manager import BaseManager
-from django.db.models.query import QuerySet, EmptyQuerySet
-from django.test import TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature
+from django.db.models.query import EmptyQuerySet, QuerySet
+from django.test import (
+ TestCase, TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature,
+)
from django.utils import six
from django.utils.translation import ugettext_lazy
-from .models import Article, SelfRef, ArticleSelectOnSave
+from .models import Article, ArticleSelectOnSave, SelfRef
class ModelInstanceCreationTests(TestCase):
diff --git a/tests/builtin_server/tests.py b/tests/builtin_server/tests.py
index 2bfdfac66b..e1f3e5d71d 100644
--- a/tests/builtin_server/tests.py
+++ b/tests/builtin_server/tests.py
@@ -1,12 +1,11 @@
from __future__ import unicode_literals
-from io import BytesIO
import sys
import traceback
+from io import BytesIO
from unittest import TestCase
from wsgiref import simple_server
-
# If data is too large, socket will choke, so write chunks no larger than 32MB
# at a time. The rationale behind the 32MB can be found on Django's Trac:
# https://code.djangoproject.com/ticket/5596#comment:4
diff --git a/tests/bulk_create/tests.py b/tests/bulk_create/tests.py
index 742e52fec8..924e69e0a5 100644
--- a/tests/bulk_create/tests.py
+++ b/tests/bulk_create/tests.py
@@ -3,10 +3,11 @@ from __future__ import unicode_literals
from operator import attrgetter
from django.db import connection
-from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
-from django.test import override_settings
+from django.test import (
+ TestCase, override_settings, skipIfDBFeature, skipUnlessDBFeature,
+)
-from .models import Country, Restaurant, Pizzeria, State, TwoFields
+from .models import Country, Pizzeria, Restaurant, State, TwoFields
class BulkCreateTests(TestCase):
diff --git a/tests/cache/models.py b/tests/cache/models.py
index 4fccbb664b..349fd87473 100644
--- a/tests/cache/models.py
+++ b/tests/cache/models.py
@@ -1,6 +1,5 @@
-from django.utils import timezone
-
from django.db import models
+from django.utils import timezone
def expensive_calculation():
diff --git a/tests/cache/tests.py b/tests/cache/tests.py
index c17ef12ae0..c6e76c417c 100644
--- a/tests/cache/tests.py
+++ b/tests/cache/tests.py
@@ -4,9 +4,9 @@
# Uses whatever cache backend is set in the test settings file.
from __future__ import unicode_literals
+import copy
import os
import re
-import copy
import shutil
import tempfile
import threading
@@ -15,36 +15,39 @@ import unittest
import warnings
from django.conf import settings
-from django.core import management
-from django.core import signals
-from django.core.cache import cache, caches, CacheKeyWarning, DEFAULT_CACHE_ALIAS
-from django.db import connection, connections, transaction
+from django.core import management, signals
+from django.core.cache import (
+ DEFAULT_CACHE_ALIAS, CacheKeyWarning, cache, caches,
+)
from django.core.cache.utils import make_template_fragment_key
+from django.db import connection, connections, transaction
from django.http import HttpRequest, HttpResponse, StreamingHttpResponse
-from django.middleware.cache import (FetchFromCacheMiddleware,
- UpdateCacheMiddleware, CacheMiddleware)
+from django.middleware.cache import (
+ CacheMiddleware, FetchFromCacheMiddleware, UpdateCacheMiddleware,
+)
from django.middleware.csrf import CsrfViewMiddleware
from django.template import engines
from django.template.context_processors import csrf
from django.template.response import TemplateResponse
-from django.test import (TestCase, TransactionTestCase, RequestFactory,
- override_settings)
+from django.test import (
+ RequestFactory, TestCase, TransactionTestCase, override_settings,
+)
from django.test.signals import setting_changed
-from django.utils import six
-from django.utils import timezone
-from django.utils import translation
-from django.utils.cache import (patch_vary_headers, get_cache_key,
- learn_cache_key, patch_cache_control, patch_response_headers)
+from django.utils import six, timezone, translation
+from django.utils.cache import (
+ get_cache_key, learn_cache_key, patch_cache_control,
+ patch_response_headers, patch_vary_headers,
+)
from django.utils.encoding import force_text
from django.views.decorators.cache import cache_page
+from .models import Poll, expensive_calculation
+
try: # Use the same idiom as in cache backends
from django.utils.six.moves import cPickle as pickle
except ImportError:
import pickle
-from .models import Poll, expensive_calculation
-
# functions/classes for complex data type tests
def f():
diff --git a/tests/check_framework/test_model_field_deprecation.py b/tests/check_framework/test_model_field_deprecation.py
index a8a987b4cb..ce30803a61 100644
--- a/tests/check_framework/test_model_field_deprecation.py
+++ b/tests/check_framework/test_model_field_deprecation.py
@@ -1,5 +1,5 @@
-from django.db import models
from django.core import checks
+from django.db import models
from django.test import SimpleTestCase
from .tests import IsolateModelsMixin
diff --git a/tests/check_framework/test_security.py b/tests/check_framework/test_security.py
index 4a72e60029..c62d96f68c 100644
--- a/tests/check_framework/test_security.py
+++ b/tests/check_framework/test_security.py
@@ -1,11 +1,8 @@
from django.conf import settings
+from django.core.checks.security import base, csrf, sessions
from django.test import TestCase
from django.test.utils import override_settings
-from django.core.checks.security import base
-from django.core.checks.security import csrf
-from django.core.checks.security import sessions
-
class CheckSessionCookieSecureTest(TestCase):
@property
diff --git a/tests/check_framework/tests.py b/tests/check_framework/tests.py
index d15988b117..167d0087ee 100644
--- a/tests/check_framework/tests.py
+++ b/tests/check_framework/tests.py
@@ -1,21 +1,22 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.utils.six import StringIO
import sys
from django.apps import apps
from django.conf import settings
from django.core import checks
from django.core.checks import Error, Warning
+from django.core.checks.compatibility.django_1_7_0 import \
+ check_1_7_compatibility
from django.core.checks.registry import CheckRegistry
-from django.core.checks.compatibility.django_1_7_0 import check_1_7_compatibility
-from django.core.management.base import CommandError
from django.core.management import call_command
+from django.core.management.base import CommandError
from django.db import models
from django.test import TestCase
from django.test.utils import override_settings, override_system_checks
from django.utils.encoding import force_text
+from django.utils.six import StringIO
from .models import SimpleModel
diff --git a/tests/choices/models.py b/tests/choices/models.py
index e33d45733a..3384947f93 100644
--- a/tests/choices/models.py
+++ b/tests/choices/models.py
@@ -12,7 +12,6 @@ field. This method returns the "human-readable" value of the field.
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
-
GENDER_CHOICES = (
('M', 'Male'),
('F', 'Female'),
diff --git a/tests/conditional_processing/tests.py b/tests/conditional_processing/tests.py
index f679996efd..7cbe378be8 100644
--- a/tests/conditional_processing/tests.py
+++ b/tests/conditional_processing/tests.py
@@ -5,7 +5,6 @@ from datetime import datetime
from django.test import TestCase, override_settings
-
FULL_RESPONSE = 'Test conditional get response'
LAST_MODIFIED = datetime(2007, 10, 21, 23, 21, 47)
LAST_MODIFIED_STR = 'Sun, 21 Oct 2007 23:21:47 GMT'
diff --git a/tests/conditional_processing/urls.py b/tests/conditional_processing/urls.py
index 0ae4a6868b..2492a950a4 100644
--- a/tests/conditional_processing/urls.py
+++ b/tests/conditional_processing/urls.py
@@ -2,7 +2,6 @@ from django.conf.urls import url
from . import views
-
urlpatterns = [
url('^condition/$', views.index),
url('^condition/last_modified/$', views.last_modified_view1),
diff --git a/tests/conditional_processing/views.py b/tests/conditional_processing/views.py
index 496e79fd34..3542d2bfc1 100644
--- a/tests/conditional_processing/views.py
+++ b/tests/conditional_processing/views.py
@@ -1,7 +1,7 @@
-from django.views.decorators.http import condition, etag, last_modified
from django.http import HttpResponse
+from django.views.decorators.http import condition, etag, last_modified
-from .tests import FULL_RESPONSE, LAST_MODIFIED, ETAG
+from .tests import ETAG, FULL_RESPONSE, LAST_MODIFIED
def index(request):
diff --git a/tests/contenttypes_tests/tests.py b/tests/contenttypes_tests/tests.py
index be727c4a96..a791f8df3c 100644
--- a/tests/contenttypes_tests/tests.py
+++ b/tests/contenttypes_tests/tests.py
@@ -2,10 +2,10 @@
from __future__ import unicode_literals
from django.apps.registry import Apps, apps
+from django.contrib.contenttypes import management
from django.contrib.contenttypes.fields import (
- GenericForeignKey, GenericRelation
+ GenericForeignKey, GenericRelation,
)
-from django.contrib.contenttypes import management
from django.contrib.contenttypes.models import ContentType
from django.core import checks
from django.db import connections, models
@@ -13,7 +13,7 @@ from django.test import TestCase, override_settings
from django.test.utils import captured_stdout
from django.utils.encoding import force_str, force_text
-from .models import Author, Article, SchemeIncludedURL
+from .models import Article, Author, SchemeIncludedURL
@override_settings(ROOT_URLCONF='contenttypes_tests.urls')
diff --git a/tests/context_processors/urls.py b/tests/context_processors/urls.py
index f68720d581..ac887f6613 100644
--- a/tests/context_processors/urls.py
+++ b/tests/context_processors/urls.py
@@ -2,7 +2,6 @@ from django.conf.urls import url
from . import views
-
urlpatterns = [
url(r'^request_attrs/$', views.request_processor),
url(r'^debug/$', views.debug_processor),
diff --git a/tests/csrf_tests/tests.py b/tests/csrf_tests/tests.py
index 29d93389f3..21caacc1d9 100644
--- a/tests/csrf_tests/tests.py
+++ b/tests/csrf_tests/tests.py
@@ -1,14 +1,17 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
+
import logging
from django.conf import settings
from django.http import HttpRequest, HttpResponse
-from django.middleware.csrf import CsrfViewMiddleware, CSRF_KEY_LENGTH
+from django.middleware.csrf import CSRF_KEY_LENGTH, CsrfViewMiddleware
from django.template import RequestContext, Template
from django.template.context_processors import csrf
from django.test import TestCase, override_settings
-from django.views.decorators.csrf import csrf_exempt, requires_csrf_token, ensure_csrf_cookie
+from django.views.decorators.csrf import (
+ csrf_exempt, ensure_csrf_cookie, requires_csrf_token,
+)
# Response/views used for CsrfResponseMiddleware and CsrfViewMiddleware tests
diff --git a/tests/custom_columns/tests.py b/tests/custom_columns/tests.py
index fab77847b0..b258aea710 100644
--- a/tests/custom_columns/tests.py
+++ b/tests/custom_columns/tests.py
@@ -4,7 +4,7 @@ from django.core.exceptions import FieldError
from django.test import TestCase
from django.utils import six
-from .models import Author, Article
+from .models import Article, Author
class CustomColumnsTests(TestCase):
diff --git a/tests/custom_lookups/tests.py b/tests/custom_lookups/tests.py
index 945c33a0ec..1b45be8451 100644
--- a/tests/custom_lookups/tests.py
+++ b/tests/custom_lookups/tests.py
@@ -1,14 +1,14 @@
from __future__ import unicode_literals
-from datetime import date, datetime
import time
import unittest
+from datetime import date, datetime
from django.core.exceptions import FieldError
-from django.db import models
-from django.db import connection
+from django.db import connection, models
from django.test import TestCase, override_settings
from django.utils import timezone
+
from .models import Author, MySQLUnixTimestamp
diff --git a/tests/custom_managers/models.py b/tests/custom_managers/models.py
index d4ca730629..0444d40f58 100644
--- a/tests/custom_managers/models.py
+++ b/tests/custom_managers/models.py
@@ -11,7 +11,9 @@ returns.
from __future__ import unicode_literals
-from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
+from django.contrib.contenttypes.fields import (
+ GenericForeignKey, GenericRelation,
+)
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
diff --git a/tests/custom_managers/tests.py b/tests/custom_managers/tests.py
index c115482802..7dc5552e41 100644
--- a/tests/custom_managers/tests.py
+++ b/tests/custom_managers/tests.py
@@ -4,9 +4,11 @@ from django.db import models
from django.test import TestCase
from django.utils import six
-from .models import (Book, Car, CustomManager, CustomQuerySet,
- DeconstructibleCustomManager, FunPerson, OneToOneRestrictedModel, Person,
- PersonManager, PublishedBookManager, RelatedModel, RestrictedModel)
+from .models import (
+ Book, Car, CustomManager, CustomQuerySet, DeconstructibleCustomManager,
+ FunPerson, OneToOneRestrictedModel, Person, PersonManager,
+ PublishedBookManager, RelatedModel, RestrictedModel,
+)
class CustomManagerTests(TestCase):
diff --git a/tests/custom_pk/models.py b/tests/custom_pk/models.py
index f4ecc874ee..eb9f86b064 100644
--- a/tests/custom_pk/models.py
+++ b/tests/custom_pk/models.py
@@ -9,9 +9,9 @@ this behavior by explicitly adding ``primary_key=True`` to a field.
from __future__ import unicode_literals
from django.db import models
+from django.utils.encoding import python_2_unicode_compatible
from .fields import MyAutoField
-from django.utils.encoding import python_2_unicode_compatible
@python_2_unicode_compatible
diff --git a/tests/custom_pk/tests.py b/tests/custom_pk/tests.py
index e3133774e6..9ba506d953 100644
--- a/tests/custom_pk/tests.py
+++ b/tests/custom_pk/tests.py
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import transaction, IntegrityError
+from django.db import IntegrityError, transaction
from django.test import TestCase, skipIfDBFeature
from django.utils import six
-from .models import Employee, Business, Bar, Foo
+from .models import Bar, Business, Employee, Foo
class BasicCustomPKTests(TestCase):
diff --git a/tests/dates/tests.py b/tests/dates/tests.py
index cc6a571d0d..c0f399b091 100644
--- a/tests/dates/tests.py
+++ b/tests/dates/tests.py
@@ -6,7 +6,7 @@ from django.core.exceptions import FieldError
from django.test import TestCase
from django.utils import six
-from .models import Article, Comment, Category
+from .models import Article, Category, Comment
class DatesTests(TestCase):
diff --git a/tests/datetimes/tests.py b/tests/datetimes/tests.py
index 776f6ecc33..447cbef99a 100644
--- a/tests/datetimes/tests.py
+++ b/tests/datetimes/tests.py
@@ -3,16 +3,15 @@ from __future__ import unicode_literals
import datetime
from unittest import skipIf
-try:
- import pytz
-except ImportError:
- pytz = None
-
from django.test import TestCase, override_settings
from django.utils import timezone
+from .models import Article, Category, Comment
-from .models import Article, Comment, Category
+try:
+ import pytz
+except ImportError:
+ pytz = None
class DateTimesTests(TestCase):
diff --git a/tests/db_functions/tests.py b/tests/db_functions/tests.py
index 97d32d86e7..9e7d27899a 100644
--- a/tests/db_functions/tests.py
+++ b/tests/db_functions/tests.py
@@ -1,13 +1,13 @@
from __future__ import unicode_literals
-from django.db.models import TextField, CharField, Value as V
+from django.db.models import CharField, TextField, Value as V
from django.db.models.functions import (
- Coalesce, Concat, Lower, Upper, Length, Substr,
+ Coalesce, Concat, Length, Lower, Substr, Upper,
)
from django.test import TestCase
from django.utils import six, timezone
-from .models import Author, Article
+from .models import Article, Author
lorem_ipsum = """
diff --git a/tests/db_typecasts/tests.py b/tests/db_typecasts/tests.py
index e391743028..d0e0db20d7 100644
--- a/tests/db_typecasts/tests.py
+++ b/tests/db_typecasts/tests.py
@@ -6,7 +6,6 @@ import unittest
from django.db.backends import utils as typecasts
from django.utils import six
-
TEST_CASES = {
'typecast_date': (
('', None),
diff --git a/tests/decorators/tests.py b/tests/decorators/tests.py
index 30423e7c80..d3e2eddf8c 100644
--- a/tests/decorators/tests.py
+++ b/tests/decorators/tests.py
@@ -1,16 +1,24 @@
-from functools import wraps, update_wrapper
+from functools import update_wrapper, wraps
from unittest import TestCase
from django.contrib.admin.views.decorators import staff_member_required
-from django.contrib.auth.decorators import login_required, permission_required, user_passes_test
-from django.http import HttpResponse, HttpRequest, HttpResponseNotAllowed
+from django.contrib.auth.decorators import (
+ login_required, permission_required, user_passes_test,
+)
+from django.http import HttpRequest, HttpResponse, HttpResponseNotAllowed
from django.middleware.clickjacking import XFrameOptionsMiddleware
from django.utils.decorators import method_decorator
from django.utils.functional import allow_lazy, lazy
-from django.views.decorators.cache import cache_page, never_cache, cache_control
-from django.views.decorators.clickjacking import xframe_options_deny, xframe_options_sameorigin, xframe_options_exempt
-from django.views.decorators.http import require_http_methods, require_GET, require_POST, require_safe, condition
-from django.views.decorators.vary import vary_on_headers, vary_on_cookie
+from django.views.decorators.cache import (
+ cache_control, cache_page, never_cache,
+)
+from django.views.decorators.clickjacking import (
+ xframe_options_deny, xframe_options_exempt, xframe_options_sameorigin,
+)
+from django.views.decorators.http import (
+ condition, require_GET, require_http_methods, require_POST, require_safe,
+)
+from django.views.decorators.vary import vary_on_cookie, vary_on_headers
def fully_decorated(request):
diff --git a/tests/defer/tests.py b/tests/defer/tests.py
index 8471976173..81f00df12b 100644
--- a/tests/defer/tests.py
+++ b/tests/defer/tests.py
@@ -3,7 +3,9 @@ from __future__ import unicode_literals
from django.db.models.query_utils import DeferredAttribute, InvalidQuery
from django.test import TestCase
-from .models import Secondary, Primary, Child, BigChild, ChildProxy, RefreshPrimaryProxy
+from .models import (
+ BigChild, Child, ChildProxy, Primary, RefreshPrimaryProxy, Secondary,
+)
class AssertionMixin(object):
diff --git a/tests/defer_regress/tests.py b/tests/defer_regress/tests.py
index 87638bb99d..6c66a415df 100644
--- a/tests/defer_regress/tests.py
+++ b/tests/defer_regress/tests.py
@@ -6,13 +6,15 @@ from django.apps import apps
from django.contrib.contenttypes.models import ContentType
from django.contrib.sessions.backends.db import SessionStore
from django.db.models import Count
-from django.db.models.query_utils import deferred_class_factory, DeferredAttribute
+from django.db.models.query_utils import (
+ DeferredAttribute, deferred_class_factory,
+)
from django.test import TestCase, override_settings
from .models import (
- ResolveThis, Item, RelatedItem, Child, Leaf, Proxy, SimpleItem, Feature,
- ItemAndSimpleItem, OneToOneItem, SpecialFeature, Location, Request,
- ProxyRelated, Derived, Base,
+ Base, Child, Derived, Feature, Item, ItemAndSimpleItem, Leaf, Location,
+ OneToOneItem, Proxy, ProxyRelated, RelatedItem, Request, ResolveThis,
+ SimpleItem, SpecialFeature,
)
diff --git a/tests/delete/tests.py b/tests/delete/tests.py
index c04284e069..24d5aeabea 100644
--- a/tests/delete/tests.py
+++ b/tests/delete/tests.py
@@ -2,14 +2,15 @@ from __future__ import unicode_literals
from math import ceil
-from django.db import models, IntegrityError, connection
+from django.db import IntegrityError, connection, models
from django.db.models.sql.constants import GET_ITERATOR_CHUNK_SIZE
-from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature
+from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from django.utils.six.moves import range
-from .models import (R, RChild, S, T, A, M, MR, MRNull,
- create_a, get_default_r, User, Avatar, HiddenUser, HiddenUserProfile,
- M2MTo, M2MFrom, Parent, Child, Base)
+from .models import (
+ A, M, MR, R, S, T, Avatar, Base, Child, HiddenUser, HiddenUserProfile,
+ M2MFrom, M2MTo, MRNull, Parent, RChild, User, create_a, get_default_r,
+)
class OnDeleteTests(TestCase):
diff --git a/tests/delete_regress/models.py b/tests/delete_regress/models.py
index 6afe84146c..c3ecdac7bf 100644
--- a/tests/delete_regress/models.py
+++ b/tests/delete_regress/models.py
@@ -1,5 +1,5 @@
from django.contrib.contenttypes.fields import (
- GenericForeignKey, GenericRelation
+ GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
diff --git a/tests/delete_regress/tests.py b/tests/delete_regress/tests.py
index abfa248aea..d03ce3771f 100644
--- a/tests/delete_regress/tests.py
+++ b/tests/delete_regress/tests.py
@@ -3,14 +3,16 @@ from __future__ import unicode_literals
import datetime
from django.conf import settings
-from django.db import transaction, DEFAULT_DB_ALIAS, models
+from django.db import DEFAULT_DB_ALIAS, models, transaction
from django.db.utils import ConnectionHandler
from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
-from .models import (Book, Award, AwardNote, Person, Child, Toy, PlayedWith,
- PlayedWithNote, Email, Researcher, Food, Eaten, Policy, Version, Location,
- Item, Image, File, Photo, FooFile, FooImage, FooPhoto, FooFileProxy, Login,
- OrgUnit, OrderedPerson, House)
+from .models import (
+ Award, AwardNote, Book, Child, Eaten, Email, File, Food, FooFile,
+ FooFileProxy, FooImage, FooPhoto, House, Image, Item, Location, Login,
+ OrderedPerson, OrgUnit, Person, Photo, PlayedWith, PlayedWithNote, Policy,
+ Researcher, Toy, Version,
+)
# Can't run this test under SQLite, because you can't
diff --git a/tests/dispatch/tests.py b/tests/dispatch/tests.py
index 14aa4a66bd..1860ca0614 100644
--- a/tests/dispatch/tests.py
+++ b/tests/dispatch/tests.py
@@ -7,7 +7,6 @@ from types import TracebackType
from django.dispatch import Signal, receiver
-
if sys.platform.startswith('java'):
def garbage_collect():
# Some JVM GCs will execute finalizers in a different thread, meaning
diff --git a/tests/distinct_on_fields/tests.py b/tests/distinct_on_fields/tests.py
index 3e6e6c2358..68290d7b8f 100644
--- a/tests/distinct_on_fields/tests.py
+++ b/tests/distinct_on_fields/tests.py
@@ -4,7 +4,7 @@ from django.db.models import Max
from django.test import TestCase, skipUnlessDBFeature
from django.test.utils import str_prefix
-from .models import Tag, Celebrity, Fan, Staff, StaffTag
+from .models import Celebrity, Fan, Staff, StaffTag, Tag
@skipUnlessDBFeature('can_distinct_on_fields')
diff --git a/tests/expressions/tests.py b/tests/expressions/tests.py
index cce1253e3f..7233fa0d08 100644
--- a/tests/expressions/tests.py
+++ b/tests/expressions/tests.py
@@ -1,24 +1,28 @@
from __future__ import unicode_literals
-from copy import deepcopy
import datetime
import uuid
+from copy import deepcopy
from django.core.exceptions import FieldError
-from django.db import connection, transaction, DatabaseError
+from django.db import DatabaseError, connection, transaction
from django.db.models import TimeField, UUIDField
-from django.db.models.aggregates import Avg, Count, Max, Min, StdDev, Sum, Variance
+from django.db.models.aggregates import (
+ Avg, Count, Max, Min, StdDev, Sum, Variance,
+)
from django.db.models.expressions import (
- Case, Col, Date, DateTime, F, Func, OrderBy,
- Random, RawSQL, Ref, Value, When
+ F, Case, Col, Date, DateTime, Func, OrderBy, Random, RawSQL, Ref, Value,
+ When,
+)
+from django.db.models.functions import (
+ Coalesce, Concat, Length, Lower, Substr, Upper,
)
-from django.db.models.functions import Coalesce, Concat, Length, Lower, Substr, Upper
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
from django.test.utils import Approximate
from django.utils import six
from django.utils.timezone import utc
-from .models import Company, Employee, Number, Experiment, Time, UUID
+from .models import UUID, Company, Employee, Experiment, Number, Time
class BasicExpressionsTests(TestCase):
diff --git a/tests/expressions_case/tests.py b/tests/expressions_case/tests.py
index 0790b7b080..79fabeb8db 100644
--- a/tests/expressions_case/tests.py
+++ b/tests/expressions_case/tests.py
@@ -1,25 +1,25 @@
from __future__ import unicode_literals
+import unittest
from datetime import date, datetime, time, timedelta
from decimal import Decimal
from operator import attrgetter, itemgetter
-import unittest
from uuid import UUID
from django.core.exceptions import FieldError
from django.db import connection, models
-from django.db.models import F, Q, Value, Min, Max
+from django.db.models import F, Q, Max, Min, Value
from django.db.models.expressions import Case, When
from django.test import TestCase
from django.utils import six
+from .models import CaseTestModel, Client, FKCaseTestModel, O2OCaseTestModel
+
try:
from PIL import Image
except ImportError:
Image = None
-from .models import CaseTestModel, O2OCaseTestModel, FKCaseTestModel, Client
-
class CaseExpressionTests(TestCase):
@classmethod
diff --git a/tests/extra_regress/tests.py b/tests/extra_regress/tests.py
index 8749cb8ebf..aba6e326e1 100644
--- a/tests/extra_regress/tests.py
+++ b/tests/extra_regress/tests.py
@@ -1,12 +1,12 @@
from __future__ import unicode_literals
-from collections import OrderedDict
import datetime
+from collections import OrderedDict
from django.contrib.auth.models import User
from django.test import TestCase
-from .models import TestObject, Order, RevisionableModel
+from .models import Order, RevisionableModel, TestObject
class ExtraRegressTests(TestCase):
diff --git a/tests/field_subclassing/fields.py b/tests/field_subclassing/fields.py
index b94b2372c1..3bfdb5a89c 100644
--- a/tests/field_subclassing/fields.py
+++ b/tests/field_subclassing/fields.py
@@ -4,11 +4,9 @@ import json
import warnings
from django.db import models
-from django.utils.encoding import force_text
from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
-from django.utils.encoding import python_2_unicode_compatible
-
+from django.utils.encoding import force_text, python_2_unicode_compatible
# Catch warning about subfieldbase -- remove in Django 2.0
warnings.filterwarnings(
diff --git a/tests/field_subclassing/models.py b/tests/field_subclassing/models.py
index 66e765ac3e..7ff429c125 100644
--- a/tests/field_subclassing/models.py
+++ b/tests/field_subclassing/models.py
@@ -2,10 +2,9 @@
Tests for field subclassing.
"""
from django.db import models
-from django.utils.encoding import force_text
+from django.utils.encoding import force_text, python_2_unicode_compatible
-from .fields import Small, SmallField, SmallerField, JSONField
-from django.utils.encoding import python_2_unicode_compatible
+from .fields import JSONField, Small, SmallerField, SmallField
@python_2_unicode_compatible
diff --git a/tests/field_subclassing/tests.py b/tests/field_subclassing/tests.py
index 9e40d92496..4d3340260d 100644
--- a/tests/field_subclassing/tests.py
+++ b/tests/field_subclassing/tests.py
@@ -6,7 +6,7 @@ from django.core import exceptions, serializers
from django.db import connection
from django.test import TestCase
-from .fields import Small, CustomTypedField
+from .fields import CustomTypedField, Small
from .models import ChoicesModel, DataModel, MyModel, OtherModel
diff --git a/tests/file_storage/models.py b/tests/file_storage/models.py
index 2f58c53ddd..45a3d9f0e7 100644
--- a/tests/file_storage/models.py
+++ b/tests/file_storage/models.py
@@ -9,8 +9,8 @@ import os
import random
import tempfile
-from django.db import models
from django.core.files.storage import FileSystemStorage
+from django.db import models
class OldStyleFSStorage(FileSystemStorage):
diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py
index 2718f07cad..2c08a5312f 100644
--- a/tests/file_storage/tests.py
+++ b/tests/file_storage/tests.py
@@ -13,20 +13,19 @@ import warnings
from datetime import datetime, timedelta
from django.core.cache import cache
-from django.core.exceptions import SuspiciousOperation, SuspiciousFileOperation
-from django.core.files.base import File, ContentFile
+from django.core.exceptions import SuspiciousFileOperation, SuspiciousOperation
+from django.core.files.base import ContentFile, File
from django.core.files.storage import FileSystemStorage, get_storage_class
-from django.core.files.uploadedfile import (InMemoryUploadedFile, SimpleUploadedFile,
- TemporaryUploadedFile)
-from django.test import LiveServerTestCase, SimpleTestCase
-from django.test import override_settings
+from django.core.files.uploadedfile import (
+ InMemoryUploadedFile, SimpleUploadedFile, TemporaryUploadedFile,
+)
+from django.test import LiveServerTestCase, SimpleTestCase, override_settings
from django.utils import six
-from django.utils.six.moves.urllib.request import urlopen
from django.utils._os import upath
+from django.utils.six.moves.urllib.request import urlopen
from .models import Storage, temp_storage, temp_storage_location
-
FILE_SUFFIX_REGEX = '[A-Za-z0-9]{7}'
diff --git a/tests/file_storage/urls.py b/tests/file_storage/urls.py
index 7d50ef46b8..2bf659f6a8 100644
--- a/tests/file_storage/urls.py
+++ b/tests/file_storage/urls.py
@@ -1,7 +1,6 @@
from django.conf.urls import url
from django.http import HttpResponse
-
urlpatterns = [
url(r'^$', lambda req: HttpResponse('example view')),
]
diff --git a/tests/file_uploads/tests.py b/tests/file_uploads/tests.py
index 7036c199d0..e9cc9cd8b0 100644
--- a/tests/file_uploads/tests.py
+++ b/tests/file_uploads/tests.py
@@ -13,16 +13,14 @@ import unittest
from django.core.files import temp as tempfile
from django.core.files.uploadedfile import SimpleUploadedFile
from django.http.multipartparser import MultiPartParser, parse_header
-from django.test import TestCase, client
-from django.test import override_settings
+from django.test import TestCase, client, override_settings
from django.utils.encoding import force_bytes
from django.utils.http import urlquote
-from django.utils.six import BytesIO, PY2, StringIO
+from django.utils.six import PY2, BytesIO, StringIO
from . import uploadhandler
from .models import FileModel
-
UNICODE_FILENAME = 'test-0123456789_中文_Orléans.jpg'
MEDIA_ROOT = sys_tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])
UPLOAD_TO = os.path.join(MEDIA_ROOT, 'test_upload')
diff --git a/tests/file_uploads/urls.py b/tests/file_uploads/urls.py
index 99f0cd3eb5..504554483e 100644
--- a/tests/file_uploads/urls.py
+++ b/tests/file_uploads/urls.py
@@ -2,7 +2,6 @@ from django.conf.urls import url
from . import views
-
urlpatterns = [
url(r'^upload/$', views.file_upload_view),
url(r'^verify/$', views.file_upload_view_verify),
diff --git a/tests/file_uploads/views.py b/tests/file_uploads/views.py
index 2b00192e2e..5269e98da7 100644
--- a/tests/file_uploads/views.py
+++ b/tests/file_uploads/views.py
@@ -11,7 +11,7 @@ from django.utils.encoding import force_bytes, smart_str
from .models import FileModel
from .tests import UNICODE_FILENAME, UPLOAD_TO
-from .uploadhandler import QuotaUploadHandler, ErroringUploadHandler
+from .uploadhandler import ErroringUploadHandler, QuotaUploadHandler
def file_upload_view(request):
diff --git a/tests/files/tests.py b/tests/files/tests.py
index e16ebd0729..c72d948392 100644
--- a/tests/files/tests.py
+++ b/tests/files/tests.py
@@ -1,20 +1,20 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from io import BytesIO, StringIO
-import os
import gzip
+import os
import tempfile
import unittest
import zlib
+from io import BytesIO, StringIO
from django.core.files import File
-from django.core.files.move import file_move_safe
from django.core.files.base import ContentFile
-from django.core.files.uploadedfile import SimpleUploadedFile, UploadedFile
+from django.core.files.move import file_move_safe
from django.core.files.temp import NamedTemporaryFile
-from django.utils._os import upath
+from django.core.files.uploadedfile import SimpleUploadedFile, UploadedFile
from django.utils import six
+from django.utils._os import upath
try:
from PIL import Image
diff --git a/tests/fixtures/tests.py b/tests/fixtures/tests.py
index 109d98bec3..e81aea8f6f 100644
--- a/tests/fixtures/tests.py
+++ b/tests/fixtures/tests.py
@@ -6,10 +6,12 @@ import warnings
from django.apps import apps
from django.contrib.sites.models import Site
from django.core import management
-from django.db import connection, IntegrityError
-from django.test import TestCase, TransactionTestCase, ignore_warnings, skipUnlessDBFeature
-from django.utils.encoding import force_text
+from django.db import IntegrityError, connection
+from django.test import (
+ TestCase, TransactionTestCase, ignore_warnings, skipUnlessDBFeature,
+)
from django.utils import six
+from django.utils.encoding import force_text
from .models import Article, Spy, Tag, Visa
diff --git a/tests/fixtures_regress/tests.py b/tests/fixtures_regress/tests.py
index a91935af8f..63dbe9e72b 100644
--- a/tests/fixtures_regress/tests.py
+++ b/tests/fixtures_regress/tests.py
@@ -7,28 +7,29 @@ import os
import re
import warnings
-from django.core import serializers
+from django.core import management, serializers
from django.core.exceptions import ImproperlyConfigured
-from django.core.serializers.base import DeserializationError
-from django.core import management
from django.core.management.base import CommandError
-from django.db import transaction, IntegrityError
+from django.core.serializers.base import DeserializationError
+from django.db import IntegrityError, transaction
from django.db.models import signals
-from django.test import (TestCase, TransactionTestCase, skipIfDBFeature,
- skipUnlessDBFeature)
-from django.test import override_settings
-from django.utils._os import upath
+from django.test import (
+ TestCase, TransactionTestCase, override_settings, skipIfDBFeature,
+ skipUnlessDBFeature,
+)
from django.utils import six
+from django.utils._os import upath
from django.utils.six import PY3, StringIO
-from .models import (Animal, Stuff, Absolute, Parent, Child, Article, Widget,
- Store, Person, Book, NKChild, RefToNKChild, Circle1, Circle2, Circle3,
- ExternalDependency, Thingy,
- M2MSimpleA, M2MSimpleB, M2MSimpleCircularA, M2MSimpleCircularB,
- M2MComplexA, M2MComplexB, M2MThroughAB, M2MComplexCircular1A,
- M2MComplexCircular1B, M2MComplexCircular1C, M2MCircular1ThroughAB,
- M2MCircular1ThroughBC, M2MCircular1ThroughCA, M2MComplexCircular2A,
- M2MComplexCircular2B, M2MCircular2ThroughAB)
+from .models import (
+ Absolute, Animal, Article, Book, Child, Circle1, Circle2, Circle3,
+ ExternalDependency, M2MCircular1ThroughAB, M2MCircular1ThroughBC,
+ M2MCircular1ThroughCA, M2MCircular2ThroughAB, M2MComplexA, M2MComplexB,
+ M2MComplexCircular1A, M2MComplexCircular1B, M2MComplexCircular1C,
+ M2MComplexCircular2A, M2MComplexCircular2B, M2MSimpleA, M2MSimpleB,
+ M2MSimpleCircularA, M2MSimpleCircularB, M2MThroughAB, NKChild, Parent,
+ Person, RefToNKChild, Store, Stuff, Thingy, Widget,
+)
_cur_dir = os.path.dirname(os.path.abspath(upath(__file__)))
diff --git a/tests/force_insert_update/tests.py b/tests/force_insert_update/tests.py
index 6d87151d83..ae8b771ed1 100644
--- a/tests/force_insert_update/tests.py
+++ b/tests/force_insert_update/tests.py
@@ -1,10 +1,11 @@
from __future__ import unicode_literals
-from django.db import transaction, IntegrityError, DatabaseError
+from django.db import DatabaseError, IntegrityError, transaction
from django.test import TestCase
-from .models import (Counter, WithCustomPK, InheritedCounter, ProxyCounter,
- SubCounter)
+from .models import (
+ Counter, InheritedCounter, ProxyCounter, SubCounter, WithCustomPK,
+)
class ForceTests(TestCase):
diff --git a/tests/foreign_object/models.py b/tests/foreign_object/models.py
index 07d9ff4450..1e3214fec7 100644
--- a/tests/foreign_object/models.py
+++ b/tests/foreign_object/models.py
@@ -1,7 +1,8 @@
import datetime
from django.db import models
-from django.db.models.fields.related import ReverseSingleRelatedObjectDescriptor
+from django.db.models.fields.related import \
+ ReverseSingleRelatedObjectDescriptor
from django.utils.encoding import python_2_unicode_compatible
from django.utils.translation import get_language
diff --git a/tests/foreign_object/tests.py b/tests/foreign_object/tests.py
index dc949a3526..5c4c0970f3 100644
--- a/tests/foreign_object/tests.py
+++ b/tests/foreign_object/tests.py
@@ -1,13 +1,16 @@
import datetime
from operator import attrgetter
-from .models import (
- Country, Person, Group, Membership, Friendship, Article,
- ArticleTranslation, ArticleTag, ArticleIdea, NewsArticle)
+from django import forms
+from django.core.exceptions import FieldError
from django.test import TestCase, skipUnlessDBFeature
from django.utils import translation
-from django.core.exceptions import FieldError
-from django import forms
+
+from .models import (
+ Article, ArticleIdea, ArticleTag, ArticleTranslation, Country, Friendship,
+ Group, Membership, NewsArticle, Person,
+)
+
# Note that these tests are testing internal implementation details.
# ForeignObject is not part of public API.
diff --git a/tests/forms_tests/models.py b/tests/forms_tests/models.py
index 82fa005025..936bf8b41f 100644
--- a/tests/forms_tests/models.py
+++ b/tests/forms_tests/models.py
@@ -10,7 +10,6 @@ from django.core.files.storage import FileSystemStorage
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
-
callable_default_counter = itertools.count()
callable_default = lambda: next(callable_default_counter)
diff --git a/tests/forms_tests/tests/test_error_messages.py b/tests/forms_tests/tests/test_error_messages.py
index 5f79d4aa95..c02a44f8ff 100644
--- a/tests/forms_tests/tests/test_error_messages.py
+++ b/tests/forms_tests/tests/test_error_messages.py
@@ -7,11 +7,11 @@ from django.forms import (
DecimalField, EmailField, FileField, FloatField, Form,
GenericIPAddressField, IntegerField, ModelChoiceField,
ModelMultipleChoiceField, MultipleChoiceField, RegexField,
- SplitDateTimeField, TimeField, URLField, utils, ValidationError,
+ SplitDateTimeField, TimeField, URLField, ValidationError, utils,
)
from django.test import TestCase
-from django.utils.safestring import mark_safe
from django.utils.encoding import python_2_unicode_compatible
+from django.utils.safestring import mark_safe
class AssertFormErrorsMixin(object):
diff --git a/tests/forms_tests/tests/test_fields.py b/tests/forms_tests/tests/test_fields.py
index fda451281f..ed060bc064 100644
--- a/tests/forms_tests/tests/test_fields.py
+++ b/tests/forms_tests/tests/test_fields.py
@@ -27,34 +27,32 @@ __init__(). For example, CharField has a max_length option.
from __future__ import unicode_literals
import datetime
+import os
import pickle
import re
-import os
import uuid
from decimal import Decimal
from unittest import skipIf
-try:
- from PIL import Image
-except ImportError:
- Image = None
-
from django.core.files.uploadedfile import SimpleUploadedFile
from django.forms import (
BooleanField, CharField, ChoiceField, ComboField, DateField, DateTimeField,
DecimalField, DurationField, EmailField, Field, FileField, FilePathField,
- FloatField, Form, forms, GenericIPAddressField, HiddenInput, ImageField,
+ FloatField, Form, GenericIPAddressField, HiddenInput, ImageField,
IntegerField, MultipleChoiceField, NullBooleanField, NumberInput,
PasswordInput, RadioSelect, RegexField, SlugField, SplitDateTimeField,
- TextInput, Textarea, TimeField, TypedChoiceField, TypedMultipleChoiceField,
- URLField, UUIDField, ValidationError, Widget,
+ Textarea, TextInput, TimeField, TypedChoiceField, TypedMultipleChoiceField,
+ URLField, UUIDField, ValidationError, Widget, forms,
)
from django.test import SimpleTestCase, ignore_warnings
-from django.utils import formats
-from django.utils import six
-from django.utils import translation
-from django.utils.deprecation import RemovedInDjango20Warning
+from django.utils import formats, six, translation
from django.utils._os import upath
+from django.utils.deprecation import RemovedInDjango20Warning
+
+try:
+ from PIL import Image
+except ImportError:
+ Image = None
def fix_os_paths(x):
diff --git a/tests/forms_tests/tests/test_forms.py b/tests/forms_tests/tests/test_forms.py
index df090ef60e..4024f0359e 100644
--- a/tests/forms_tests/tests/test_forms.py
+++ b/tests/forms_tests/tests/test_forms.py
@@ -10,22 +10,22 @@ from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.validators import RegexValidator
from django.forms import (
BooleanField, CharField, CheckboxSelectMultiple, ChoiceField, DateField,
- DateTimeField, EmailField, FileField, FloatField, Form, forms, HiddenInput,
+ DateTimeField, EmailField, FileField, FloatField, Form, HiddenInput,
ImageField, IntegerField, MultipleChoiceField, MultipleHiddenInput,
MultiValueField, NullBooleanField, PasswordInput, RadioSelect, Select,
SplitDateTimeField, SplitHiddenDateTimeWidget, Textarea, TextInput,
- TimeField, ValidationError,
+ TimeField, ValidationError, forms,
)
from django.forms.utils import ErrorList
from django.http import QueryDict
-from django.template import Template, Context
+from django.template import Context, Template
from django.test import TestCase
from django.test.utils import str_prefix
+from django.utils import six
from django.utils.datastructures import MultiValueDict
from django.utils.encoding import force_text, python_2_unicode_compatible
from django.utils.html import format_html
-from django.utils.safestring import mark_safe, SafeData
-from django.utils import six
+from django.utils.safestring import SafeData, mark_safe
class Person(Form):
diff --git a/tests/forms_tests/tests/test_formsets.py b/tests/forms_tests/tests/test_formsets.py
index 276bf1cb22..7f450247eb 100644
--- a/tests/forms_tests/tests/test_formsets.py
+++ b/tests/forms_tests/tests/test_formsets.py
@@ -3,8 +3,10 @@ from __future__ import unicode_literals
import datetime
-from django.forms import (CharField, DateField, FileField, Form, IntegerField,
- SplitDateTimeField, ValidationError, formsets)
+from django.forms import (
+ CharField, DateField, FileField, Form, IntegerField, SplitDateTimeField,
+ ValidationError, formsets,
+)
from django.forms.formsets import BaseFormSet, formset_factory
from django.forms.utils import ErrorList
from django.test import TestCase
diff --git a/tests/forms_tests/tests/test_input_formats.py b/tests/forms_tests/tests/test_input_formats.py
index 60e153db4c..afb2513a95 100644
--- a/tests/forms_tests/tests/test_input_formats.py
+++ b/tests/forms_tests/tests/test_input_formats.py
@@ -1,9 +1,8 @@
-from datetime import time, date, datetime
+from datetime import date, datetime, time
from django import forms
-from django.test import override_settings
+from django.test import SimpleTestCase, override_settings
from django.utils.translation import activate, deactivate
-from django.test import SimpleTestCase
@override_settings(TIME_INPUT_FORMATS=["%I:%M:%S %p", "%I:%M %p"], USE_L10N=True)
diff --git a/tests/forms_tests/tests/test_media.py b/tests/forms_tests/tests/test_media.py
index c44e443eac..027e410f30 100644
--- a/tests/forms_tests/tests/test_media.py
+++ b/tests/forms_tests/tests/test_media.py
@@ -1,6 +1,6 @@
# -*- coding: utf-8 -*-
-from django.forms import Media, TextInput, CharField, Form, MultiWidget
-from django.template import Template, Context
+from django.forms import CharField, Form, Media, MultiWidget, TextInput
+from django.template import Context, Template
from django.test import TestCase, override_settings
diff --git a/tests/forms_tests/tests/test_regressions.py b/tests/forms_tests/tests/test_regressions.py
index b0b360e679..3a20d4d9fb 100644
--- a/tests/forms_tests/tests/test_regressions.py
+++ b/tests/forms_tests/tests/test_regressions.py
@@ -10,7 +10,7 @@ from django.test import TestCase, ignore_warnings
from django.utils import translation
from django.utils.translation import gettext_lazy, ugettext_lazy
-from forms_tests.models import Cheese
+from ..models import Cheese
class FormsRegressionsTestCase(TestCase):
diff --git a/tests/forms_tests/tests/test_utils.py b/tests/forms_tests/tests/test_utils.py
index 9f412b7a27..4519963d96 100644
--- a/tests/forms_tests/tests/test_utils.py
+++ b/tests/forms_tests/tests/test_utils.py
@@ -4,12 +4,12 @@ from __future__ import unicode_literals
import copy
from django.core.exceptions import ValidationError
-from django.forms.utils import flatatt, ErrorDict, ErrorList
+from django.forms.utils import ErrorDict, ErrorList, flatatt
from django.test import TestCase
-from django.utils.safestring import mark_safe
from django.utils import six
-from django.utils.translation import ugettext_lazy
from django.utils.encoding import python_2_unicode_compatible
+from django.utils.safestring import mark_safe
+from django.utils.translation import ugettext_lazy
class FormsUtilsTestCase(TestCase):
diff --git a/tests/forms_tests/tests/test_widgets.py b/tests/forms_tests/tests/test_widgets.py
index b58c4e74e4..fc8ac93721 100644
--- a/tests/forms_tests/tests/test_widgets.py
+++ b/tests/forms_tests/tests/test_widgets.py
@@ -16,11 +16,11 @@ from django.forms import (
SplitDateTimeWidget, Textarea, TextInput, TimeInput, ValidationError,
)
from django.forms.widgets import RadioFieldRenderer
-from django.utils.safestring import mark_safe, SafeData
-from django.utils import six, translation
from django.test import TestCase, override_settings
+from django.utils import six, translation
from django.utils.dates import MONTHS_AP
from django.utils.encoding import force_text, python_2_unicode_compatible
+from django.utils.safestring import SafeData, mark_safe
from ..models import Article
diff --git a/tests/forms_tests/tests/tests.py b/tests/forms_tests/tests/tests.py
index 0b3d5765a0..8e8aa82cdd 100644
--- a/tests/forms_tests/tests/tests.py
+++ b/tests/forms_tests/tests/tests.py
@@ -5,13 +5,17 @@ import datetime
from django.core.files.uploadedfile import SimpleUploadedFile
from django.db import models
-from django.forms import Form, ModelForm, FileField, ModelChoiceField, CharField
+from django.forms import (
+ CharField, FileField, Form, ModelChoiceField, ModelForm,
+)
from django.forms.models import ModelFormMetaclass
from django.test import TestCase
from django.utils import six
-from ..models import (ChoiceModel, ChoiceOptionModel, ChoiceFieldModel,
- FileModel, Group, BoundaryModel, Defaults, OptionalMultiChoiceModel)
+from ..models import (
+ BoundaryModel, ChoiceFieldModel, ChoiceModel, ChoiceOptionModel, Defaults,
+ FileModel, Group, OptionalMultiChoiceModel,
+)
class ChoiceFieldForm(ModelForm):
diff --git a/tests/forms_tests/urls.py b/tests/forms_tests/urls.py
index e4a91469b1..ab7fa902a9 100644
--- a/tests/forms_tests/urls.py
+++ b/tests/forms_tests/urls.py
@@ -2,7 +2,6 @@ from django.conf.urls import url
from .views import ArticleFormView
-
urlpatterns = [
url(r'^model_form/(?P<pk>[0-9]+)/$', ArticleFormView.as_view(), name="article_form"),
]
diff --git a/tests/from_db_value/tests.py b/tests/from_db_value/tests.py
index 69e22d4290..10b9e1556e 100644
--- a/tests/from_db_value/tests.py
+++ b/tests/from_db_value/tests.py
@@ -2,7 +2,7 @@ from django.db import connection
from django.db.models import Max
from django.test import TestCase
-from .models import CashModel, Cash
+from .models import Cash, CashModel
class FromDBValueTest(TestCase):
diff --git a/tests/generic_inline_admin/admin.py b/tests/generic_inline_admin/admin.py
index 46f6cf3e7f..3f13b394f3 100644
--- a/tests/generic_inline_admin/admin.py
+++ b/tests/generic_inline_admin/admin.py
@@ -1,9 +1,9 @@
from django.contrib import admin
from django.contrib.contenttypes.admin import GenericTabularInline
-from .models import (Media, PhoneNumber, Episode, Contact,
- Category, EpisodePermanent)
-
+from .models import (
+ Category, Contact, Episode, EpisodePermanent, Media, PhoneNumber,
+)
site = admin.AdminSite(name="admin")
diff --git a/tests/generic_inline_admin/models.py b/tests/generic_inline_admin/models.py
index 059aadc5ba..d15f2b9f17 100644
--- a/tests/generic_inline_admin/models.py
+++ b/tests/generic_inline_admin/models.py
@@ -1,5 +1,5 @@
from django.contrib.contenttypes.fields import (
- GenericForeignKey, GenericRelation
+ GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
diff --git a/tests/generic_inline_admin/tests.py b/tests/generic_inline_admin/tests.py
index 325d94c7a7..0394377466 100644
--- a/tests/generic_inline_admin/tests.py
+++ b/tests/generic_inline_admin/tests.py
@@ -10,9 +10,8 @@ from django.forms.formsets import DEFAULT_MAX_NUM
from django.forms.models import ModelForm
from django.test import RequestFactory, TestCase, override_settings
-# local test models
from .admin import MediaInline, MediaPermanentInline, site as admin_site
-from .models import Episode, Media, EpisodePermanent, Category
+from .models import Category, Episode, EpisodePermanent, Media
# Set TEMPLATE_DEBUG to True to ensure {% include %} will raise exceptions.
diff --git a/tests/generic_relations/models.py b/tests/generic_relations/models.py
index cd013e580a..1f1872dd0f 100644
--- a/tests/generic_relations/models.py
+++ b/tests/generic_relations/models.py
@@ -12,7 +12,7 @@ from complete).
from __future__ import unicode_literals
from django.contrib.contenttypes.fields import (
- GenericForeignKey, GenericRelation
+ GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
diff --git a/tests/generic_relations/tests.py b/tests/generic_relations/tests.py
index bc2cfaa579..05ce20f078 100644
--- a/tests/generic_relations/tests.py
+++ b/tests/generic_relations/tests.py
@@ -8,10 +8,11 @@ from django.db.models import Q
from django.test import TestCase
from django.utils import six
-from .models import (TaggedItem, ValuableTaggedItem, Comparison, Animal,
- Vegetable, Mineral, Gecko, Rock, ManualPK,
- ForProxyModelModel, ForConcreteModelModel,
- ProxyRelatedModel, ConcreteRelatedModel, AllowsNullGFK)
+from .models import (
+ AllowsNullGFK, Animal, Comparison, ConcreteRelatedModel,
+ ForConcreteModelModel, ForProxyModelModel, Gecko, ManualPK, Mineral,
+ ProxyRelatedModel, Rock, TaggedItem, ValuableTaggedItem, Vegetable,
+)
class GenericRelationsTests(TestCase):
diff --git a/tests/generic_relations_regress/models.py b/tests/generic_relations_regress/models.py
index b57b887e4a..ffedbc86f8 100644
--- a/tests/generic_relations_regress/models.py
+++ b/tests/generic_relations_regress/models.py
@@ -1,11 +1,10 @@
from django.contrib.contenttypes.fields import (
- GenericForeignKey, GenericRelation
+ GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
-from django.utils.encoding import python_2_unicode_compatible
from django.db.models.deletion import ProtectedError
-
+from django.utils.encoding import python_2_unicode_compatible
__all__ = ('Link', 'Place', 'Restaurant', 'Person', 'Address',
'CharLink', 'TextLink', 'OddRelation1', 'OddRelation2',
diff --git a/tests/generic_relations_regress/tests.py b/tests/generic_relations_regress/tests.py
index 88243bade0..0d78223725 100644
--- a/tests/generic_relations_regress/tests.py
+++ b/tests/generic_relations_regress/tests.py
@@ -1,14 +1,13 @@
from django.db.models import Q, Sum
+from django.db.models.deletion import ProtectedError
from django.db.utils import IntegrityError
-from django.test import TestCase, skipIfDBFeature
from django.forms.models import modelform_factory
-from django.db.models.deletion import ProtectedError
+from django.test import TestCase, skipIfDBFeature
from .models import (
- Address, Place, Restaurant, Link, CharLink, TextLink,
- Person, Contact, Note, Organization, OddRelation1, OddRelation2, Company,
- Developer, Team, Guild, Tag, Board, HasLinkThing, A, B, C, D,
- Related, Content, Node,
+ A, B, C, D, Address, Board, CharLink, Company, Contact, Content, Developer,
+ Guild, HasLinkThing, Link, Node, Note, OddRelation1, OddRelation2,
+ Organization, Person, Place, Related, Restaurant, Tag, Team, TextLink,
)
diff --git a/tests/generic_views/test_base.py b/tests/generic_views/test_base.py
index f297b2e91b..bf7fa0fc34 100644
--- a/tests/generic_views/test_base.py
+++ b/tests/generic_views/test_base.py
@@ -6,9 +6,9 @@ import unittest
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import resolve
from django.http import HttpResponse
-from django.test import TestCase, RequestFactory, override_settings
+from django.test import RequestFactory, TestCase, override_settings
from django.test.utils import require_jinja2
-from django.views.generic import View, TemplateView, RedirectView
+from django.views.generic import RedirectView, TemplateView, View
from . import views
diff --git a/tests/generic_views/test_edit.py b/tests/generic_views/test_edit.py
index b61a11086a..91d0d20ff7 100644
--- a/tests/generic_views/test_edit.py
+++ b/tests/generic_views/test_edit.py
@@ -2,14 +2,14 @@ from __future__ import unicode_literals
import warnings
+from django import forms
from django.core.exceptions import ImproperlyConfigured
from django.core.urlresolvers import reverse
-from django import forms
from django.test import TestCase, ignore_warnings, override_settings
from django.test.client import RequestFactory
from django.utils.deprecation import RemovedInDjango20Warning
from django.views.generic.base import View
-from django.views.generic.edit import FormMixin, ModelFormMixin, CreateView
+from django.views.generic.edit import CreateView, FormMixin, ModelFormMixin
from . import views
from .models import Artist, Author
diff --git a/tests/generic_views/test_list.py b/tests/generic_views/test_list.py
index f5b91c74bb..b9274242c9 100644
--- a/tests/generic_views/test_list.py
+++ b/tests/generic_views/test_list.py
@@ -4,10 +4,10 @@ import datetime
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase, override_settings
-from django.views.generic.base import View
from django.utils.encoding import force_str
+from django.views.generic.base import View
-from .models import Author, Artist, Book
+from .models import Artist, Author, Book
@override_settings(ROOT_URLCONF='generic_views.urls')
diff --git a/tests/generic_views/urls.py b/tests/generic_views/urls.py
index e09ee12562..83ba68fa2e 100644
--- a/tests/generic_views/urls.py
+++ b/tests/generic_views/urls.py
@@ -7,9 +7,7 @@ from django.contrib.auth.decorators import login_required
from django.views.decorators.cache import cache_page
from django.views.generic import TemplateView
-from . import models
-from . import views
-
+from . import models, views
urlpatterns = [
# TemplateView
diff --git a/tests/generic_views/views.py b/tests/generic_views/views.py
index fe7fb88876..6dcac21aa6 100644
--- a/tests/generic_views/views.py
+++ b/tests/generic_views/views.py
@@ -6,8 +6,8 @@ from django.core.urlresolvers import reverse, reverse_lazy
from django.utils.decorators import method_decorator
from django.views import generic
+from .models import Artist, Author, Book, BookSigning, Page
from .test_forms import AuthorForm, ContactForm
-from .models import Artist, Author, Book, Page, BookSigning
class CustomTemplateView(generic.TemplateView):
diff --git a/tests/get_earliest_or_latest/tests.py b/tests/get_earliest_or_latest/tests.py
index de3307b1a6..c4e4bb7586 100644
--- a/tests/get_earliest_or_latest/tests.py
+++ b/tests/get_earliest_or_latest/tests.py
@@ -4,7 +4,7 @@ from datetime import datetime
from django.test import TestCase
-from .models import Article, Person, IndexErrorArticle
+from .models import Article, IndexErrorArticle, Person
class EarliestOrLatestTests(TestCase):
diff --git a/tests/get_object_or_404/tests.py b/tests/get_object_or_404/tests.py
index 75d2a1c784..a5e3d2d8b8 100644
--- a/tests/get_object_or_404/tests.py
+++ b/tests/get_object_or_404/tests.py
@@ -1,10 +1,10 @@
from __future__ import unicode_literals
from django.http import Http404
-from django.shortcuts import get_object_or_404, get_list_or_404
+from django.shortcuts import get_list_or_404, get_object_or_404
from django.test import TestCase
-from .models import Author, Article
+from .models import Article, Author
class GetObjectOr404Tests(TestCase):
diff --git a/tests/get_or_create/tests.py b/tests/get_or_create/tests.py
index f15d84323d..a58e77ec0e 100644
--- a/tests/get_or_create/tests.py
+++ b/tests/get_or_create/tests.py
@@ -1,14 +1,16 @@
from __future__ import unicode_literals
-from datetime import date
import traceback
+from datetime import date
-from django.db import IntegrityError, DatabaseError
-from django.utils.encoding import DjangoUnicodeDecodeError
+from django.db import DatabaseError, IntegrityError
from django.test import TestCase, TransactionTestCase, ignore_warnings
+from django.utils.encoding import DjangoUnicodeDecodeError
-from .models import (DefaultPerson, Person, ManualPrimaryKeyTest, Profile,
- Tag, Thing, Publisher, Author, Book)
+from .models import (
+ Author, Book, DefaultPerson, ManualPrimaryKeyTest, Person, Profile,
+ Publisher, Tag, Thing,
+)
class GetOrCreateTests(TestCase):
diff --git a/tests/handlers/tests.py b/tests/handlers/tests.py
index a543513a25..a1fed74105 100644
--- a/tests/handlers/tests.py
+++ b/tests/handlers/tests.py
@@ -3,12 +3,13 @@
from __future__ import unicode_literals
from django.core.handlers.wsgi import WSGIHandler, WSGIRequest
-from django.core.signals import request_started, request_finished
+from django.core.signals import request_finished, request_started
from django.db import close_old_connections, connection
-from django.test import RequestFactory, TestCase, TransactionTestCase
-from django.test import override_settings
-from django.utils.encoding import force_str
+from django.test import (
+ RequestFactory, TestCase, TransactionTestCase, override_settings,
+)
from django.utils import six
+from django.utils.encoding import force_str
class HandlerTests(TestCase):
diff --git a/tests/http_utils/tests.py b/tests/http_utils/tests.py
index d88afb951c..2a2b29bbfb 100644
--- a/tests/http_utils/tests.py
+++ b/tests/http_utils/tests.py
@@ -1,9 +1,11 @@
from __future__ import unicode_literals
-import io
import gzip
+import io
-from django.http import HttpRequest, HttpResponse, HttpResponseRedirect, StreamingHttpResponse
+from django.http import (
+ HttpRequest, HttpResponse, HttpResponseRedirect, StreamingHttpResponse,
+)
from django.http.utils import conditional_content_removal, fix_location_header
from django.test import TestCase
diff --git a/tests/httpwrappers/tests.py b/tests/httpwrappers/tests.py
index 14ad306c65..bea1c50b7e 100644
--- a/tests/httpwrappers/tests.py
+++ b/tests/httpwrappers/tests.py
@@ -11,16 +11,17 @@ from django.core.exceptions import SuspiciousOperation
from django.core.serializers.json import DjangoJSONEncoder
from django.core.signals import request_finished
from django.db import close_old_connections
-from django.http import (QueryDict, HttpResponse, HttpResponseRedirect,
- HttpResponsePermanentRedirect, HttpResponseNotAllowed,
- HttpResponseNotModified, StreamingHttpResponse,
- SimpleCookie, BadHeaderError, JsonResponse,
- parse_cookie)
+from django.http import (
+ BadHeaderError, HttpResponse, HttpResponseNotAllowed,
+ HttpResponseNotModified, HttpResponsePermanentRedirect,
+ HttpResponseRedirect, JsonResponse, QueryDict, SimpleCookie,
+ StreamingHttpResponse, parse_cookie,
+)
from django.test import TestCase
-from django.utils.encoding import smart_str, force_text
-from django.utils.functional import lazy
-from django.utils._os import upath
from django.utils import six
+from django.utils._os import upath
+from django.utils.encoding import force_text, smart_str
+from django.utils.functional import lazy
lazystr = lazy(force_text, six.text_type)
diff --git a/tests/i18n/contenttypes/tests.py b/tests/i18n/contenttypes/tests.py
index a93f2030f2..890fa1156b 100644
--- a/tests/i18n/contenttypes/tests.py
+++ b/tests/i18n/contenttypes/tests.py
@@ -5,9 +5,8 @@ import os
from django.contrib.contenttypes.models import ContentType
from django.test import TestCase, override_settings
+from django.utils import six, translation
from django.utils._os import upath
-from django.utils import six
-from django.utils import translation
@override_settings(
diff --git a/tests/i18n/patterns/tests.py b/tests/i18n/patterns/tests.py
index f96ac82fc4..1ac0e8a4a9 100644
--- a/tests/i18n/patterns/tests.py
+++ b/tests/i18n/patterns/tests.py
@@ -3,13 +3,15 @@ from __future__ import unicode_literals
import os
from django.core.exceptions import ImproperlyConfigured
-from django.core.urlresolvers import reverse, clear_url_caches, set_script_prefix
+from django.core.urlresolvers import (
+ clear_url_caches, reverse, set_script_prefix,
+)
from django.http import HttpResponsePermanentRedirect
from django.middleware.locale import LocaleMiddleware
+from django.template import Context, Template
from django.test import TestCase, override_settings
-from django.template import Template, Context
-from django.utils._os import upath
from django.utils import translation
+from django.utils._os import upath
class PermanentRedirectLocaleMiddleWare(LocaleMiddleware):
diff --git a/tests/i18n/patterns/urls/default.py b/tests/i18n/patterns/urls/default.py
index 416c4e854f..caf1a7637d 100644
--- a/tests/i18n/patterns/urls/default.py
+++ b/tests/i18n/patterns/urls/default.py
@@ -3,7 +3,6 @@ from django.conf.urls.i18n import i18n_patterns
from django.utils.translation import ugettext_lazy as _
from django.views.generic import TemplateView
-
view = TemplateView.as_view(template_name='dummy.html')
urlpatterns = [
diff --git a/tests/i18n/patterns/urls/included.py b/tests/i18n/patterns/urls/included.py
index eb4631c087..ded29a8bf1 100644
--- a/tests/i18n/patterns/urls/included.py
+++ b/tests/i18n/patterns/urls/included.py
@@ -1,7 +1,6 @@
from django.conf.urls import url
from django.views.generic import TemplateView
-
view = TemplateView.as_view(template_name='dummy.html')
urlpatterns = [
diff --git a/tests/i18n/patterns/urls/namespace.py b/tests/i18n/patterns/urls/namespace.py
index 570a7572e6..6060c57bd6 100644
--- a/tests/i18n/patterns/urls/namespace.py
+++ b/tests/i18n/patterns/urls/namespace.py
@@ -2,7 +2,6 @@ from django.conf.urls import url
from django.utils.translation import ugettext_lazy as _
from django.views.generic import TemplateView
-
view = TemplateView.as_view(template_name='dummy.html')
urlpatterns = [
diff --git a/tests/i18n/patterns/urls/path_unused.py b/tests/i18n/patterns/urls/path_unused.py
index cd17527bf0..e2186d3d02 100644
--- a/tests/i18n/patterns/urls/path_unused.py
+++ b/tests/i18n/patterns/urls/path_unused.py
@@ -1,7 +1,6 @@
from django.conf.urls import url
from django.views.generic import TemplateView
-
view = TemplateView.as_view(template_name='dummy.html')
urlpatterns = [
diff --git a/tests/i18n/patterns/urls/wrong.py b/tests/i18n/patterns/urls/wrong.py
index fe948e0563..a8f9410db8 100644
--- a/tests/i18n/patterns/urls/wrong.py
+++ b/tests/i18n/patterns/urls/wrong.py
@@ -2,7 +2,6 @@ from django.conf.urls import include, url
from django.conf.urls.i18n import i18n_patterns
from django.utils.translation import ugettext_lazy as _
-
urlpatterns = i18n_patterns(
url(_(r'^account/'), include('i18n.patterns.urls.wrong_namespace', namespace='account')),
)
diff --git a/tests/i18n/patterns/urls/wrong_namespace.py b/tests/i18n/patterns/urls/wrong_namespace.py
index f3b55b69fe..e19c99c935 100644
--- a/tests/i18n/patterns/urls/wrong_namespace.py
+++ b/tests/i18n/patterns/urls/wrong_namespace.py
@@ -3,7 +3,6 @@ from django.conf.urls.i18n import i18n_patterns
from django.utils.translation import ugettext_lazy as _
from django.views.generic import TemplateView
-
view = TemplateView.as_view(template_name='dummy.html')
urlpatterns = i18n_patterns(
diff --git a/tests/i18n/test_compilation.py b/tests/i18n/test_compilation.py
index c17db0a98a..682885bec8 100644
--- a/tests/i18n/test_compilation.py
+++ b/tests/i18n/test_compilation.py
@@ -1,21 +1,22 @@
# -*- coding: utf-8 -*-
+import gettext as gettext_module
import os
import shutil
import stat
import unittest
-import gettext as gettext_module
-from django.core.management import call_command, CommandError, execute_from_command_line
+from django.core.management import (
+ CommandError, call_command, execute_from_command_line,
+)
from django.core.management.utils import find_command
-from django.test import SimpleTestCase
-from django.test import override_settings
+from django.test import SimpleTestCase, override_settings
from django.test.utils import captured_stderr, captured_stdout
from django.utils import translation
-from django.utils.translation import ugettext
-from django.utils.encoding import force_text
from django.utils._os import upath
+from django.utils.encoding import force_text
from django.utils.six import StringIO
+from django.utils.translation import ugettext
has_msgfmt = find_command('msgfmt')
diff --git a/tests/i18n/test_extraction.py b/tests/i18n/test_extraction.py
index 99d4983b43..556cba7fa4 100644
--- a/tests/i18n/test_extraction.py
+++ b/tests/i18n/test_extraction.py
@@ -6,24 +6,24 @@ import os
import re
import shutil
import time
-from unittest import SkipTest, skipUnless
import warnings
+from unittest import SkipTest, skipUnless
from django.conf import settings
from django.core import management
from django.core.management import execute_from_command_line
from django.core.management.base import CommandError
-from django.core.management.commands.makemessages import Command as MakeMessagesCommand
+from django.core.management.commands.makemessages import \
+ Command as MakeMessagesCommand
from django.core.management.utils import find_command
-from django.test import mock, override_settings, SimpleTestCase
+from django.test import SimpleTestCase, mock, override_settings
from django.test.utils import captured_stderr, captured_stdout
-from django.utils.encoding import force_text
-from django.utils._os import upath
from django.utils import six
+from django.utils._os import upath
+from django.utils.encoding import force_text
from django.utils.six import StringIO
from django.utils.translation import TranslatorCommentWarning
-
LOCALE = 'de'
has_xgettext = find_command('xgettext')
this_directory = os.path.dirname(upath(__file__))
diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py
index cbc31828b4..b9a2858148 100644
--- a/tests/i18n/tests.py
+++ b/tests/i18n/tests.py
@@ -1,45 +1,40 @@
# -*- encoding: utf-8 -*-
from __future__ import unicode_literals
-from contextlib import contextmanager
import datetime
import decimal
import gettext as gettext_module
-from importlib import import_module
import os
import pickle
+from contextlib import contextmanager
+from importlib import import_module
from threading import local
from unittest import skipUnless
from django import forms
from django.conf import settings
-from django.template import Template, Context
+from django.template import Context, Template
from django.template.base import TemplateSyntaxError
-from django.test import TestCase, RequestFactory, override_settings
-from django.utils import translation
-from django.utils.formats import (get_format, date_format, time_format,
- localize, localize_input, iter_format_modules, get_format_modules,
- reset_format_cache, sanitize_separators)
-from django.utils.numberformat import format as nformat
+from django.test import RequestFactory, TestCase, override_settings
+from django.utils import six, translation
from django.utils._os import upath
-from django.utils.safestring import mark_safe, SafeBytes, SafeString, SafeText
-from django.utils import six
+from django.utils.formats import (
+ date_format, get_format, get_format_modules, iter_format_modules, localize,
+ localize_input, reset_format_cache, sanitize_separators, time_format,
+)
+from django.utils.numberformat import format as nformat
+from django.utils.safestring import SafeBytes, SafeString, SafeText, mark_safe
from django.utils.six import PY3
-from django.utils.translation import (activate, deactivate,
- get_language, get_language_from_request, get_language_info,
- to_locale, trans_real,
- gettext, gettext_lazy,
- ugettext, ugettext_lazy,
- ngettext_lazy,
- ungettext_lazy,
- pgettext, pgettext_lazy,
- npgettext, npgettext_lazy,
- check_for_language,
- string_concat, LANGUAGE_SESSION_KEY)
-
-from .forms import I18nForm, SelectDateForm, CompanyForm
-from .models import Company, TestModel
+from django.utils.translation import (
+ LANGUAGE_SESSION_KEY, activate, check_for_language, deactivate,
+ get_language, get_language_from_request, get_language_info, gettext,
+ gettext_lazy, ngettext_lazy, npgettext, npgettext_lazy, pgettext,
+ pgettext_lazy, string_concat, to_locale, trans_real, ugettext,
+ ugettext_lazy, ungettext_lazy,
+)
+from .forms import CompanyForm, I18nForm, SelectDateForm
+from .models import Company, TestModel
here = os.path.dirname(os.path.abspath(upath(__file__)))
extended_locale_paths = settings.LOCALE_PATHS + [
diff --git a/tests/i18n/urls.py b/tests/i18n/urls.py
index c1124a1b8c..d63499f1bb 100644
--- a/tests/i18n/urls.py
+++ b/tests/i18n/urls.py
@@ -6,7 +6,6 @@ from django.test import ignore_warnings
from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.translation import ugettext_lazy as _
-
# test deprecated version of i18n_patterns() function (with prefix). Remove it
# and convert to list of urls() in Django 2.0
i18n_patterns = ignore_warnings(category=RemovedInDjango20Warning)(i18n_patterns)
diff --git a/tests/indexes/models.py b/tests/indexes/models.py
index c3d43913dd..3e9cbf630b 100644
--- a/tests/indexes/models.py
+++ b/tests/indexes/models.py
@@ -1,5 +1,4 @@
-from django.db import connection
-from django.db import models
+from django.db import connection, models
class CurrentTranslation(models.ForeignObject):
diff --git a/tests/inline_formsets/tests.py b/tests/inline_formsets/tests.py
index 6f6bc76ac8..167d2a68e1 100644
--- a/tests/inline_formsets/tests.py
+++ b/tests/inline_formsets/tests.py
@@ -4,7 +4,7 @@ from django.forms.models import inlineformset_factory
from django.test import TestCase, skipUnlessDBFeature
from django.utils import six
-from .models import Poet, Poem, School, Parent, Child
+from .models import Child, Parent, Poem, Poet, School
class DeletionTests(TestCase):
diff --git a/tests/introspection/tests.py b/tests/introspection/tests.py
index cc6b33e572..1280c13fe0 100644
--- a/tests/introspection/tests.py
+++ b/tests/introspection/tests.py
@@ -6,7 +6,7 @@ from django.db import connection
from django.db.utils import DatabaseError
from django.test import TransactionTestCase, mock, skipUnlessDBFeature
-from .models import Reporter, Article
+from .models import Article, Reporter
class IntrospectionTests(TransactionTestCase):
diff --git a/tests/invalid_models_tests/test_models.py b/tests/invalid_models_tests/test_models.py
index 3c874ad11b..85599bc68a 100644
--- a/tests/invalid_models_tests/test_models.py
+++ b/tests/invalid_models_tests/test_models.py
@@ -5,7 +5,7 @@ import unittest
from django.conf import settings
from django.core.checks import Error
-from django.db import models, connections
+from django.db import connections, models
from django.test.utils import override_settings
from .base import IsolatedModelsTestCase
diff --git a/tests/invalid_models_tests/test_relative_fields.py b/tests/invalid_models_tests/test_relative_fields.py
index 9781ecc2ba..b6ac3de722 100644
--- a/tests/invalid_models_tests/test_relative_fields.py
+++ b/tests/invalid_models_tests/test_relative_fields.py
@@ -3,8 +3,8 @@ from __future__ import unicode_literals
from django.core.checks import Error, Warning as DjangoWarning
from django.db import models
-from django.test.utils import override_settings
from django.test.testcases import skipIfDBFeature
+from django.test.utils import override_settings
from .base import IsolatedModelsTestCase
diff --git a/tests/known_related_objects/tests.py b/tests/known_related_objects/tests.py
index f7ac18c981..9712ee69ca 100644
--- a/tests/known_related_objects/tests.py
+++ b/tests/known_related_objects/tests.py
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
from django.test import TestCase
-from .models import Tournament, Organiser, Pool, PoolStyle
+from .models import Organiser, Pool, PoolStyle, Tournament
class ExistingRelatedInstancesTests(TestCase):
diff --git a/tests/logging_tests/tests.py b/tests/logging_tests/tests.py
index 3e4c19ece5..a349e4f35b 100644
--- a/tests/logging_tests/tests.py
+++ b/tests/logging_tests/tests.py
@@ -4,22 +4,21 @@ from __future__ import unicode_literals
import logging
import warnings
+from admin_scripts.tests import AdminScriptTestCase
+
from django.core import mail
from django.core.files.temp import NamedTemporaryFile
-from django.test import TestCase, RequestFactory, override_settings
+from django.test import RequestFactory, TestCase, override_settings
from django.test.utils import patch_logger
-from django.utils.encoding import force_text
from django.utils.deprecation import RemovedInNextVersionWarning
+from django.utils.encoding import force_text
from django.utils.log import (
AdminEmailHandler, CallbackFilter, RequireDebugFalse, RequireDebugTrue,
)
from django.utils.six import StringIO
-from admin_scripts.tests import AdminScriptTestCase
-
from .logconfig import MyEmailBackend
-
# logging config prior to using filter with mail_admins
OLD_LOGGING = {
'version': 1,
diff --git a/tests/logging_tests/views.py b/tests/logging_tests/views.py
index c685bcc005..77186be329 100644
--- a/tests/logging_tests/views.py
+++ b/tests/logging_tests/views.py
@@ -1,6 +1,6 @@
from __future__ import unicode_literals
-from django.core.exceptions import SuspiciousOperation, DisallowedHost
+from django.core.exceptions import DisallowedHost, SuspiciousOperation
def suspicious(request):
diff --git a/tests/lookup/tests.py b/tests/lookup/tests.py
index 8dabfb2c18..36b60a033d 100644
--- a/tests/lookup/tests.py
+++ b/tests/lookup/tests.py
@@ -8,7 +8,7 @@ from django.core.exceptions import FieldError
from django.db import connection
from django.test import TestCase, TransactionTestCase, skipUnlessDBFeature
-from .models import Author, Article, Tag, Game, Season, Player, MyISAMArticle
+from .models import Article, Author, Game, MyISAMArticle, Player, Season, Tag
class LookupTests(TestCase):
diff --git a/tests/m2m_and_m2o/tests.py b/tests/m2m_and_m2o/tests.py
index 2317f62300..2c84a7f2d4 100644
--- a/tests/m2m_and_m2o/tests.py
+++ b/tests/m2m_and_m2o/tests.py
@@ -1,7 +1,7 @@
from django.db.models import Q
from django.test import TestCase
-from .models import Issue, User, UnicodeReferenceModel
+from .models import Issue, UnicodeReferenceModel, User
class RelatedObjectTests(TestCase):
diff --git a/tests/m2m_intermediary/tests.py b/tests/m2m_intermediary/tests.py
index d9c77ecb7c..ce4e186004 100644
--- a/tests/m2m_intermediary/tests.py
+++ b/tests/m2m_intermediary/tests.py
@@ -5,7 +5,7 @@ from datetime import datetime
from django.test import TestCase
from django.utils import six
-from .models import Reporter, Article, Writer
+from .models import Article, Reporter, Writer
class M2MIntermediaryTests(TestCase):
diff --git a/tests/m2m_regress/tests.py b/tests/m2m_regress/tests.py
index b1adc53952..885efa593f 100644
--- a/tests/m2m_regress/tests.py
+++ b/tests/m2m_regress/tests.py
@@ -4,8 +4,10 @@ from django.core.exceptions import FieldError
from django.test import TestCase
from django.utils import six
-from .models import (SelfRefer, Tag, TagCollection, Entry, SelfReferChild,
- SelfReferChildSibling, Worksheet, RegressionModelSplit)
+from .models import (
+ Entry, RegressionModelSplit, SelfRefer, SelfReferChild,
+ SelfReferChildSibling, Tag, TagCollection, Worksheet,
+)
class M2MRegressionTests(TestCase):
diff --git a/tests/m2m_signals/tests.py b/tests/m2m_signals/tests.py
index f41f6efd8e..514dec78c9 100644
--- a/tests/m2m_signals/tests.py
+++ b/tests/m2m_signals/tests.py
@@ -5,7 +5,7 @@ Testing signals emitted on changing m2m relations.
from django.db import models
from django.test import TestCase
-from .models import Part, Car, SportsCar, Person
+from .models import Car, Part, Person, SportsCar
class ManyToManySignalsTest(TestCase):
diff --git a/tests/m2m_through/tests.py b/tests/m2m_through/tests.py
index 80c1e6c393..f8149b7c1f 100644
--- a/tests/m2m_through/tests.py
+++ b/tests/m2m_through/tests.py
@@ -5,9 +5,11 @@ from operator import attrgetter
from django.test import TestCase
-from .models import (Person, Group, Membership, CustomMembership,
- PersonSelfRefM2M, Friendship, Event, Invitation, Employee, Relationship,
- Ingredient, Recipe, RecipeIngredient)
+from .models import (
+ CustomMembership, Employee, Event, Friendship, Group, Ingredient,
+ Invitation, Membership, Person, PersonSelfRefM2M, Recipe, RecipeIngredient,
+ Relationship,
+)
class M2mThroughTests(TestCase):
diff --git a/tests/m2m_through_regress/tests.py b/tests/m2m_through_regress/tests.py
index c5f56a5d62..f283c658b8 100644
--- a/tests/m2m_through_regress/tests.py
+++ b/tests/m2m_through_regress/tests.py
@@ -1,12 +1,13 @@
from __future__ import unicode_literals
-from django.core import management
from django.contrib.auth.models import User
+from django.core import management
from django.test import TestCase
from django.utils.six import StringIO
-from .models import (Person, Group, Membership, UserMembership, Car, Driver,
- CarDriver)
+from .models import (
+ Car, CarDriver, Driver, Group, Membership, Person, UserMembership,
+)
class M2MThroughTestCase(TestCase):
diff --git a/tests/mail/tests.py b/tests/mail/tests.py
index 683f47fe31..b6170068fb 100644
--- a/tests/mail/tests.py
+++ b/tests/mail/tests.py
@@ -2,24 +2,25 @@
from __future__ import unicode_literals
import asyncore
-from email.mime.text import MIMEText
import os
import shutil
import smtpd
import sys
import tempfile
import threading
-from smtplib import SMTPException, SMTP
+from email.mime.text import MIMEText
+from smtplib import SMTP, SMTPException
from ssl import SSLError
from django.core import mail
-from django.core.mail import (EmailMessage, mail_admins, mail_managers,
- EmailMultiAlternatives, send_mail, send_mass_mail)
-from django.core.mail.backends import console, dummy, locmem, filebased, smtp
+from django.core.mail import (
+ EmailMessage, EmailMultiAlternatives, mail_admins, mail_managers,
+ send_mail, send_mass_mail,
+)
+from django.core.mail.backends import console, dummy, filebased, locmem, smtp
from django.core.mail.message import BadHeaderError
-from django.test import SimpleTestCase
-from django.test import override_settings
-from django.utils.encoding import force_text, force_bytes
+from django.test import SimpleTestCase, override_settings
+from django.utils.encoding import force_bytes, force_text
from django.utils.six import PY3, StringIO, binary_type
from django.utils.translation import ugettext_lazy
diff --git a/tests/managers_regress/models.py b/tests/managers_regress/models.py
index 99494448bd..16849ed913 100644
--- a/tests/managers_regress/models.py
+++ b/tests/managers_regress/models.py
@@ -3,11 +3,11 @@ Various edge-cases for model managers.
"""
from django.contrib.contenttypes.fields import (
- GenericForeignKey, GenericRelation
+ GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
-from django.utils.encoding import python_2_unicode_compatible, force_text
+from django.utils.encoding import force_text, python_2_unicode_compatible
class OnlyFred(models.Manager):
diff --git a/tests/managers_regress/tests.py b/tests/managers_regress/tests.py
index af507f0b75..6f70314cb7 100644
--- a/tests/managers_regress/tests.py
+++ b/tests/managers_regress/tests.py
@@ -7,18 +7,8 @@ from django.test import TestCase, override_settings
from django.utils.encoding import force_text
from .models import (
- Child1,
- Child2,
- Child3,
- Child4,
- Child5,
- Child6,
- Child7,
- AbstractBase1,
- AbstractBase2,
- AbstractBase3,
- RelatedModel,
- RelationModel,
+ AbstractBase1, AbstractBase2, AbstractBase3, Child1, Child2, Child3,
+ Child4, Child5, Child6, Child7, RelatedModel, RelationModel,
)
diff --git a/tests/many_to_one/tests.py b/tests/many_to_one/tests.py
index b66cfde9ed..fdb77b4711 100644
--- a/tests/many_to_one/tests.py
+++ b/tests/many_to_one/tests.py
@@ -1,14 +1,16 @@
-from copy import deepcopy
import datetime
+from copy import deepcopy
-from django.core.exceptions import MultipleObjectsReturned, FieldError
+from django.core.exceptions import FieldError, MultipleObjectsReturned
from django.db import models, transaction
from django.test import TestCase
from django.utils import six
from django.utils.translation import ugettext_lazy
-from .models import (Article, Reporter, First, Third, Parent, Child,
- ToFieldChild, Category, Record, Relation, School, Student)
+from .models import (
+ Article, Category, Child, First, Parent, Record, Relation, Reporter,
+ School, Student, Third, ToFieldChild,
+)
class ManyToOneTests(TestCase):
diff --git a/tests/max_lengths/tests.py b/tests/max_lengths/tests.py
index 64edaa6f59..fa3cd4bddc 100644
--- a/tests/max_lengths/tests.py
+++ b/tests/max_lengths/tests.py
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
import unittest
-from .models import PersonWithDefaultMaxLengths, PersonWithCustomMaxLengths
+from .models import PersonWithCustomMaxLengths, PersonWithDefaultMaxLengths
class MaxLengthArgumentsTests(unittest.TestCase):
diff --git a/tests/middleware/test_security.py b/tests/middleware/test_security.py
index 66cbf5f7b2..7c0d50491a 100644
--- a/tests/middleware/test_security.py
+++ b/tests/middleware/test_security.py
@@ -1,5 +1,5 @@
from django.http import HttpResponse
-from django.test import TestCase, RequestFactory
+from django.test import RequestFactory, TestCase
from django.test.utils import override_settings
diff --git a/tests/middleware/tests.py b/tests/middleware/tests.py
index c7620732b5..1490094ef7 100644
--- a/tests/middleware/tests.py
+++ b/tests/middleware/tests.py
@@ -2,22 +2,24 @@
from __future__ import unicode_literals
import gzip
-from io import BytesIO
import random
import re
+from io import BytesIO
from unittest import skipIf
from django.conf import settings
from django.core import mail
from django.http import (
- HttpRequest, HttpResponse, StreamingHttpResponse, FileResponse,
- HttpResponseRedirect, HttpResponsePermanentRedirect,
+ FileResponse, HttpRequest, HttpResponse, HttpResponsePermanentRedirect,
+ HttpResponseRedirect, StreamingHttpResponse,
)
from django.middleware.clickjacking import XFrameOptionsMiddleware
-from django.middleware.common import CommonMiddleware, BrokenLinkEmailsMiddleware
-from django.middleware.http import ConditionalGetMiddleware
+from django.middleware.common import (
+ BrokenLinkEmailsMiddleware, CommonMiddleware,
+)
from django.middleware.gzip import GZipMiddleware
-from django.test import TestCase, RequestFactory, override_settings
+from django.middleware.http import ConditionalGetMiddleware
+from django.test import RequestFactory, TestCase, override_settings
from django.test.utils import patch_logger
from django.utils import six
from django.utils.encoding import force_str
diff --git a/tests/middleware/views.py b/tests/middleware/views.py
index c1ee23e893..50e23d1782 100644
--- a/tests/middleware/views.py
+++ b/tests/middleware/views.py
@@ -1,5 +1,5 @@
-from django.http import HttpResponse
-
-
-def empty_view(request, *args, **kwargs):
- return HttpResponse('')
+from django.http import HttpResponse
+
+
+def empty_view(request, *args, **kwargs):
+ return HttpResponse('')
diff --git a/tests/middleware_exceptions/tests.py b/tests/middleware_exceptions/tests.py
index 9c7a24ec22..3e6cbb747c 100644
--- a/tests/middleware_exceptions/tests.py
+++ b/tests/middleware_exceptions/tests.py
@@ -4,8 +4,8 @@ from django.conf import settings
from django.core.exceptions import MiddlewareNotUsed
from django.core.signals import got_request_exception
from django.http import HttpResponse
-from django.template.response import TemplateResponse
from django.template import engines
+from django.template.response import TemplateResponse
from django.test import RequestFactory, TestCase, override_settings
from django.test.utils import patch_logger
diff --git a/tests/migrate_signals/tests.py b/tests/migrate_signals/tests.py
index adb721e074..2e729fec41 100644
--- a/tests/migrate_signals/tests.py
+++ b/tests/migrate_signals/tests.py
@@ -1,10 +1,9 @@
from django.apps import apps
from django.core import management
from django.db.models import signals
-from django.test import override_settings, TestCase
+from django.test import TestCase, override_settings
from django.utils import six
-
APP_CONFIG = apps.get_app_config('migrate_signals')
PRE_MIGRATE_ARGS = ['app_config', 'verbosity', 'interactive', 'using']
MIGRATE_DATABASE = 'default'
diff --git a/tests/migration_test_data_persistence/migrations/0001_initial.py b/tests/migration_test_data_persistence/migrations/0001_initial.py
index d49c47b188..6c19c4c81c 100644
--- a/tests/migration_test_data_persistence/migrations/0001_initial.py
+++ b/tests/migration_test_data_persistence/migrations/0001_initial.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migration_test_data_persistence/tests.py b/tests/migration_test_data_persistence/tests.py
index 0b6369db4b..316cd21965 100644
--- a/tests/migration_test_data_persistence/tests.py
+++ b/tests/migration_test_data_persistence/tests.py
@@ -1,4 +1,5 @@
-from django.test import TransactionTestCase, TestCase
+from django.test import TestCase, TransactionTestCase
+
from .models import Book
diff --git a/tests/migrations/deprecated_field_migrations/0001_initial.py b/tests/migrations/deprecated_field_migrations/0001_initial.py
index 724f973405..624ea68016 100644
--- a/tests/migrations/deprecated_field_migrations/0001_initial.py
+++ b/tests/migrations/deprecated_field_migrations/0001_initial.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0001_initial.py b/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0001_initial.py
index c20e811696..09cda3c61f 100644
--- a/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0001_initial.py
+++ b/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0001_initial.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0002_a2.py b/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0002_a2.py
index 0c75368e04..e528f9ee5e 100644
--- a/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0002_a2.py
+++ b/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0002_a2.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0003_a3.py b/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0003_a3.py
index 655ea03216..34f3c6c062 100644
--- a/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0003_a3.py
+++ b/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0003_a3.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0004_a4.py b/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0004_a4.py
index c45faf587f..5a1ebfb684 100644
--- a/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0004_a4.py
+++ b/tests/migrations/migrations_test_apps/lookuperror_a/migrations/0004_a4.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migrations/migrations_test_apps/lookuperror_b/migrations/0001_initial.py b/tests/migrations/migrations_test_apps/lookuperror_b/migrations/0001_initial.py
index 67dafcae28..9cd50e24b8 100644
--- a/tests/migrations/migrations_test_apps/lookuperror_b/migrations/0001_initial.py
+++ b/tests/migrations/migrations_test_apps/lookuperror_b/migrations/0001_initial.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migrations/migrations_test_apps/lookuperror_b/migrations/0002_b2.py b/tests/migrations/migrations_test_apps/lookuperror_b/migrations/0002_b2.py
index 7972ef8d84..70ba124a0d 100644
--- a/tests/migrations/migrations_test_apps/lookuperror_b/migrations/0002_b2.py
+++ b/tests/migrations/migrations_test_apps/lookuperror_b/migrations/0002_b2.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migrations/migrations_test_apps/lookuperror_b/migrations/0003_b3.py b/tests/migrations/migrations_test_apps/lookuperror_b/migrations/0003_b3.py
index f5147c4f7f..746c49d0a1 100644
--- a/tests/migrations/migrations_test_apps/lookuperror_b/migrations/0003_b3.py
+++ b/tests/migrations/migrations_test_apps/lookuperror_b/migrations/0003_b3.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migrations/migrations_test_apps/lookuperror_c/migrations/0001_initial.py b/tests/migrations/migrations_test_apps/lookuperror_c/migrations/0001_initial.py
index c2e46bee70..bf9ec3d171 100644
--- a/tests/migrations/migrations_test_apps/lookuperror_c/migrations/0001_initial.py
+++ b/tests/migrations/migrations_test_apps/lookuperror_c/migrations/0001_initial.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migrations/migrations_test_apps/lookuperror_c/migrations/0002_c2.py b/tests/migrations/migrations_test_apps/lookuperror_c/migrations/0002_c2.py
index 1f7f440d83..12942c23b1 100644
--- a/tests/migrations/migrations_test_apps/lookuperror_c/migrations/0002_c2.py
+++ b/tests/migrations/migrations_test_apps/lookuperror_c/migrations/0002_c2.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migrations/migrations_test_apps/lookuperror_c/migrations/0003_c3.py b/tests/migrations/migrations_test_apps/lookuperror_c/migrations/0003_c3.py
index d4d48fc32f..f226cad458 100644
--- a/tests/migrations/migrations_test_apps/lookuperror_c/migrations/0003_c3.py
+++ b/tests/migrations/migrations_test_apps/lookuperror_c/migrations/0003_c3.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migrations/migrations_test_apps/unmigrated_app/models.py b/tests/migrations/migrations_test_apps/unmigrated_app/models.py
index c44e922d38..a06b4ac159 100644
--- a/tests/migrations/migrations_test_apps/unmigrated_app/models.py
+++ b/tests/migrations/migrations_test_apps/unmigrated_app/models.py
@@ -1,5 +1,6 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
+
from django.db import models
diff --git a/tests/migrations/test_autodetector.py b/tests/migrations/test_autodetector.py
index 9c878a2bea..3d822072ce 100644
--- a/tests/migrations/test_autodetector.py
+++ b/tests/migrations/test_autodetector.py
@@ -1,13 +1,13 @@
# -*- coding: utf-8 -*-
from django.conf import settings
-from django.test import TestCase, mock, override_settings
+from django.contrib.auth.models import AbstractBaseUser
+from django.db import connection, models
from django.db.migrations.autodetector import MigrationAutodetector
-from django.db.migrations.questioner import MigrationQuestioner
-from django.db.migrations.state import ProjectState, ModelState
from django.db.migrations.graph import MigrationGraph
from django.db.migrations.loader import MigrationLoader
-from django.db import models, connection
-from django.contrib.auth.models import AbstractBaseUser
+from django.db.migrations.questioner import MigrationQuestioner
+from django.db.migrations.state import ModelState, ProjectState
+from django.test import TestCase, mock, override_settings
from .models import FoodManager, FoodQuerySet
diff --git a/tests/migrations/test_commands.py b/tests/migrations/test_commands.py
index 0f86289cff..d69936636b 100644
--- a/tests/migrations/test_commands.py
+++ b/tests/migrations/test_commands.py
@@ -7,8 +7,8 @@ import os
import shutil
from django.apps import apps
+from django.core.management import CommandError, call_command
from django.db import connection, models
-from django.core.management import call_command, CommandError
from django.db.migrations import questioner
from django.test import ignore_warnings, mock, override_settings
from django.utils import six
diff --git a/tests/migrations/test_executor.py b/tests/migrations/test_executor.py
index 12385ac7da..e6482fb830 100644
--- a/tests/migrations/test_executor.py
+++ b/tests/migrations/test_executor.py
@@ -1,8 +1,8 @@
+from django.apps.registry import apps as global_apps
from django.db import connection
from django.db.migrations.executor import MigrationExecutor
from django.db.migrations.graph import MigrationGraph
-from django.test import modify_settings, override_settings, TestCase
-from django.apps.registry import apps as global_apps
+from django.test import TestCase, modify_settings, override_settings
from .test_base import MigrationTestBase
diff --git a/tests/migrations/test_graph.py b/tests/migrations/test_graph.py
index 89ad206897..cfb61d355f 100644
--- a/tests/migrations/test_graph.py
+++ b/tests/migrations/test_graph.py
@@ -1,5 +1,7 @@
+from django.db.migrations.graph import (
+ CircularDependencyError, MigrationGraph, NodeNotFoundError,
+)
from django.test import TestCase
-from django.db.migrations.graph import CircularDependencyError, MigrationGraph, NodeNotFoundError
from django.utils.encoding import force_text
diff --git a/tests/migrations/test_loader.py b/tests/migrations/test_loader.py
index 8df7b7aa9b..b189da0721 100644
--- a/tests/migrations/test_loader.py
+++ b/tests/migrations/test_loader.py
@@ -2,12 +2,11 @@ from __future__ import unicode_literals
from unittest import skipIf
-from django.test import TestCase, override_settings
from django.db import connection, connections
from django.db.migrations.graph import NodeNotFoundError
-from django.db.migrations.loader import MigrationLoader, AmbiguityError
+from django.db.migrations.loader import AmbiguityError, MigrationLoader
from django.db.migrations.recorder import MigrationRecorder
-from django.test import modify_settings
+from django.test import TestCase, modify_settings, override_settings
from django.utils import six
diff --git a/tests/migrations/test_migrations_custom_user/0001_initial.py b/tests/migrations/test_migrations_custom_user/0001_initial.py
index d7c37151f1..3a4523277d 100644
--- a/tests/migrations/test_migrations_custom_user/0001_initial.py
+++ b/tests/migrations/test_migrations_custom_user/0001_initial.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import migrations, models
from django.conf import settings
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migrations/test_migrations_no_changes/0003_third.py b/tests/migrations/test_migrations_no_changes/0003_third.py
index 2418bd5e9f..05b7535dc3 100644
--- a/tests/migrations/test_migrations_no_changes/0003_third.py
+++ b/tests/migrations/test_migrations_no_changes/0003_third.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migrations/test_migrations_no_default/0001_initial.py b/tests/migrations/test_migrations_no_default/0001_initial.py
index c30910e056..2fd027f2d2 100644
--- a/tests/migrations/test_migrations_no_default/0001_initial.py
+++ b/tests/migrations/test_migrations_no_default/0001_initial.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/migrations/test_multidb.py b/tests/migrations/test_multidb.py
index dec1d25dd0..90e03a400e 100644
--- a/tests/migrations/test_multidb.py
+++ b/tests/migrations/test_multidb.py
@@ -1,16 +1,16 @@
import unittest
-try:
- import sqlparse
-except ImportError:
- sqlparse = None
-
-from django.db import migrations, models, connection
+from django.db import connection, migrations, models
from django.db.migrations.state import ProjectState
from django.test import override_settings
from .test_operations import OperationTestBase
+try:
+ import sqlparse
+except ImportError:
+ sqlparse = None
+
class AgnosticRouter(object):
"""
diff --git a/tests/migrations/test_operations.py b/tests/migrations/test_operations.py
index d8a042d4ba..d27ca5eeb5 100644
--- a/tests/migrations/test_operations.py
+++ b/tests/migrations/test_operations.py
@@ -2,11 +2,6 @@ from __future__ import unicode_literals
import unittest
-try:
- import sqlparse
-except ImportError:
- sqlparse = None
-
from django.db import connection, migrations, models, transaction
from django.db.migrations.migration import Migration
from django.db.migrations.state import ProjectState
@@ -19,6 +14,11 @@ from django.utils import six
from .models import FoodManager, FoodQuerySet
from .test_base import MigrationTestBase
+try:
+ import sqlparse
+except ImportError:
+ sqlparse = None
+
class OperationTestBase(MigrationTestBase):
"""
diff --git a/tests/migrations/test_optimizer.py b/tests/migrations/test_optimizer.py
index cb89a85c2d..e639752082 100644
--- a/tests/migrations/test_optimizer.py
+++ b/tests/migrations/test_optimizer.py
@@ -1,9 +1,8 @@
# -*- coding: utf-8 -*-
-from django.test import TestCase
+from django.db import migrations, models
from django.db.migrations.optimizer import MigrationOptimizer
-from django.db import migrations
-from django.db import models
+from django.test import TestCase
from .models import CustomModelBase, EmptyManager
diff --git a/tests/migrations/test_state.py b/tests/migrations/test_state.py
index a7dbdbe11c..7db3565657 100644
--- a/tests/migrations/test_state.py
+++ b/tests/migrations/test_state.py
@@ -1,11 +1,14 @@
from django.apps.registry import Apps
from django.db import models
from django.db.migrations.operations import RemoveField
-from django.db.migrations.state import ProjectState, ModelState, InvalidBasesError
+from django.db.migrations.state import (
+ InvalidBasesError, ModelState, ProjectState,
+)
from django.test import TestCase
-from .models import (FoodManager, FoodQuerySet, ModelWithCustomBase,
- NoMigrationFoodManager)
+from .models import (
+ FoodManager, FoodQuerySet, ModelWithCustomBase, NoMigrationFoodManager,
+)
class StateTests(TestCase):
diff --git a/tests/migrations/test_writer.py b/tests/migrations/test_writer.py
index 6c6a654365..38065fbb1a 100644
--- a/tests/migrations/test_writer.py
+++ b/tests/migrations/test_writer.py
@@ -8,20 +8,22 @@ import re
import tokenize
import unittest
-from django.core.validators import RegexValidator, EmailValidator
-from django.db import models, migrations
-from django.db.migrations.writer import MigrationWriter, OperationWriter, SettingsReference
-from django.test import SimpleTestCase, TestCase, ignore_warnings
+import custom_migration_operations.more_operations
+import custom_migration_operations.operations
+
from django.conf import settings
+from django.core.validators import EmailValidator, RegexValidator
+from django.db import migrations, models
+from django.db.migrations.writer import (
+ MigrationWriter, OperationWriter, SettingsReference,
+)
+from django.test import SimpleTestCase, TestCase, ignore_warnings
from django.utils import datetime_safe, six
from django.utils.deconstruct import deconstructible
+from django.utils.timezone import FixedOffset, get_default_timezone, utc
from django.utils.translation import ugettext_lazy as _
-from django.utils.timezone import get_default_timezone, utc, FixedOffset
-
-import custom_migration_operations.operations
-import custom_migration_operations.more_operations
-from .models import FoodQuerySet, FoodManager
+from .models import FoodManager, FoodQuerySet
class TestModel1(object):
diff --git a/tests/model_fields/models.py b/tests/model_fields/models.py
index 9a6a3f1f36..ee2f807146 100644
--- a/tests/model_fields/models.py
+++ b/tests/model_fields/models.py
@@ -2,21 +2,23 @@ import os
import tempfile
import uuid
-try:
- from PIL import Image
-except ImportError:
- Image = None
-
-from django.core.files.storage import FileSystemStorage
-from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
+from django.contrib.contenttypes.fields import (
+ GenericForeignKey, GenericRelation,
+)
from django.contrib.contenttypes.models import ContentType
+from django.core.files.storage import FileSystemStorage
+from django.db import models
+from django.db.models.fields.files import ImageField, ImageFieldFile
from django.db.models.fields.related import (
- ForeignObject, ForeignKey, ManyToManyField, OneToOneField,
+ ForeignKey, ForeignObject, ManyToManyField, OneToOneField,
)
-from django.db import models
-from django.db.models.fields.files import ImageFieldFile, ImageField
from django.utils import six
+try:
+ from PIL import Image
+except ImportError:
+ Image = None
+
class Foo(models.Model):
a = models.CharField(max_length=10)
diff --git a/tests/model_fields/test_field_flags.py b/tests/model_fields/test_field_flags.py
index 08a57db501..3749e55452 100644
--- a/tests/model_fields/test_field_flags.py
+++ b/tests/model_fields/test_field_flags.py
@@ -1,17 +1,15 @@
from django import test
-
from django.contrib.contenttypes.fields import (
GenericForeignKey, GenericRelation,
)
from django.db import models
from django.db.models.fields.related import (
- ForeignObject, ForeignKey, OneToOneField, ManyToManyField,
- ManyToOneRel, ForeignObjectRel,
+ ForeignKey, ForeignObject, ForeignObjectRel, ManyToManyField, ManyToOneRel,
+ OneToOneField,
)
from .models import AllFieldsModel
-
NON_CONCRETE_FIELDS = (
ForeignObject,
GenericForeignKey,
diff --git a/tests/model_fields/test_uuid.py b/tests/model_fields/test_uuid.py
index d2ffe71a3a..4680d5dbb4 100644
--- a/tests/model_fields/test_uuid.py
+++ b/tests/model_fields/test_uuid.py
@@ -5,7 +5,7 @@ from django.core import exceptions, serializers
from django.db import models
from django.test import TestCase
-from .models import UUIDModel, NullableUUIDModel, PrimaryKeyUUIDModel
+from .models import NullableUUIDModel, PrimaryKeyUUIDModel, UUIDModel
class TestSaveLoad(TestCase):
diff --git a/tests/model_fields/tests.py b/tests/model_fields/tests.py
index 5c8c8109d1..8894ef9158 100644
--- a/tests/model_fields/tests.py
+++ b/tests/model_fields/tests.py
@@ -1,22 +1,21 @@
from __future__ import unicode_literals
import datetime
-from decimal import Decimal
import unittest
+from decimal import Decimal
-from django import test
-from django import forms
-from django.core import validators
-from django.core import checks
+from django import forms, test
+from django.core import checks, validators
from django.core.exceptions import ValidationError
-from django.db import connection, transaction, models, IntegrityError
+from django.db import IntegrityError, connection, models, transaction
from django.db.models.fields import (
- AutoField, BigIntegerField, BinaryField, BooleanField, CharField,
- CommaSeparatedIntegerField, DateField, DateTimeField, DecimalField,
- EmailField, FilePathField, FloatField, IntegerField, IPAddressField,
- GenericIPAddressField, NOT_PROVIDED, NullBooleanField, PositiveIntegerField,
+ NOT_PROVIDED, AutoField, BigIntegerField, BinaryField, BooleanField,
+ CharField, CommaSeparatedIntegerField, DateField, DateTimeField,
+ DecimalField, EmailField, FilePathField, FloatField, GenericIPAddressField,
+ IntegerField, IPAddressField, NullBooleanField, PositiveIntegerField,
PositiveSmallIntegerField, SlugField, SmallIntegerField, TextField,
- TimeField, URLField)
+ TimeField, URLField,
+)
from django.db.models.fields.files import FileField, ImageField
from django.utils import six
from django.utils.functional import lazy
@@ -24,9 +23,10 @@ from django.utils.functional import lazy
from .models import (
Bar, BigD, BigIntegerModel, BigS, BooleanModel, DataModel, DateTimeModel,
Document, FksToBooleans, FkToChar, FloatModel, Foo, GenericIPAddress,
- IntegerModel, NullBooleanModel, PositiveIntegerModel, PositiveSmallIntegerModel,
- Post, PrimaryKeyCharModel, RenamedField, SmallIntegerModel, VerboseNameField,
- Whiz, WhizIter, WhizIterEmpty)
+ IntegerModel, NullBooleanModel, PositiveIntegerModel,
+ PositiveSmallIntegerModel, Post, PrimaryKeyCharModel, RenamedField,
+ SmallIntegerModel, VerboseNameField, Whiz, WhizIter, WhizIterEmpty,
+)
class BasicFieldTests(test.TestCase):
diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py
index d2b55c4e10..ac3c6062a2 100644
--- a/tests/model_forms/models.py
+++ b/tests/model_forms/models.py
@@ -17,10 +17,9 @@ from django.core.exceptions import ValidationError
from django.core.files.storage import FileSystemStorage
from django.db import models
from django.utils import six
+from django.utils._os import upath
from django.utils.encoding import python_2_unicode_compatible
from django.utils.six.moves import range
-from django.utils._os import upath
-
temp_storage_dir = tempfile.mkdtemp(dir=os.environ['DJANGO_TEST_TEMP_DIR'])
temp_storage = FileSystemStorage(temp_storage_dir)
diff --git a/tests/model_forms/tests.py b/tests/model_forms/tests.py
index 4bb7c47eb2..82fc0925d0 100644
--- a/tests/model_forms/tests.py
+++ b/tests/model_forms/tests.py
@@ -6,25 +6,31 @@ from decimal import Decimal
from unittest import skipUnless
from django import forms
-from django.core.exceptions import FieldError, ImproperlyConfigured, NON_FIELD_ERRORS
+from django.core.exceptions import (
+ NON_FIELD_ERRORS, FieldError, ImproperlyConfigured,
+)
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.validators import ValidationError
from django.db import connection
from django.db.models.query import EmptyQuerySet
-from django.forms.models import (construct_instance, fields_for_model,
- model_to_dict, modelform_factory, ModelFormMetaclass)
-from django.template import Template, Context
+from django.forms.models import (
+ ModelFormMetaclass, construct_instance, fields_for_model, model_to_dict,
+ modelform_factory,
+)
+from django.template import Context, Template
from django.test import TestCase, skipUnlessDBFeature
-from django.utils._os import upath
from django.utils import six
+from django.utils._os import upath
-from .models import (Article, ArticleStatus, Author, Author1, BetterWriter, BigInt, Book,
- Category, CommaSeparatedInteger, CustomFF, CustomFieldForExclusionModel,
- DerivedBook, DerivedPost, Document, ExplicitPK, FilePathModel, FlexibleDatePost, Homepage,
- ImprovedArticle, ImprovedArticleWithParentLink, Inventory, Person, Photo, Post, Price,
- Product, Publication, TextFile, Triple, Writer, WriterProfile,
- Colour, ColourfulItem, DateTimePost, CustomErrorMessage,
- test_images, StumpJoke, Character, Student)
+from .models import (
+ Article, ArticleStatus, Author, Author1, BetterWriter, BigInt, Book,
+ Category, Character, Colour, ColourfulItem, CommaSeparatedInteger,
+ CustomErrorMessage, CustomFF, CustomFieldForExclusionModel, DateTimePost,
+ DerivedBook, DerivedPost, Document, ExplicitPK, FilePathModel,
+ FlexibleDatePost, Homepage, ImprovedArticle, ImprovedArticleWithParentLink,
+ Inventory, Person, Photo, Post, Price, Product, Publication, Student,
+ StumpJoke, TextFile, Triple, Writer, WriterProfile, test_images,
+)
if test_images:
from .models import ImageFile, OptionalImageFile
diff --git a/tests/model_formsets/tests.py b/tests/model_formsets/tests.py
index acd05c9bf2..2d0380195b 100644
--- a/tests/model_formsets/tests.py
+++ b/tests/model_formsets/tests.py
@@ -8,16 +8,20 @@ from decimal import Decimal
from django import forms
from django.core.exceptions import ImproperlyConfigured
from django.db import models
-from django.forms.models import (_get_foreign_key, inlineformset_factory,
- modelformset_factory, BaseModelFormSet)
+from django.forms.models import (
+ BaseModelFormSet, _get_foreign_key, inlineformset_factory,
+ modelformset_factory,
+)
from django.test import TestCase, skipUnlessDBFeature
from django.utils import six
-from .models import (Author, BetterAuthor, Book, BookWithCustomPK,
- BookWithOptionalAltEditor, AlternateBook, AuthorMeeting, CustomPrimaryKey,
- Place, Owner, Location, OwnerProfile, Restaurant, Product, Price,
- MexicanRestaurant, ClassyMexicanRestaurant, Repository, Revision,
- Person, Membership, Team, Player, Poet, Poem, Post)
+from .models import (
+ AlternateBook, Author, AuthorMeeting, BetterAuthor, Book, BookWithCustomPK,
+ BookWithOptionalAltEditor, ClassyMexicanRestaurant, CustomPrimaryKey,
+ Location, Membership, MexicanRestaurant, Owner, OwnerProfile, Person,
+ Place, Player, Poem, Poet, Post, Price, Product, Repository, Restaurant,
+ Revision, Team,
+)
class DeletionTests(TestCase):
diff --git a/tests/model_formsets_regress/tests.py b/tests/model_formsets_regress/tests.py
index 8982efed51..d9e87ec046 100644
--- a/tests/model_formsets_regress/tests.py
+++ b/tests/model_formsets_regress/tests.py
@@ -1,15 +1,18 @@
from __future__ import unicode_literals
from django import forms
-from django.forms.formsets import BaseFormSet, DELETION_FIELD_NAME
+from django.forms.formsets import DELETION_FIELD_NAME, BaseFormSet
+from django.forms.models import (
+ BaseModelFormSet, inlineformset_factory, modelform_factory,
+ modelformset_factory,
+)
from django.forms.utils import ErrorDict, ErrorList
-from django.forms.models import modelform_factory, inlineformset_factory, modelformset_factory, BaseModelFormSet
from django.test import TestCase
from django.utils import six
from .models import (
- User, UserSite, UserProfile, ProfileNetwork, Restaurant, Manager, Network,
- Host,
+ Host, Manager, Network, ProfileNetwork, Restaurant, User, UserProfile,
+ UserSite,
)
diff --git a/tests/model_inheritance/models.py b/tests/model_inheritance/models.py
index af28159757..a77ab15f70 100644
--- a/tests/model_inheritance/models.py
+++ b/tests/model_inheritance/models.py
@@ -16,6 +16,7 @@ from __future__ import unicode_literals
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
+
#
# Abstract base classes
#
diff --git a/tests/model_inheritance/same_model_name/models.py b/tests/model_inheritance/same_model_name/models.py
index 307a505ee6..6b45e28dfe 100644
--- a/tests/model_inheritance/same_model_name/models.py
+++ b/tests/model_inheritance/same_model_name/models.py
@@ -5,9 +5,9 @@ requiring an %(app_label)s format string. This app tests this feature by
redefining the Copy model from model_inheritance/models.py.
"""
-from django.db import models
-
from model_inheritance.models import NamedURL
+
+from django.db import models
from django.utils.encoding import python_2_unicode_compatible
diff --git a/tests/model_inheritance/tests.py b/tests/model_inheritance/tests.py
index a732464e69..3c4f71d934 100644
--- a/tests/model_inheritance/tests.py
+++ b/tests/model_inheritance/tests.py
@@ -10,9 +10,10 @@ from django.test.utils import CaptureQueriesContext
from django.utils import six
from .models import (
- Chef, CommonInfo, ItalianRestaurant, ParkingLot, Place, Post,
- Restaurant, Student, Supplier, Worker, MixinModel,
- Title, Copy, Base, SubBase, GrandParent, GrandChild)
+ Base, Chef, CommonInfo, Copy, GrandChild, GrandParent, ItalianRestaurant,
+ MixinModel, ParkingLot, Place, Post, Restaurant, Student, SubBase,
+ Supplier, Title, Worker,
+)
class ModelInheritanceTests(TestCase):
diff --git a/tests/model_inheritance_regress/tests.py b/tests/model_inheritance_regress/tests.py
index 7e1c4b81bf..6d916bf6e4 100644
--- a/tests/model_inheritance_regress/tests.py
+++ b/tests/model_inheritance_regress/tests.py
@@ -10,12 +10,14 @@ from unittest import expectedFailure
from django import forms
from django.test import TestCase
-from .models import (Place, Restaurant, ItalianRestaurant, ParkingLot,
- ParkingLot2, ParkingLot3, Supplier, Wholesaler, Child, SelfRefParent,
- SelfRefChild, ArticleWithAuthor, M2MChild, QualityControl, DerivedM,
- Person, BirthdayParty, BachelorParty, MessyBachelorParty,
- InternalCertificationAudit, BusStation, TrainStation, User, Profile,
- ParkingLot4A, ParkingLot4B, Senator)
+from .models import (
+ ArticleWithAuthor, BachelorParty, BirthdayParty, BusStation, Child,
+ DerivedM, InternalCertificationAudit, ItalianRestaurant, M2MChild,
+ MessyBachelorParty, ParkingLot, ParkingLot2, ParkingLot3, ParkingLot4A,
+ ParkingLot4B, Person, Place, Profile, QualityControl, Restaurant,
+ SelfRefChild, SelfRefParent, Senator, Supplier, TrainStation, User,
+ Wholesaler,
+)
class ModelInheritanceTest(TestCase):
diff --git a/tests/model_meta/models.py b/tests/model_meta/models.py
index b4ed9f89d2..6ce36ed9d6 100644
--- a/tests/model_meta/models.py
+++ b/tests/model_meta/models.py
@@ -1,7 +1,8 @@
-from django.db import models
-
-from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
+from django.contrib.contenttypes.fields import (
+ GenericForeignKey, GenericRelation,
+)
from django.contrib.contenttypes.models import ContentType
+from django.db import models
class Relation(models.Model):
diff --git a/tests/model_meta/results.py b/tests/model_meta/results.py
index 1efc49ed23..d70963206f 100644
--- a/tests/model_meta/results.py
+++ b/tests/model_meta/results.py
@@ -1,6 +1,4 @@
-from .models import (
- AbstractPerson, BasePerson, Person, Relating, Relation,
-)
+from .models import AbstractPerson, BasePerson, Person, Relating, Relation
TEST_RESULTS = {
'get_all_field_names': {
diff --git a/tests/model_meta/test_legacy.py b/tests/model_meta/test_legacy.py
index 60bfb1641f..c319f28fcc 100644
--- a/tests/model_meta/test_legacy.py
+++ b/tests/model_meta/test_legacy.py
@@ -3,7 +3,7 @@ import warnings
from django import test
from django.contrib.contenttypes.fields import GenericRelation
from django.core.exceptions import FieldDoesNotExist
-from django.db.models.fields import related, CharField
+from django.db.models.fields import CharField, related
from django.utils.deprecation import RemovedInDjango20Warning
from .models import BasePerson, Person
diff --git a/tests/model_meta/tests.py b/tests/model_meta/tests.py
index 36b65f5ab8..4a08b408c6 100644
--- a/tests/model_meta/tests.py
+++ b/tests/model_meta/tests.py
@@ -1,13 +1,15 @@
from django.apps import apps
-from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
+from django.contrib.contenttypes.fields import (
+ GenericForeignKey, GenericRelation,
+)
from django.core.exceptions import FieldDoesNotExist
-from django.db.models.fields import related, CharField, Field
-from django.db.models.options import IMMUTABLE_WARNING, EMPTY_RELATION_TREE
+from django.db.models.fields import CharField, Field, related
+from django.db.models.options import EMPTY_RELATION_TREE, IMMUTABLE_WARNING
from django.test import TestCase
from .models import (
- Relation, AbstractPerson, BasePerson, Person, ProxyPerson, Relating,
- CommonAncestor, FirstParent, SecondParent, Child
+ AbstractPerson, BasePerson, Child, CommonAncestor, FirstParent, Person,
+ ProxyPerson, Relating, Relation, SecondParent,
)
from .results import TEST_RESULTS
diff --git a/tests/model_options/models/tablespaces.py b/tests/model_options/models/tablespaces.py
index 56e22e973a..7328a3df6e 100644
--- a/tests/model_options/models/tablespaces.py
+++ b/tests/model_options/models/tablespaces.py
@@ -1,5 +1,6 @@
from django.db import models
+
# Since the test database doesn't have tablespaces, it's impossible for Django
# to create the tables for models where db_tablespace is set. To avoid this
# problem, we mark the models as unmanaged, and temporarily revert them to
diff --git a/tests/model_options/test_default_related_name.py b/tests/model_options/test_default_related_name.py
index 6cdffe5cf9..a30de192cb 100644
--- a/tests/model_options/test_default_related_name.py
+++ b/tests/model_options/test_default_related_name.py
@@ -1,6 +1,6 @@
from django.test import TestCase
-from .models.default_related_name import Author, Editor, Book
+from .models.default_related_name import Author, Book, Editor
class DefaultRelatedNameTests(TestCase):
diff --git a/tests/model_options/test_tablespaces.py b/tests/model_options/test_tablespaces.py
index 515cd8a032..e8372e1bc7 100644
--- a/tests/model_options/test_tablespaces.py
+++ b/tests/model_options/test_tablespaces.py
@@ -5,8 +5,9 @@ from django.conf import settings
from django.db import connection
from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature
-from .models.tablespaces import (Article, ArticleRef, Authors, Reviewers,
- Scientist, ScientistRef)
+from .models.tablespaces import (
+ Article, ArticleRef, Authors, Reviewers, Scientist, ScientistRef,
+)
def sql_for_table(model):
diff --git a/tests/model_package/tests.py b/tests/model_package/tests.py
index c0a65b2ad6..9d1b81fa2a 100644
--- a/tests/model_package/tests.py
+++ b/tests/model_package/tests.py
@@ -1,11 +1,11 @@
from __future__ import unicode_literals
-from django.db import models, connection
+from django.db import connection, models
from django.db.backends.utils import truncate_name
from django.test import TestCase
-from .models.publication import Publication
from .models.article import Article, Site
+from .models.publication import Publication
class Advertisement(models.Model):
diff --git a/tests/model_permalink/views.py b/tests/model_permalink/views.py
index c1ee23e893..50e23d1782 100644
--- a/tests/model_permalink/views.py
+++ b/tests/model_permalink/views.py
@@ -1,5 +1,5 @@
-from django.http import HttpResponse
-
-
-def empty_view(request, *args, **kwargs):
- return HttpResponse('')
+from django.http import HttpResponse
+
+
+def empty_view(request, *args, **kwargs):
+ return HttpResponse('')
diff --git a/tests/model_regress/models.py b/tests/model_regress/models.py
index c42b0f0d35..b899baf6ea 100644
--- a/tests/model_regress/models.py
+++ b/tests/model_regress/models.py
@@ -4,7 +4,6 @@ from __future__ import unicode_literals
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
-
CHOICES = (
(1, 'first'),
(2, 'second'),
diff --git a/tests/model_regress/test_pickle.py b/tests/model_regress/test_pickle.py
index 64d2f6df5f..9f3725ad18 100644
--- a/tests/model_regress/test_pickle.py
+++ b/tests/model_regress/test_pickle.py
@@ -5,8 +5,8 @@ import subprocess
import sys
import warnings
-from django.db import models, DJANGO_VERSION_PICKLE_KEY
from django.core.files.temp import NamedTemporaryFile
+from django.db import DJANGO_VERSION_PICKLE_KEY, models
from django.test import TestCase
from django.utils.encoding import force_text
from django.utils.version import get_major_version, get_version
diff --git a/tests/model_regress/tests.py b/tests/model_regress/tests.py
index 49ef6b98cd..feb81f32bc 100644
--- a/tests/model_regress/tests.py
+++ b/tests/model_regress/tests.py
@@ -4,14 +4,16 @@ import datetime
from operator import attrgetter
from django.core.exceptions import ValidationError
+from django.db import router
+from django.db.models.sql import InsertQuery
from django.test import TestCase, skipUnlessDBFeature
from django.utils import six
from django.utils.timezone import get_fixed_timezone
-from django.db import router
-from django.db.models.sql import InsertQuery
-from .models import (Worker, Article, Party, Event, Department,
- BrokenUnicodeMethod, NonAutoPK, Model1, Model2, Model3)
+from .models import (
+ Article, BrokenUnicodeMethod, Department, Event, Model1, Model2, Model3,
+ NonAutoPK, Party, Worker,
+)
class ModelTests(TestCase):
diff --git a/tests/model_validation/tests.py b/tests/model_validation/tests.py
index 50ccfd2de6..677e21b37a 100644
--- a/tests/model_validation/tests.py
+++ b/tests/model_validation/tests.py
@@ -1,9 +1,9 @@
from django.core import management
-from django.core.checks import run_checks, Error
+from django.core.checks import Error, run_checks
from django.db.models.signals import post_init
from django.test import TestCase
-from django.utils import six
from django.test.utils import override_settings
+from django.utils import six
class OnPostInit(object):
diff --git a/tests/modeladmin/tests.py b/tests/modeladmin/tests.py
index 6157d6c1d4..cc9c8f2de0 100644
--- a/tests/modeladmin/tests.py
+++ b/tests/modeladmin/tests.py
@@ -3,19 +3,21 @@ from __future__ import unicode_literals
from datetime import date
from django import forms
-from django.contrib.admin.options import (ModelAdmin, TabularInline,
- HORIZONTAL, VERTICAL)
+from django.contrib.admin import BooleanFieldListFilter, SimpleListFilter
+from django.contrib.admin.options import (
+ HORIZONTAL, VERTICAL, ModelAdmin, TabularInline,
+)
from django.contrib.admin.sites import AdminSite
from django.contrib.admin.widgets import AdminDateWidget, AdminRadioSelect
-from django.contrib.admin import (SimpleListFilter,
- BooleanFieldListFilter)
from django.core.checks import Error
from django.forms.models import BaseModelFormSet
from django.forms.widgets import Select
from django.test import TestCase
from django.utils import six
-from .models import Band, Concert, ValidationTestModel, ValidationTestInlineModel
+from .models import (
+ Band, Concert, ValidationTestInlineModel, ValidationTestModel,
+)
class MockRequest(object):
diff --git a/tests/multiple_database/models.py b/tests/multiple_database/models.py
index e02bb17f27..e5d3e723e4 100644
--- a/tests/multiple_database/models.py
+++ b/tests/multiple_database/models.py
@@ -1,6 +1,6 @@
from django.contrib.auth.models import User
from django.contrib.contenttypes.fields import (
- GenericForeignKey, GenericRelation
+ GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
diff --git a/tests/multiple_database/tests.py b/tests/multiple_database/tests.py
index e0fc431dd0..5da69b560f 100644
--- a/tests/multiple_database/tests.py
+++ b/tests/multiple_database/tests.py
@@ -7,14 +7,14 @@ from operator import attrgetter
from django.contrib.auth.models import User
from django.contrib.contenttypes.models import ContentType
from django.core import management
-from django.db import connections, router, DEFAULT_DB_ALIAS, transaction
+from django.db import DEFAULT_DB_ALIAS, connections, router, transaction
from django.db.models import signals
from django.db.utils import ConnectionRouter
from django.test import TestCase, override_settings
from django.utils.six import StringIO
from .models import Book, Person, Pet, Review, UserProfile
-from .routers import TestRouter, AuthRouter, WriteRouter
+from .routers import AuthRouter, TestRouter, WriteRouter
class QueryTestCase(TestCase):
diff --git a/tests/nested_foreign_keys/tests.py b/tests/nested_foreign_keys/tests.py
index e08922aefb..80c09810a4 100644
--- a/tests/nested_foreign_keys/tests.py
+++ b/tests/nested_foreign_keys/tests.py
@@ -2,7 +2,9 @@ from __future__ import unicode_literals
from django.test import TestCase
-from .models import Person, Movie, Event, Screening, ScreeningNullFK, Package, PackageNullFK
+from .models import (
+ Event, Movie, Package, PackageNullFK, Person, Screening, ScreeningNullFK,
+)
# These are tests for #16715. The basic scheme is always the same: 3 models with
diff --git a/tests/null_fk/tests.py b/tests/null_fk/tests.py
index 26eae6491e..008c0981e6 100644
--- a/tests/null_fk/tests.py
+++ b/tests/null_fk/tests.py
@@ -3,8 +3,9 @@ from __future__ import unicode_literals
from django.db.models import Q
from django.test import TestCase
-from .models import (SystemDetails, Item, PropertyValue, SystemInfo, Forum,
- Post, Comment)
+from .models import (
+ Comment, Forum, Item, Post, PropertyValue, SystemDetails, SystemInfo,
+)
class NullFkTests(TestCase):
diff --git a/tests/null_fk_ordering/tests.py b/tests/null_fk_ordering/tests.py
index 2fe48f0b19..7215118b94 100644
--- a/tests/null_fk_ordering/tests.py
+++ b/tests/null_fk_ordering/tests.py
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
from django.test import TestCase
-from .models import Author, Article, SystemInfo, Forum, Post, Comment
+from .models import Article, Author, Comment, Forum, Post, SystemInfo
class NullFkOrderingTests(TestCase):
diff --git a/tests/null_queries/tests.py b/tests/null_queries/tests.py
index 1b73c977b4..8c8ca3f28d 100644
--- a/tests/null_queries/tests.py
+++ b/tests/null_queries/tests.py
@@ -1,9 +1,9 @@
from __future__ import unicode_literals
-from django.test import TestCase
from django.core.exceptions import FieldError
+from django.test import TestCase
-from .models import Poll, Choice, OuterA, Inner, OuterB
+from .models import Choice, Inner, OuterA, OuterB, Poll
class NullQueriesTests(TestCase):
diff --git a/tests/one_to_one/tests.py b/tests/one_to_one/tests.py
index 73d76d4a48..d7d5793b0a 100644
--- a/tests/one_to_one/tests.py
+++ b/tests/one_to_one/tests.py
@@ -1,10 +1,12 @@
from __future__ import unicode_literals
-from django.db import transaction, IntegrityError, connection
+from django.db import IntegrityError, connection, transaction
from django.test import TestCase
-from .models import (Bar, Favorites, HiddenPointer, ManualPrimaryKey, MultiModel,
- Place, RelatedModel, Restaurant, School, Director, Target, UndergroundBar, Waiter)
+from .models import (
+ Bar, Director, Favorites, HiddenPointer, ManualPrimaryKey, MultiModel,
+ Place, RelatedModel, Restaurant, School, Target, UndergroundBar, Waiter,
+)
class OneToOneTests(TestCase):
diff --git a/tests/order_with_respect_to/tests.py b/tests/order_with_respect_to/tests.py
index 8fc09b496b..60181cca4b 100644
--- a/tests/order_with_respect_to/tests.py
+++ b/tests/order_with_respect_to/tests.py
@@ -2,11 +2,10 @@ from __future__ import unicode_literals
from operator import attrgetter
-from django.test import TestCase
-
from django.db import models
+from django.test import TestCase
-from .models import Post, Question, Answer
+from .models import Answer, Post, Question
class OrderWithRespectToTests(TestCase):
diff --git a/tests/pagination/custom.py b/tests/pagination/custom.py
index 47a932c7e3..77277dca5b 100644
--- a/tests/pagination/custom.py
+++ b/tests/pagination/custom.py
@@ -1,4 +1,4 @@
-from django.core.paginator import Paginator, Page
+from django.core.paginator import Page, Paginator
class ValidAdjacentNumsPage(Page):
diff --git a/tests/pagination/tests.py b/tests/pagination/tests.py
index 7f405cffaa..0757859628 100644
--- a/tests/pagination/tests.py
+++ b/tests/pagination/tests.py
@@ -1,15 +1,16 @@
from __future__ import unicode_literals
-from datetime import datetime
import unittest
+from datetime import datetime
-from django.core.paginator import (Paginator, EmptyPage, InvalidPage,
- PageNotAnInteger)
+from django.core.paginator import (
+ EmptyPage, InvalidPage, PageNotAnInteger, Paginator,
+)
from django.test import TestCase
from django.utils import six
-from .models import Article
from .custom import ValidAdjacentNumsPaginator
+from .models import Article
class PaginationTests(unittest.TestCase):
diff --git a/tests/postgres_tests/array_default_migrations/0001_initial.py b/tests/postgres_tests/array_default_migrations/0001_initial.py
index 0b7eb77c3d..14734d3670 100644
--- a/tests/postgres_tests/array_default_migrations/0001_initial.py
+++ b/tests/postgres_tests/array_default_migrations/0001_initial.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
import django.contrib.postgres.fields
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/postgres_tests/array_default_migrations/0002_integerarraymodel_field_2.py b/tests/postgres_tests/array_default_migrations/0002_integerarraymodel_field_2.py
index 074c2f70e5..0ee5a83c5e 100644
--- a/tests/postgres_tests/array_default_migrations/0002_integerarraymodel_field_2.py
+++ b/tests/postgres_tests/array_default_migrations/0002_integerarraymodel_field_2.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
import django.contrib.postgres.fields
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/postgres_tests/migrations/0001_setup_extensions.py b/tests/postgres_tests/migrations/0001_setup_extensions.py
index 0c43974954..0915b74343 100644
--- a/tests/postgres_tests/migrations/0001_setup_extensions.py
+++ b/tests/postgres_tests/migrations/0001_setup_extensions.py
@@ -1,7 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.contrib.postgres.operations import HStoreExtension, UnaccentExtension
+from django.contrib.postgres.operations import (
+ HStoreExtension, UnaccentExtension,
+)
from django.db import migrations
diff --git a/tests/postgres_tests/migrations/0002_create_test_models.py b/tests/postgres_tests/migrations/0002_create_test_models.py
index 841953d351..c4f031f6d0 100644
--- a/tests/postgres_tests/migrations/0002_create_test_models.py
+++ b/tests/postgres_tests/migrations/0002_create_test_models.py
@@ -1,9 +1,9 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
import django.contrib.postgres.fields
import django.contrib.postgres.fields.hstore
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/postgres_tests/models.py b/tests/postgres_tests/models.py
index 0422aba6a0..f698d56a58 100644
--- a/tests/postgres_tests/models.py
+++ b/tests/postgres_tests/models.py
@@ -1,6 +1,6 @@
from django.contrib.postgres.fields import (
- ArrayField, HStoreField, IntegerRangeField, BigIntegerRangeField,
- FloatRangeField, DateTimeRangeField, DateRangeField,
+ ArrayField, BigIntegerRangeField, DateRangeField, DateTimeRangeField,
+ FloatRangeField, HStoreField, IntegerRangeField,
)
from django.db import connection, models
diff --git a/tests/postgres_tests/test_array.py b/tests/postgres_tests/test_array.py
index 020b31658f..8edc78d65c 100644
--- a/tests/postgres_tests/test_array.py
+++ b/tests/postgres_tests/test_array.py
@@ -3,19 +3,18 @@ import json
import unittest
import uuid
+from django import forms
from django.contrib.postgres.fields import ArrayField
from django.contrib.postgres.forms import SimpleArrayField, SplitArrayField
from django.core import exceptions, serializers
from django.core.management import call_command
-from django.db import models, IntegrityError, connection
-from django import forms
+from django.db import IntegrityError, connection, models
from django.test import TestCase, override_settings
from django.utils import timezone
from .models import (
- IntegerArrayModel, NullableIntegerArrayModel, CharArrayModel,
- DateTimeArrayModel, NestedIntegerArrayModel, OtherTypesArrayModel,
- ArrayFieldSubclass,
+ ArrayFieldSubclass, CharArrayModel, DateTimeArrayModel, IntegerArrayModel,
+ NestedIntegerArrayModel, NullableIntegerArrayModel, OtherTypesArrayModel,
)
diff --git a/tests/postgres_tests/test_ranges.py b/tests/postgres_tests/test_ranges.py
index bc15987ba7..c26382a15b 100644
--- a/tests/postgres_tests/test_ranges.py
+++ b/tests/postgres_tests/test_ranges.py
@@ -2,16 +2,18 @@ import datetime
import json
import unittest
+from psycopg2.extras import DateRange, DateTimeTZRange, NumericRange
+
from django import forms
-from django.contrib.postgres import forms as pg_forms, fields as pg_fields
-from django.contrib.postgres.validators import RangeMaxValueValidator, RangeMinValueValidator
+from django.contrib.postgres import fields as pg_fields, forms as pg_forms
+from django.contrib.postgres.validators import (
+ RangeMaxValueValidator, RangeMinValueValidator,
+)
from django.core import exceptions, serializers
from django.db import connection
from django.test import TestCase
from django.utils import timezone
-from psycopg2.extras import NumericRange, DateTimeTZRange, DateRange
-
from .models import RangesModel
diff --git a/tests/prefetch_related/models.py b/tests/prefetch_related/models.py
index 40540e9b26..9961fd15ae 100644
--- a/tests/prefetch_related/models.py
+++ b/tests/prefetch_related/models.py
@@ -1,5 +1,5 @@
from django.contrib.contenttypes.fields import (
- GenericForeignKey, GenericRelation
+ GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
from django.db import models
diff --git a/tests/prefetch_related/tests.py b/tests/prefetch_related/tests.py
index d8d5c19f8e..f059a6f7ca 100644
--- a/tests/prefetch_related/tests.py
+++ b/tests/prefetch_related/tests.py
@@ -1,7 +1,7 @@
from __future__ import unicode_literals
-from django.core.exceptions import ObjectDoesNotExist
from django.contrib.contenttypes.models import ContentType
+from django.core.exceptions import ObjectDoesNotExist
from django.db import connection
from django.db.models import Prefetch
from django.db.models.query import get_prefetcher
@@ -9,10 +9,12 @@ from django.test import TestCase, override_settings
from django.utils import six
from django.utils.encoding import force_text
-from .models import (Author, Bio, Book, Reader, Qualification, Teacher, Department,
- TaggedItem, Bookmark, AuthorAddress, FavoriteAuthors, AuthorWithAge,
- BookWithYear, BookReview, Person, House, Room, Employee, Comment,
- LessonEntry, WordEntry, Author2)
+from .models import (
+ Author, Author2, AuthorAddress, AuthorWithAge, Bio, Book, Bookmark,
+ BookReview, BookWithYear, Comment, Department, Employee, FavoriteAuthors,
+ House, LessonEntry, Person, Qualification, Reader, Room, TaggedItem,
+ Teacher, WordEntry,
+)
class PrefetchRelatedTests(TestCase):
diff --git a/tests/proxy_model_inheritance/tests.py b/tests/proxy_model_inheritance/tests.py
index 3678466e8c..b0af0040f9 100644
--- a/tests/proxy_model_inheritance/tests.py
+++ b/tests/proxy_model_inheritance/tests.py
@@ -7,8 +7,9 @@ from django.test import TestCase, TransactionTestCase
from django.test.utils import extend_sys_path
from django.utils._os import upath
-from .models import (ConcreteModel, ConcreteModelSubclass,
- ConcreteModelSubclassProxy)
+from .models import (
+ ConcreteModel, ConcreteModelSubclass, ConcreteModelSubclassProxy,
+)
class ProxyModelInheritanceTests(TransactionTestCase):
diff --git a/tests/proxy_models/admin.py b/tests/proxy_models/admin.py
index d2b6319301..72556c34a5 100644
--- a/tests/proxy_models/admin.py
+++ b/tests/proxy_models/admin.py
@@ -1,6 +1,6 @@
from django.contrib import admin
-from .models import TrackerUser, ProxyTrackerUser
+from .models import ProxyTrackerUser, TrackerUser
admin.site.register(TrackerUser)
admin.site.register(ProxyTrackerUser)
diff --git a/tests/proxy_models/models.py b/tests/proxy_models/models.py
index 2e28c3b996..90a542ffac 100644
--- a/tests/proxy_models/models.py
+++ b/tests/proxy_models/models.py
@@ -7,6 +7,7 @@ providing a modified interface to the data from the base class.
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
+
# A couple of managers for testing managing overriding in proxy model cases.
diff --git a/tests/proxy_models/tests.py b/tests/proxy_models/tests.py
index 131bd1524f..17d139bbeb 100644
--- a/tests/proxy_models/tests.py
+++ b/tests/proxy_models/tests.py
@@ -3,18 +3,18 @@ from __future__ import unicode_literals
from django.apps import apps
from django.contrib import admin
from django.contrib.contenttypes.models import ContentType
-from django.core import management
-from django.core import checks
-from django.db import models, DEFAULT_DB_ALIAS
+from django.core import checks, management
+from django.db import DEFAULT_DB_ALIAS, models
from django.db.models import signals
from django.test import TestCase, override_settings
-
-from .models import (MyPerson, Person, StatusPerson, LowerStatusPerson,
- MyPersonProxy, Abstract, OtherPerson, User, UserProxy, UserProxyProxy,
- Country, State, StateProxy, TrackerUser, BaseUser, Bug, ProxyTrackerUser,
- Improvement, ProxyProxyBug, ProxyBug, ProxyImprovement, Issue)
from .admin import admin as force_admin_model_registration # NOQA
+from .models import (
+ Abstract, BaseUser, Bug, Country, Improvement, Issue, LowerStatusPerson,
+ MyPerson, MyPersonProxy, OtherPerson, Person, ProxyBug, ProxyImprovement,
+ ProxyProxyBug, ProxyTrackerUser, State, StateProxy, StatusPerson,
+ TrackerUser, User, UserProxy, UserProxyProxy,
+)
class ProxyModelTests(TestCase):
diff --git a/tests/proxy_models/urls.py b/tests/proxy_models/urls.py
index 6fcf1e055b..eb91d283d4 100644
--- a/tests/proxy_models/urls.py
+++ b/tests/proxy_models/urls.py
@@ -1,5 +1,4 @@
from django.conf.urls import include, url
-
from django.contrib import admin
urlpatterns = [
diff --git a/tests/queries/tests.py b/tests/queries/tests.py
index 8340369a6d..0f86a0f066 100644
--- a/tests/queries/tests.py
+++ b/tests/queries/tests.py
@@ -1,35 +1,37 @@
from __future__ import unicode_literals
-from collections import OrderedDict
import datetime
-from operator import attrgetter
import pickle
import unittest
+from collections import OrderedDict
+from operator import attrgetter
from django.core.exceptions import FieldError
-from django.db import connection, DEFAULT_DB_ALIAS
-from django.db.models import Count, F, Q
-from django.db.models.sql.where import WhereNode, NothingNode
+from django.db import DEFAULT_DB_ALIAS, connection
+from django.db.models import F, Q, Count
from django.db.models.sql.constants import LOUTER
from django.db.models.sql.datastructures import EmptyResultSet
+from django.db.models.sql.where import NothingNode, WhereNode
from django.test import TestCase, skipUnlessDBFeature
from django.test.utils import CaptureQueriesContext
from django.utils import six
from django.utils.six.moves import range
from .models import (
- Annotation, Article, Author, Celebrity, Child, Cover, Detail, DumbCategory,
- ExtraInfo, Fan, Item, LeafA, Join, LeafB, LoopX, LoopZ, ManagedModel,
- Member, NamedCategory, Note, Number, Plaything, PointerA, Ranking, Related,
- Report, ReservedName, Tag, TvChef, Valid, X, Food, Eaten, Node, ObjectA,
- ProxyObjectA, ChildObjectA, ObjectB, ProxyObjectB, ObjectC, CategoryItem,
- SimpleCategory, SpecialCategory, OneToOneCategory, NullableName, ProxyCategory,
- SingleObject, RelatedObject, ModelA, ModelB, ModelC, ModelD, Responsibility, Job,
- JobResponsibilities, BaseA, FK1, Identifier, Program, Channel, Page, Paragraph,
- Chapter, Book, MyObject, Order, OrderItem, SharedConnection, Task, Staff,
- StaffUser, CategoryRelationship, Ticket21203Parent, Ticket21203Child, Person,
- Company, Employment, CustomPk, CustomPkTag, Classroom, School, Student,
- Ticket23605A, Ticket23605B, Ticket23605C)
+ FK1, X, Annotation, Article, Author, BaseA, Book, CategoryItem,
+ CategoryRelationship, Celebrity, Channel, Chapter, Child, ChildObjectA,
+ Classroom, Company, Cover, CustomPk, CustomPkTag, Detail, DumbCategory,
+ Eaten, Employment, ExtraInfo, Fan, Food, Identifier, Item, Job,
+ JobResponsibilities, Join, LeafA, LeafB, LoopX, LoopZ, ManagedModel,
+ Member, ModelA, ModelB, ModelC, ModelD, MyObject, NamedCategory, Node,
+ Note, NullableName, Number, ObjectA, ObjectB, ObjectC, OneToOneCategory,
+ Order, OrderItem, Page, Paragraph, Person, Plaything, PointerA, Program,
+ ProxyCategory, ProxyObjectA, ProxyObjectB, Ranking, Related, RelatedObject,
+ Report, ReservedName, Responsibility, School, SharedConnection,
+ SimpleCategory, SingleObject, SpecialCategory, Staff, StaffUser, Student,
+ Tag, Task, Ticket21203Child, Ticket21203Parent, Ticket23605A, Ticket23605B,
+ Ticket23605C, TvChef, Valid,
+)
class BaseQuerysetTest(TestCase):
diff --git a/tests/queryset_pickle/models.py b/tests/queryset_pickle/models.py
index 792369c575..6503d1f33a 100644
--- a/tests/queryset_pickle/models.py
+++ b/tests/queryset_pickle/models.py
@@ -1,6 +1,6 @@
import datetime
-from django.db import models, DJANGO_VERSION_PICKLE_KEY
+from django.db import DJANGO_VERSION_PICKLE_KEY, models
from django.utils.translation import ugettext_lazy as _
from django.utils.version import get_major_version
diff --git a/tests/queryset_pickle/tests.py b/tests/queryset_pickle/tests.py
index c56b7179d2..a710a394d4 100644
--- a/tests/queryset_pickle/tests.py
+++ b/tests/queryset_pickle/tests.py
@@ -1,14 +1,14 @@
from __future__ import unicode_literals
-import pickle
import datetime
+import pickle
import warnings
from django.test import TestCase
from django.utils.encoding import force_text
from django.utils.version import get_major_version, get_version
-from .models import Group, Event, Happening, Container, M2MModel
+from .models import Container, Event, Group, Happening, M2MModel
class PickleabilityTestCase(TestCase):
diff --git a/tests/raw_query/tests.py b/tests/raw_query/tests.py
index 287b0f24dd..5d2bf4becf 100644
--- a/tests/raw_query/tests.py
+++ b/tests/raw_query/tests.py
@@ -5,7 +5,7 @@ from datetime import date
from django.db.models.query_utils import InvalidQuery
from django.test import TestCase, skipUnlessDBFeature
-from .models import Author, Book, Coffee, Reviewer, FriendlyAuthor
+from .models import Author, Book, Coffee, FriendlyAuthor, Reviewer
class RawQueryTests(TestCase):
diff --git a/tests/requests/tests.py b/tests/requests/tests.py
index e9fdefb7ea..b0598b1cc0 100644
--- a/tests/requests/tests.py
+++ b/tests/requests/tests.py
@@ -1,16 +1,18 @@
# -*- encoding: utf-8 -*-
from __future__ import unicode_literals
+import time
from datetime import datetime, timedelta
from io import BytesIO
from itertools import chain
-import time
from django.core.exceptions import SuspiciousOperation
-from django.core.handlers.wsgi import WSGIRequest, LimitedStream
-from django.http import (HttpRequest, HttpResponse, parse_cookie,
- build_request_repr, UnreadablePostError, RawPostDataException)
-from django.test import SimpleTestCase, RequestFactory, override_settings
+from django.core.handlers.wsgi import LimitedStream, WSGIRequest
+from django.http import (
+ HttpRequest, HttpResponse, RawPostDataException, UnreadablePostError,
+ build_request_repr, parse_cookie,
+)
+from django.test import RequestFactory, SimpleTestCase, override_settings
from django.test.client import FakePayload
from django.test.utils import str_prefix
from django.utils import six
diff --git a/tests/resolve_url/tests.py b/tests/resolve_url/tests.py
index 0fc3307026..b8ccd530e1 100644
--- a/tests/resolve_url/tests.py
+++ b/tests/resolve_url/tests.py
@@ -1,11 +1,11 @@
from __future__ import unicode_literals
-from django.core.urlresolvers import NoReverseMatch, reverse_lazy
from django.contrib.auth.views import logout
+from django.core.urlresolvers import NoReverseMatch, reverse_lazy
from django.shortcuts import resolve_url
from django.test import TestCase, ignore_warnings, override_settings
-from django.utils.deprecation import RemovedInDjango20Warning
from django.utils import six
+from django.utils.deprecation import RemovedInDjango20Warning
from .models import UnimportantThing
diff --git a/tests/reverse_lookup/tests.py b/tests/reverse_lookup/tests.py
index a1b33b26fa..1b9184d682 100644
--- a/tests/reverse_lookup/tests.py
+++ b/tests/reverse_lookup/tests.py
@@ -3,7 +3,7 @@ from __future__ import unicode_literals
from django.core.exceptions import FieldError
from django.test import TestCase
-from .models import User, Poll, Choice
+from .models import Choice, Poll, User
class ReverseLookupTests(TestCase):
diff --git a/tests/runtests.py b/tests/runtests.py
index cd84deb40e..0469d83600 100755
--- a/tests/runtests.py
+++ b/tests/runtests.py
@@ -1,5 +1,4 @@
#!/usr/bin/env python
-from argparse import ArgumentParser
import logging
import os
import shutil
@@ -7,18 +6,20 @@ import subprocess
import sys
import tempfile
import warnings
+from argparse import ArgumentParser
import django
from django import contrib
from django.apps import apps
from django.conf import settings
from django.db import connection
-from django.test import TransactionTestCase, TestCase
+from django.test import TestCase, TransactionTestCase
from django.test.utils import get_runner
-from django.utils.deprecation import RemovedInDjango20Warning, RemovedInDjango21Warning
-from django.utils._os import upath
from django.utils import six
-
+from django.utils._os import upath
+from django.utils.deprecation import (
+ RemovedInDjango20Warning, RemovedInDjango21Warning,
+)
warnings.simplefilter("error", RemovedInDjango20Warning)
warnings.simplefilter("error", RemovedInDjango21Warning)
diff --git a/tests/schema/fields.py b/tests/schema/fields.py
index d4302a6677..4cba35ebf8 100644
--- a/tests/schema/fields.py
+++ b/tests/schema/fields.py
@@ -1,9 +1,8 @@
from django.db.models.fields.related import (
+ RECURSIVE_RELATIONSHIP_CONSTANT, ManyToManyField, ManyToManyRel,
+ RelatedField, ReverseManyRelatedObjectsDescriptor,
create_many_to_many_intermediary_model,
- ManyToManyField, ManyToManyRel, RelatedField,
- RECURSIVE_RELATIONSHIP_CONSTANT, ReverseManyRelatedObjectsDescriptor,
)
-
from django.utils.functional import curry
diff --git a/tests/schema/tests.py b/tests/schema/tests.py
index 9cda278be1..88b1a8db5b 100644
--- a/tests/schema/tests.py
+++ b/tests/schema/tests.py
@@ -2,11 +2,17 @@ import datetime
import itertools
import unittest
-from django.db import connection, DatabaseError, IntegrityError, OperationalError
+from django.db import (
+ DatabaseError, IntegrityError, OperationalError, connection,
+)
from django.db.models import Model
-from django.db.models.fields import (BinaryField, BooleanField, CharField, DateTimeField,
- IntegerField, PositiveIntegerField, SlugField, TextField)
-from django.db.models.fields.related import ForeignKey, ManyToManyField, OneToOneField
+from django.db.models.fields import (
+ BinaryField, BooleanField, CharField, DateTimeField, IntegerField,
+ PositiveIntegerField, SlugField, TextField,
+)
+from django.db.models.fields.related import (
+ ForeignKey, ManyToManyField, OneToOneField,
+)
from django.db.transaction import atomic
from django.test import TransactionTestCase
@@ -14,7 +20,7 @@ from .fields import CustomManyToManyField, InheritedManyToManyField
from .models import (
Author, AuthorWithDefaultHeight, AuthorWithEvenLongerName, Book, BookWeak,
BookWithLongName, BookWithO2O, BookWithSlug, Note, Tag, TagIndexed,
- TagM2MTest, TagUniqueRename, Thing, UniqueTest, new_apps
+ TagM2MTest, TagUniqueRename, Thing, UniqueTest, new_apps,
)
diff --git a/tests/select_for_update/tests.py b/tests/select_for_update/tests.py
index abd7bd2ed4..af408f8ffe 100644
--- a/tests/select_for_update/tests.py
+++ b/tests/select_for_update/tests.py
@@ -3,16 +3,16 @@ from __future__ import unicode_literals
import threading
import time
+from multiple_database.routers import TestRouter
+
from django.conf import settings
-from django.db import transaction, connection, router
-from django.db.utils import ConnectionHandler, DEFAULT_DB_ALIAS, DatabaseError
+from django.db import connection, router, transaction
+from django.db.utils import DEFAULT_DB_ALIAS, ConnectionHandler, DatabaseError
from django.test import (
TransactionTestCase, override_settings, skipIfDBFeature,
skipUnlessDBFeature,
)
-from multiple_database.routers import TestRouter
-
from .models import Person
diff --git a/tests/select_related/models.py b/tests/select_related/models.py
index 96aace6a48..04aeaa1b61 100644
--- a/tests/select_related/models.py
+++ b/tests/select_related/models.py
@@ -7,11 +7,13 @@ isn't always a good idea, so the ``depth`` argument control how many "levels"
the select-related behavior will traverse.
"""
+from django.contrib.contenttypes.fields import (
+ GenericForeignKey, GenericRelation,
+)
+from django.contrib.contenttypes.models import ContentType
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
-from django.contrib.contenttypes.fields import GenericForeignKey, GenericRelation
-from django.contrib.contenttypes.models import ContentType
# Who remembers high school biology?
diff --git a/tests/select_related/tests.py b/tests/select_related/tests.py
index 378c0bf992..667ac2f00b 100644
--- a/tests/select_related/tests.py
+++ b/tests/select_related/tests.py
@@ -1,11 +1,11 @@
from __future__ import unicode_literals
-from django.test import TestCase
from django.core.exceptions import FieldError
+from django.test import TestCase
from .models import (
- Domain, Kingdom, Phylum, Klass, Order, Family, Genus, Species, HybridSpecies,
- Pizza, TaggedItem, Bookmark,
+ Bookmark, Domain, Family, Genus, HybridSpecies, Kingdom, Klass, Order,
+ Phylum, Pizza, Species, TaggedItem,
)
diff --git a/tests/select_related_onetoone/tests.py b/tests/select_related_onetoone/tests.py
index a6c0f3a42b..2cb17a5ba9 100644
--- a/tests/select_related_onetoone/tests.py
+++ b/tests/select_related_onetoone/tests.py
@@ -5,9 +5,10 @@ import unittest
from django.core.exceptions import FieldError
from django.test import TestCase
-from .models import (User, UserProfile, UserStat, UserStatResult, StatDetails,
- AdvancedUserStat, Image, Product, Parent1, Parent2, Child1, Child2, Child3,
- Child4)
+from .models import (
+ AdvancedUserStat, Child1, Child2, Child3, Child4, Image, Parent1, Parent2,
+ Product, StatDetails, User, UserProfile, UserStat, UserStatResult,
+)
class ReverseSelectRelatedTestCase(TestCase):
diff --git a/tests/select_related_regress/tests.py b/tests/select_related_regress/tests.py
index 6ee48e9aec..d014123beb 100644
--- a/tests/select_related_regress/tests.py
+++ b/tests/select_related_regress/tests.py
@@ -3,9 +3,11 @@ from __future__ import unicode_literals
from django.test import TestCase
from django.utils import six
-from .models import (Building, Child, Device, Port, Item, Country, Connection,
- ClientStatus, State, Client, SpecialClient, TUser, Person, Student,
- Organizer, Class, Enrollment, Hen, Chick, A, B, C)
+from .models import (
+ A, B, C, Building, Chick, Child, Class, Client, ClientStatus, Connection,
+ Country, Device, Enrollment, Hen, Item, Organizer, Person, Port,
+ SpecialClient, State, Student, TUser,
+)
class SelectRelatedRegressTests(TestCase):
diff --git a/tests/serializers/tests.py b/tests/serializers/tests.py
index f6b66a054a..5448b01b29 100644
--- a/tests/serializers/tests.py
+++ b/tests/serializers/tests.py
@@ -3,26 +3,30 @@ from __future__ import unicode_literals
import importlib
import json
-from datetime import datetime
import re
import unittest
+from datetime import datetime
from xml.dom import minidom
-try:
- import yaml
- HAS_YAML = True
-except ImportError:
- HAS_YAML = False
-
from django.core import management, serializers
-from django.db import transaction, connection
-from django.test import TestCase, TransactionTestCase, override_settings, skipUnlessDBFeature
+from django.db import connection, transaction
+from django.test import (
+ TestCase, TransactionTestCase, override_settings, skipUnlessDBFeature,
+)
from django.test.utils import Approximate
from django.utils import six
from django.utils.six import StringIO
-from .models import (Category, Author, Article, AuthorProfile, Actor, Movie,
- Score, Player, Team)
+from .models import (
+ Actor, Article, Author, AuthorProfile, Category, Movie, Player, Score,
+ Team,
+)
+
+try:
+ import yaml
+ HAS_YAML = True
+except ImportError:
+ HAS_YAML = False
@override_settings(
diff --git a/tests/serializers_regress/models.py b/tests/serializers_regress/models.py
index 7c7b9f12b0..35c4e10676 100644
--- a/tests/serializers_regress/models.py
+++ b/tests/serializers_regress/models.py
@@ -4,11 +4,12 @@ A test spanning all the capabilities of all the serializers.
This class sets up a model for each model field type
(except for image types, because of the Pillow dependency).
"""
-from django.db import models
from django.contrib.contenttypes.fields import (
- GenericForeignKey, GenericRelation
+ GenericForeignKey, GenericRelation,
)
from django.contrib.contenttypes.models import ContentType
+from django.db import models
+
# The following classes are for testing basic data
# marshalling, including NULL values, where allowed.
diff --git a/tests/serializers_regress/tests.py b/tests/serializers_regress/tests.py
index e91a1094ee..1bd8469641 100644
--- a/tests/serializers_regress/tests.py
+++ b/tests/serializers_regress/tests.py
@@ -12,35 +12,35 @@ import datetime
import decimal
from unittest import skipUnless
-try:
- import yaml
-except ImportError:
- yaml = None
-
from django.core import serializers
from django.core.serializers import SerializerDoesNotExist
from django.core.serializers.base import DeserializationError
from django.core.serializers.xml_serializer import DTDForbidden
from django.db import connection, models
from django.http import HttpResponse
-from django.test import skipUnlessDBFeature, TestCase
+from django.test import TestCase, skipUnlessDBFeature
from django.utils import six
from django.utils.functional import curry
-from .models import (BinaryData, BooleanData, CharData, DateData, DateTimeData, EmailData,
- FileData, FilePathData, DecimalData, FloatData, IntegerData,
- GenericIPAddressData, NullBooleanData, PositiveIntegerData,
- PositiveSmallIntegerData, SlugData, SmallData, TextData, TimeData,
- GenericData, Anchor, UniqueAnchor, FKData, M2MData, O2OData,
- FKSelfData, M2MSelfData, FKDataToField, FKDataToO2O, M2MIntermediateData,
- Intermediate, BooleanPKData, CharPKData, EmailPKData, FilePathPKData,
- DecimalPKData, FloatPKData, IntegerPKData,
- GenericIPAddressPKData, PositiveIntegerPKData,
- PositiveSmallIntegerPKData, SlugPKData, SmallPKData,
- AutoNowDateTimeData, ModifyingSaveData, InheritAbstractModel, BaseModel,
- ExplicitInheritBaseModel, InheritBaseModel, ProxyBaseModel,
- ProxyProxyBaseModel, BigIntegerData, LengthModel, Tag, ComplexModel,
- NaturalKeyAnchor, FKDataNaturalKey)
+from .models import (
+ Anchor, AutoNowDateTimeData, BaseModel, BigIntegerData, BinaryData,
+ BooleanData, BooleanPKData, CharData, CharPKData, ComplexModel, DateData,
+ DateTimeData, DecimalData, DecimalPKData, EmailData, EmailPKData,
+ ExplicitInheritBaseModel, FileData, FilePathData, FilePathPKData, FKData,
+ FKDataNaturalKey, FKDataToField, FKDataToO2O, FKSelfData, FloatData,
+ FloatPKData, GenericData, GenericIPAddressData, GenericIPAddressPKData,
+ InheritAbstractModel, InheritBaseModel, IntegerData, IntegerPKData,
+ Intermediate, LengthModel, M2MData, M2MIntermediateData, M2MSelfData,
+ ModifyingSaveData, NaturalKeyAnchor, NullBooleanData, O2OData,
+ PositiveIntegerData, PositiveIntegerPKData, PositiveSmallIntegerData,
+ PositiveSmallIntegerPKData, ProxyBaseModel, ProxyProxyBaseModel, SlugData,
+ SlugPKData, SmallData, SmallPKData, Tag, TextData, TimeData, UniqueAnchor,
+)
+
+try:
+ import yaml
+except ImportError:
+ yaml = None
# A set of functions that can be used to recreate
# test data objects of various kinds.
diff --git a/tests/servers/tests.py b/tests/servers/tests.py
index 50b2cafe1a..e84b8788c0 100644
--- a/tests/servers/tests.py
+++ b/tests/servers/tests.py
@@ -8,16 +8,14 @@ import os
import socket
from django.core.exceptions import ImproperlyConfigured
-from django.test import LiveServerTestCase
-from django.test import override_settings
+from django.test import LiveServerTestCase, override_settings
+from django.utils._os import upath
from django.utils.http import urlencode
from django.utils.six.moves.urllib.error import HTTPError
from django.utils.six.moves.urllib.request import urlopen
-from django.utils._os import upath
from .models import Person
-
TEST_ROOT = os.path.dirname(upath(__file__))
TEST_SETTINGS = {
'MEDIA_URL': '/media/',
diff --git a/tests/servers/urls.py b/tests/servers/urls.py
index 002e604105..868ecc34f9 100644
--- a/tests/servers/urls.py
+++ b/tests/servers/urls.py
@@ -2,7 +2,6 @@ from django.conf.urls import url
from . import views
-
urlpatterns = [
url(r'^example_view/$', views.example_view),
url(r'^model_view/$', views.model_view),
diff --git a/tests/servers/views.py b/tests/servers/views.py
index eb7c6c650d..f1fb8714c5 100644
--- a/tests/servers/views.py
+++ b/tests/servers/views.py
@@ -1,4 +1,5 @@
from django.http import HttpResponse
+
from .models import Person
diff --git a/tests/settings_tests/tests.py b/tests/settings_tests/tests.py
index 8d39d6c1b1..6a444d56a9 100644
--- a/tests/settings_tests/tests.py
+++ b/tests/settings_tests/tests.py
@@ -1,14 +1,16 @@
import os
import sys
-from types import ModuleType
import unittest
import warnings
+from types import ModuleType
from django.conf import LazySettings, Settings, settings
from django.core.exceptions import ImproperlyConfigured
from django.http import HttpRequest
-from django.test import (SimpleTestCase, TransactionTestCase, TestCase,
- modify_settings, override_settings, signals)
+from django.test import (
+ SimpleTestCase, TestCase, TransactionTestCase, modify_settings,
+ override_settings, signals,
+)
from django.utils import six
from django.utils.encoding import force_text
diff --git a/tests/shortcuts/tests.py b/tests/shortcuts/tests.py
index 98251244c5..08bcc55343 100644
--- a/tests/shortcuts/tests.py
+++ b/tests/shortcuts/tests.py
@@ -1,6 +1,6 @@
-from django.utils.deprecation import RemovedInDjango20Warning
from django.test import TestCase, ignore_warnings, override_settings
from django.test.utils import require_jinja2
+from django.utils.deprecation import RemovedInDjango20Warning
@override_settings(
diff --git a/tests/shortcuts/views.py b/tests/shortcuts/views.py
index 85d1922d58..f988edf8d9 100644
--- a/tests/shortcuts/views.py
+++ b/tests/shortcuts/views.py
@@ -1,10 +1,9 @@
import os.path
-from django.shortcuts import render_to_response, render
+from django.shortcuts import render, render_to_response
from django.template import Context, RequestContext
from django.utils._os import upath
-
dirs = (os.path.join(os.path.dirname(upath(__file__)), 'other_templates'),)
diff --git a/tests/signing/tests.py b/tests/signing/tests.py
index 32b8bb3b5e..006151baf6 100644
--- a/tests/signing/tests.py
+++ b/tests/signing/tests.py
@@ -5,8 +5,8 @@ import datetime
from django.core import signing
from django.test import TestCase
from django.test.utils import freeze_time
-from django.utils.encoding import force_str
from django.utils import six
+from django.utils.encoding import force_str
class TestSigner(TestCase):
diff --git a/tests/sites_framework/migrations/0001_initial.py b/tests/sites_framework/migrations/0001_initial.py
index 2ce80fd87d..5a4ac27961 100644
--- a/tests/sites_framework/migrations/0001_initial.py
+++ b/tests/sites_framework/migrations/0001_initial.py
@@ -1,7 +1,7 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from django.db import models, migrations
+from django.db import migrations, models
class Migration(migrations.Migration):
diff --git a/tests/sites_framework/tests.py b/tests/sites_framework/tests.py
index 97d01e1d57..911286adc1 100644
--- a/tests/sites_framework/tests.py
+++ b/tests/sites_framework/tests.py
@@ -6,8 +6,9 @@ from django.core import checks
from django.db import models
from django.test import TestCase
-from .models import (SyndicatedArticle, ExclusiveArticle, CustomArticle,
- AbstractArticle)
+from .models import (
+ AbstractArticle, CustomArticle, ExclusiveArticle, SyndicatedArticle,
+)
class SitesFrameworkTestCase(TestCase):
diff --git a/tests/staticfiles_tests/storage.py b/tests/staticfiles_tests/storage.py
index e47af18b22..fe4811a495 100644
--- a/tests/staticfiles_tests/storage.py
+++ b/tests/staticfiles_tests/storage.py
@@ -1,6 +1,7 @@
from datetime import datetime
-from django.core.files import storage
+
from django.contrib.staticfiles.storage import CachedStaticFilesStorage
+from django.core.files import storage
class DummyStorage(storage.Storage):
diff --git a/tests/staticfiles_tests/test_liveserver.py b/tests/staticfiles_tests/test_liveserver.py
index 4038797264..58b96b69ec 100644
--- a/tests/staticfiles_tests/test_liveserver.py
+++ b/tests/staticfiles_tests/test_liveserver.py
@@ -6,13 +6,11 @@ django.test.LiveServerTestCase.
import os
+from django.contrib.staticfiles.testing import StaticLiveServerTestCase
from django.core.exceptions import ImproperlyConfigured
from django.test import modify_settings, override_settings
-from django.utils.six.moves.urllib.request import urlopen
from django.utils._os import upath
-
-from django.contrib.staticfiles.testing import StaticLiveServerTestCase
-
+from django.utils.six.moves.urllib.request import urlopen
TEST_ROOT = os.path.dirname(upath(__file__))
TEST_SETTINGS = {
diff --git a/tests/staticfiles_tests/tests.py b/tests/staticfiles_tests/tests.py
index 7715b23f7b..e79d32dbf7 100644
--- a/tests/staticfiles_tests/tests.py
+++ b/tests/staticfiles_tests/tests.py
@@ -9,23 +9,23 @@ import sys
import tempfile
import unittest
-from django.template import Context, Template
from django.conf import settings
+from django.contrib.staticfiles import finders, storage
+from django.contrib.staticfiles.management.commands import collectstatic
+from django.contrib.staticfiles.management.commands.collectstatic import \
+ Command as CollectstaticCommand
from django.core.cache.backends.base import BaseCache
from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command
+from django.template import Context, Template
from django.test import TestCase, override_settings
+from django.utils import six
+from django.utils._os import rmtree_errorhandler, symlinks_supported, upath
from django.utils.encoding import force_text
from django.utils.functional import empty
-from django.utils._os import rmtree_errorhandler, upath, symlinks_supported
-from django.utils import six
-
-from django.contrib.staticfiles import finders, storage
-from django.contrib.staticfiles.management.commands import collectstatic
from .storage import DummyStorage
-
TEST_ROOT = os.path.dirname(upath(__file__))
TEST_SETTINGS = {
'DEBUG': True,
@@ -52,7 +52,6 @@ TEST_SETTINGS = {
'staticfiles_tests.apps.no_label',
],
}
-from django.contrib.staticfiles.management.commands.collectstatic import Command as CollectstaticCommand
class BaseStaticFilesTestCase(object):
diff --git a/tests/string_lookup/tests.py b/tests/string_lookup/tests.py
index 5a17e55560..13a4544604 100644
--- a/tests/string_lookup/tests.py
+++ b/tests/string_lookup/tests.py
@@ -2,7 +2,8 @@
from __future__ import unicode_literals
from django.test import TestCase
-from .models import Foo, Whiz, Bar, Article, Base, Child
+
+from .models import Article, Bar, Base, Child, Foo, Whiz
class StringLookupTests(TestCase):
diff --git a/tests/swappable_models/tests.py b/tests/swappable_models/tests.py
index 246d456f20..9ba684170c 100644
--- a/tests/swappable_models/tests.py
+++ b/tests/swappable_models/tests.py
@@ -1,13 +1,12 @@
from __future__ import unicode_literals
-from django.utils.six import StringIO
+from swappable_models.models import Article
from django.contrib.auth.models import Permission
from django.contrib.contenttypes.models import ContentType
from django.core import management
from django.test import TestCase, override_settings
-
-from swappable_models.models import Article
+from django.utils.six import StringIO
class SwappableModelTests(TestCase):
diff --git a/tests/syndication_tests/tests.py b/tests/syndication_tests/tests.py
index 63638fa589..6e08d719d4 100644
--- a/tests/syndication_tests/tests.py
+++ b/tests/syndication_tests/tests.py
@@ -3,21 +3,20 @@ from __future__ import unicode_literals
import datetime
from xml.dom import minidom
-try:
- import pytz
-except ImportError:
- pytz = None
-
from django.contrib.sites.models import Site
from django.contrib.syndication import views
from django.core.exceptions import ImproperlyConfigured
from django.test import TestCase, override_settings
from django.test.utils import requires_tz_support
-from django.utils.feedgenerator import rfc2822_date, rfc3339_date
from django.utils import timezone
+from django.utils.feedgenerator import rfc2822_date, rfc3339_date
from .models import Entry
+try:
+ import pytz
+except ImportError:
+ pytz = None
TZ = timezone.get_default_timezone()
diff --git a/tests/syndication_tests/urls.py b/tests/syndication_tests/urls.py
index f92896f308..d3caeae888 100644
--- a/tests/syndication_tests/urls.py
+++ b/tests/syndication_tests/urls.py
@@ -2,7 +2,6 @@ from django.conf.urls import url
from . import feeds
-
urlpatterns = [
url(r'^syndication/rss2/$', feeds.TestRss2Feed()),
url(r'^syndication/rss2/guid_ispermalink_true/$',
diff --git a/tests/template_backends/test_django.py b/tests/template_backends/test_django.py
index 2aaf6b57d8..a8cc0d58b8 100644
--- a/tests/template_backends/test_django.py
+++ b/tests/template_backends/test_django.py
@@ -1,10 +1,10 @@
+from template_tests.test_response import test_processor_name
+
from django.template import RequestContext
from django.template.backends.django import DjangoTemplates
-from django.test import ignore_warnings, RequestFactory
+from django.test import RequestFactory, ignore_warnings
from django.utils.deprecation import RemovedInDjango20Warning
-from template_tests.test_response import test_processor_name
-
from .test_dummy import TemplateStringsTests
diff --git a/tests/template_backends/test_jinja2.py b/tests/template_backends/test_jinja2.py
index 1442f25e02..5f69669446 100644
--- a/tests/template_backends/test_jinja2.py
+++ b/tests/template_backends/test_jinja2.py
@@ -4,6 +4,8 @@ from __future__ import absolute_import
from unittest import skipIf
+from .test_dummy import TemplateStringsTests
+
try:
import jinja2
except ImportError:
@@ -12,8 +14,6 @@ except ImportError:
else:
from django.template.backends.jinja2 import Jinja2
-from .test_dummy import TemplateStringsTests
-
@skipIf(jinja2 is None, "this test requires jinja2")
class Jinja2Tests(TemplateStringsTests):
diff --git a/tests/template_loader/tests.py b/tests/template_loader/tests.py
index 12bfa1b543..a4a4542f32 100644
--- a/tests/template_loader/tests.py
+++ b/tests/template_loader/tests.py
@@ -1,8 +1,9 @@
-from django.test import override_settings, SimpleTestCase
-from django.test.client import RequestFactory
from django.template import TemplateDoesNotExist
from django.template.loader import (
- get_template, select_template, render_to_string)
+ get_template, render_to_string, select_template,
+)
+from django.test import SimpleTestCase, override_settings
+from django.test.client import RequestFactory
@override_settings(TEMPLATES=[{
diff --git a/tests/template_tests/alternate_urls.py b/tests/template_tests/alternate_urls.py
index 9b05aa619b..cb73513879 100644
--- a/tests/template_tests/alternate_urls.py
+++ b/tests/template_tests/alternate_urls.py
@@ -2,7 +2,6 @@ from django.conf.urls import url
from . import views
-
urlpatterns = [
# View returning a template response
url(r'^template_response_view/$', views.template_response_view),
diff --git a/tests/template_tests/filter_tests/test_autoescape.py b/tests/template_tests/filter_tests/test_autoescape.py
index 793fbf80d6..35faada9c6 100644
--- a/tests/template_tests/filter_tests/test_autoescape.py
+++ b/tests/template_tests/filter_tests/test_autoescape.py
@@ -1,6 +1,6 @@
from django.test import SimpleTestCase
-from ..utils import setup, SafeClass, UnsafeClass
+from ..utils import SafeClass, UnsafeClass, setup
class AutoescapeStringfilterTests(SimpleTestCase):
diff --git a/tests/template_tests/filter_tests/test_date.py b/tests/template_tests/filter_tests/test_date.py
index 8485e10a19..612742a501 100644
--- a/tests/template_tests/filter_tests/test_date.py
+++ b/tests/template_tests/filter_tests/test_date.py
@@ -4,8 +4,8 @@ from django.template.defaultfilters import date
from django.test import SimpleTestCase
from django.utils import timezone
-from .timezone_utils import TimezoneTestCase
from ..utils import setup
+from .timezone_utils import TimezoneTestCase
class DateTests(TimezoneTestCase):
diff --git a/tests/template_tests/filter_tests/test_time.py b/tests/template_tests/filter_tests/test_time.py
index e2b47b45b4..f5dc47813e 100644
--- a/tests/template_tests/filter_tests/test_time.py
+++ b/tests/template_tests/filter_tests/test_time.py
@@ -4,8 +4,8 @@ from django.template.defaultfilters import time as time_filter
from django.test import SimpleTestCase
from django.utils import timezone
-from .timezone_utils import TimezoneTestCase
from ..utils import setup
+from .timezone_utils import TimezoneTestCase
class TimeTests(TimezoneTestCase):
diff --git a/tests/template_tests/filter_tests/test_timesince.py b/tests/template_tests/filter_tests/test_timesince.py
index e10e86e921..52901cea36 100644
--- a/tests/template_tests/filter_tests/test_timesince.py
+++ b/tests/template_tests/filter_tests/test_timesince.py
@@ -6,8 +6,8 @@ from django.template.defaultfilters import timesince_filter
from django.test import SimpleTestCase
from django.test.utils import requires_tz_support
-from .timezone_utils import TimezoneTestCase
from ..utils import setup
+from .timezone_utils import TimezoneTestCase
class TimesinceTests(TimezoneTestCase):
diff --git a/tests/template_tests/filter_tests/test_timeuntil.py b/tests/template_tests/filter_tests/test_timeuntil.py
index 822a7ea9eb..5befabb379 100644
--- a/tests/template_tests/filter_tests/test_timeuntil.py
+++ b/tests/template_tests/filter_tests/test_timeuntil.py
@@ -6,8 +6,8 @@ from django.template.defaultfilters import timeuntil_filter
from django.test import SimpleTestCase
from django.test.utils import requires_tz_support
-from .timezone_utils import TimezoneTestCase
from ..utils import setup
+from .timezone_utils import TimezoneTestCase
class TimeuntilTests(TimezoneTestCase):
diff --git a/tests/template_tests/syntax_tests/test_autoescape.py b/tests/template_tests/syntax_tests/test_autoescape.py
index 7b5c12c59c..d58dfc9176 100644
--- a/tests/template_tests/syntax_tests/test_autoescape.py
+++ b/tests/template_tests/syntax_tests/test_autoescape.py
@@ -2,7 +2,7 @@ from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
from django.utils.safestring import mark_safe
-from ..utils import setup, SafeClass, UnsafeClass
+from ..utils import SafeClass, UnsafeClass, setup
class AutoescapeTagTests(SimpleTestCase):
diff --git a/tests/template_tests/syntax_tests/test_basic.py b/tests/template_tests/syntax_tests/test_basic.py
index 073d26e10b..741b3ace8f 100644
--- a/tests/template_tests/syntax_tests/test_basic.py
+++ b/tests/template_tests/syntax_tests/test_basic.py
@@ -1,8 +1,7 @@
from django.template.base import Context, TemplateSyntaxError
from django.test import SimpleTestCase
-from ..utils import setup, SilentGetItemClass, SilentAttrClass, SomeClass
-
+from ..utils import SilentAttrClass, SilentGetItemClass, SomeClass, setup
basic_templates = {
'basic-syntax01': 'something cool',
diff --git a/tests/template_tests/syntax_tests/test_exceptions.py b/tests/template_tests/syntax_tests/test_exceptions.py
index e3645cb13f..db1e0f9f5f 100644
--- a/tests/template_tests/syntax_tests/test_exceptions.py
+++ b/tests/template_tests/syntax_tests/test_exceptions.py
@@ -1,8 +1,8 @@
from django.template import TemplateDoesNotExist, TemplateSyntaxError
from django.test import SimpleTestCase
-from .test_extends import inheritance_templates
from ..utils import setup
+from .test_extends import inheritance_templates
class ExceptionsTests(SimpleTestCase):
diff --git a/tests/template_tests/syntax_tests/test_extends.py b/tests/template_tests/syntax_tests/test_extends.py
index 3ad19616af..1b0ff36a3c 100644
--- a/tests/template_tests/syntax_tests/test_extends.py
+++ b/tests/template_tests/syntax_tests/test_extends.py
@@ -2,7 +2,6 @@ from django.test import SimpleTestCase
from ..utils import setup
-
inheritance_templates = {
'inheritance01': "1{% block first %}&{% endblock %}3{% block second %}_{% endblock %}",
'inheritance02': "{% extends 'inheritance01' %}"
diff --git a/tests/template_tests/syntax_tests/test_filter_syntax.py b/tests/template_tests/syntax_tests/test_filter_syntax.py
index 94e7fe2871..1793fc67de 100644
--- a/tests/template_tests/syntax_tests/test_filter_syntax.py
+++ b/tests/template_tests/syntax_tests/test_filter_syntax.py
@@ -4,7 +4,7 @@ from __future__ import unicode_literals
from django.template import TemplateSyntaxError
from django.test import SimpleTestCase
-from ..utils import setup, SomeClass, SomeOtherException, UTF8Class
+from ..utils import SomeClass, SomeOtherException, UTF8Class, setup
class FilterSyntaxTests(SimpleTestCase):
diff --git a/tests/template_tests/syntax_tests/test_if.py b/tests/template_tests/syntax_tests/test_if.py
index 9f207c4114..290a092a04 100644
--- a/tests/template_tests/syntax_tests/test_if.py
+++ b/tests/template_tests/syntax_tests/test_if.py
@@ -1,11 +1,11 @@
import warnings
from django.template import TemplateSyntaxError
-from django.test import ignore_warnings, SimpleTestCase
+from django.test import SimpleTestCase, ignore_warnings
from django.test.utils import reset_warning_registry
from django.utils.deprecation import RemovedInDjango20Warning
-from ..utils import setup, TestObj
+from ..utils import TestObj, setup
class IfTagTests(SimpleTestCase):
diff --git a/tests/template_tests/syntax_tests/test_include.py b/tests/template_tests/syntax_tests/test_include.py
index 7f3adfd8fe..17ad9c1e4c 100644
--- a/tests/template_tests/syntax_tests/test_include.py
+++ b/tests/template_tests/syntax_tests/test_include.py
@@ -1,9 +1,8 @@
from django.template import Context, TemplateDoesNotExist, TemplateSyntaxError
from django.test import SimpleTestCase
-from .test_basic import basic_templates
from ..utils import setup
-
+from .test_basic import basic_templates
include_fail_templates = {
'include-fail1': '{% load bad_tag %}{% badtag %}',
diff --git a/tests/template_tests/syntax_tests/test_numpy.py b/tests/template_tests/syntax_tests/test_numpy.py
index dd6c01f976..822b10fd7a 100644
--- a/tests/template_tests/syntax_tests/test_numpy.py
+++ b/tests/template_tests/syntax_tests/test_numpy.py
@@ -1,5 +1,5 @@
-from unittest import skipIf
import warnings
+from unittest import skipIf
from django.test import SimpleTestCase
diff --git a/tests/template_tests/syntax_tests/test_ssi.py b/tests/template_tests/syntax_tests/test_ssi.py
index c971f5c32c..591e540edb 100644
--- a/tests/template_tests/syntax_tests/test_ssi.py
+++ b/tests/template_tests/syntax_tests/test_ssi.py
@@ -1,6 +1,6 @@
import os
-from django.test import ignore_warnings, SimpleTestCase
+from django.test import SimpleTestCase, ignore_warnings
from django.utils.deprecation import RemovedInDjango20Warning
from ..utils import ROOT, setup
diff --git a/tests/template_tests/syntax_tests/test_static.py b/tests/template_tests/syntax_tests/test_static.py
index 19b4e53cde..b646ac2bb8 100644
--- a/tests/template_tests/syntax_tests/test_static.py
+++ b/tests/template_tests/syntax_tests/test_static.py
@@ -1,5 +1,5 @@
from django.conf import settings
-from django.test import override_settings, SimpleTestCase
+from django.test import SimpleTestCase, override_settings
from django.utils.six.moves.urllib.parse import urljoin
from ..utils import setup
diff --git a/tests/template_tests/syntax_tests/test_url.py b/tests/template_tests/syntax_tests/test_url.py
index 60f777f6d0..8da4dba67b 100644
--- a/tests/template_tests/syntax_tests/test_url.py
+++ b/tests/template_tests/syntax_tests/test_url.py
@@ -1,7 +1,7 @@
# coding: utf-8
from django.core.urlresolvers import NoReverseMatch
from django.template import TemplateSyntaxError
-from django.test import ignore_warnings, override_settings, SimpleTestCase
+from django.test import SimpleTestCase, ignore_warnings, override_settings
from django.utils.deprecation import RemovedInDjango20Warning
from ..utils import setup
diff --git a/tests/template_tests/templatetags/bad_tag.py b/tests/template_tests/templatetags/bad_tag.py
index b806423df3..a5be15633b 100644
--- a/tests/template_tests/templatetags/bad_tag.py
+++ b/tests/template_tests/templatetags/bad_tag.py
@@ -1,6 +1,5 @@
from django import template
-
register = template.Library()
diff --git a/tests/template_tests/templatetags/inclusion.py b/tests/template_tests/templatetags/inclusion.py
index e4edb264aa..77c9abeb5c 100644
--- a/tests/template_tests/templatetags/inclusion.py
+++ b/tests/template_tests/templatetags/inclusion.py
@@ -4,7 +4,6 @@ from django.template import Library
from django.template.loader import get_template
from django.utils import six
-
register = Library()
diff --git a/tests/template_tests/test_context.py b/tests/template_tests/test_context.py
index 24d589fb25..c7cd70ef6f 100644
--- a/tests/template_tests/test_context.py
+++ b/tests/template_tests/test_context.py
@@ -3,7 +3,9 @@
from unittest import TestCase
from django.http import HttpRequest
-from django.template import Context, RequestContext, Variable, VariableDoesNotExist
+from django.template import (
+ Context, RequestContext, Variable, VariableDoesNotExist,
+)
from django.template.context import RenderContext
diff --git a/tests/template_tests/test_loaders.py b/tests/template_tests/test_loaders.py
index 735dbac87a..bab4a469d9 100644
--- a/tests/template_tests/test_loaders.py
+++ b/tests/template_tests/test_loaders.py
@@ -9,22 +9,19 @@ import sys
import types
import unittest
-try:
- import pkg_resources
-except ImportError:
- pkg_resources = None
-
-
-from django.template import TemplateDoesNotExist, Context
-from django.template.loaders import cached, eggs
+from django.template import Context, TemplateDoesNotExist, loader
from django.template.engine import Engine
-from django.template import loader
+from django.template.loaders import cached, eggs
from django.test import SimpleTestCase, ignore_warnings, override_settings
from django.utils import six
-from django.utils.deprecation import RemovedInDjango20Warning
from django.utils._os import upath
+from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.six import StringIO
+try:
+ import pkg_resources
+except ImportError:
+ pkg_resources = None
TEMPLATES_DIR = os.path.join(os.path.dirname(upath(__file__)), 'templates')
diff --git a/tests/template_tests/test_parser.py b/tests/template_tests/test_parser.py
index 348428513b..1e1d76b1bd 100644
--- a/tests/template_tests/test_parser.py
+++ b/tests/template_tests/test_parser.py
@@ -6,7 +6,9 @@ from __future__ import unicode_literals
from unittest import TestCase
from django.template import Library, Template, TemplateSyntaxError
-from django.template.base import FilterExpression, Parser, TokenParser, Variable
+from django.template.base import (
+ FilterExpression, Parser, TokenParser, Variable,
+)
from django.test import override_settings
from django.utils import six
diff --git a/tests/template_tests/test_response.py b/tests/template_tests/test_response.py
index 5c73265ded..eabaac6ce6 100644
--- a/tests/template_tests/test_response.py
+++ b/tests/template_tests/test_response.py
@@ -1,16 +1,18 @@
from __future__ import unicode_literals
-from datetime import datetime
import os
import pickle
import time
+from datetime import datetime
-from django.test import RequestFactory, SimpleTestCase
from django.conf import settings
from django.template import Context, engines
-from django.template.response import (TemplateResponse, SimpleTemplateResponse,
- ContentNotRenderedError)
-from django.test import ignore_warnings, override_settings
+from django.template.response import (
+ ContentNotRenderedError, SimpleTemplateResponse, TemplateResponse,
+)
+from django.test import (
+ RequestFactory, SimpleTestCase, ignore_warnings, override_settings,
+)
from django.test.utils import require_jinja2
from django.utils._os import upath
from django.utils.deprecation import RemovedInDjango20Warning
diff --git a/tests/template_tests/test_unicode.py b/tests/template_tests/test_unicode.py
index 02d3d0a51d..b692bfe31c 100644
--- a/tests/template_tests/test_unicode.py
+++ b/tests/template_tests/test_unicode.py
@@ -3,10 +3,10 @@ from __future__ import unicode_literals
from unittest import TestCase
-from django.template import Template, Context
+from django.template import Context, Template
from django.template.base import TemplateEncodingError
-from django.utils.safestring import SafeData
from django.utils import six
+from django.utils.safestring import SafeData
class UnicodeTests(TestCase):
diff --git a/tests/template_tests/tests.py b/tests/template_tests/tests.py
index 8b93039dca..c57c3d1479 100644
--- a/tests/template_tests/tests.py
+++ b/tests/template_tests/tests.py
@@ -8,15 +8,18 @@ import unittest
from django import template
from django.contrib.auth.models import Group
from django.core import urlresolvers
-from django.template import (base as template_base, loader,
- Context, RequestContext, Template, TemplateSyntaxError)
+from django.template import (
+ Context, RequestContext, Template, TemplateSyntaxError,
+ base as template_base, loader,
+)
from django.template.engine import Engine
from django.template.loaders import app_directories, filesystem
from django.test import RequestFactory, SimpleTestCase
-from django.test.utils import extend_sys_path, ignore_warnings, override_settings
-from django.utils.deprecation import RemovedInDjango20Warning
+from django.test.utils import (
+ extend_sys_path, ignore_warnings, override_settings,
+)
from django.utils._os import upath
-
+from django.utils.deprecation import RemovedInDjango20Warning
TESTS_DIR = os.path.dirname(os.path.dirname(os.path.abspath(upath(__file__))))
diff --git a/tests/template_tests/urls.py b/tests/template_tests/urls.py
index 2ddb6e232c..858f6d19f6 100644
--- a/tests/template_tests/urls.py
+++ b/tests/template_tests/urls.py
@@ -2,8 +2,8 @@
from __future__ import unicode_literals
from django.conf.urls import url
-from . import views
+from . import views
urlpatterns = [
# Test urls for testing reverse lookups
diff --git a/tests/template_tests/utils.py b/tests/template_tests/utils.py
index 588c1a4096..d5af69bdd6 100644
--- a/tests/template_tests/utils.py
+++ b/tests/template_tests/utils.py
@@ -2,8 +2,8 @@
from __future__ import unicode_literals
-import os
import functools
+import os
from django import template
from django.template import Library
@@ -14,7 +14,6 @@ from django.utils._os import upath
from django.utils.encoding import python_2_unicode_compatible
from django.utils.safestring import mark_safe
-
ROOT = os.path.dirname(os.path.abspath(upath(__file__)))
diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py
index 7059c23a81..05de326bef 100644
--- a/tests/test_client/tests.py
+++ b/tests/test_client/tests.py
@@ -24,8 +24,7 @@ from __future__ import unicode_literals
from django.core import mail
from django.http import HttpResponse
-from django.test import Client, TestCase, RequestFactory
-from django.test import override_settings
+from django.test import Client, RequestFactory, TestCase, override_settings
from .views import get_view, post_view, trace_view
diff --git a/tests/test_client/urls.py b/tests/test_client/urls.py
index 72fe9676ee..1b7530db1c 100644
--- a/tests/test_client/urls.py
+++ b/tests/test_client/urls.py
@@ -4,7 +4,6 @@ from django.views.generic import RedirectView
from . import views
-
urlpatterns = [
url(r'^get_view/$', views.get_view, name='get_view'),
url(r'^post_view/$', views.post_view),
diff --git a/tests/test_client/views.py b/tests/test_client/views.py
index 2b7a4de63c..f26d474612 100644
--- a/tests/test_client/views.py
+++ b/tests/test_client/views.py
@@ -4,10 +4,10 @@ from django.contrib.auth.decorators import login_required, permission_required
from django.core import mail
from django.forms import fields
from django.forms.forms import Form, ValidationError
-from django.forms.formsets import formset_factory, BaseFormSet
+from django.forms.formsets import BaseFormSet, formset_factory
from django.http import (
- HttpResponse, HttpResponseRedirect, HttpResponseNotFound,
- HttpResponseNotAllowed, HttpResponseBadRequest,
+ HttpResponse, HttpResponseBadRequest, HttpResponseNotAllowed,
+ HttpResponseNotFound, HttpResponseRedirect,
)
from django.shortcuts import render_to_response
from django.template import Context, Template
diff --git a/tests/test_client_regress/models.py b/tests/test_client_regress/models.py
index b72d4480bf..aebc93c91b 100644
--- a/tests/test_client_regress/models.py
+++ b/tests/test_client_regress/models.py
@@ -1,5 +1,5 @@
-from django.db import models
from django.contrib.auth.models import AbstractBaseUser, BaseUserManager
+from django.db import models
class CustomUser(AbstractBaseUser):
diff --git a/tests/test_client_regress/tests.py b/tests/test_client_regress/tests.py
index c97ad550d1..fcceaf7346 100644
--- a/tests/test_client_regress/tests.py
+++ b/tests/test_client_regress/tests.py
@@ -4,21 +4,21 @@ Regression tests for the Test Client, especially the customized assertions.
"""
from __future__ import unicode_literals
-import os
import itertools
+import os
-from django.core.urlresolvers import reverse, NoReverseMatch
-from django.template import TemplateSyntaxError, Context, engines
+from django.contrib.auth.models import User
+from django.contrib.auth.signals import user_logged_in, user_logged_out
+from django.core.urlresolvers import NoReverseMatch, reverse
+from django.http import HttpResponse
+from django.template import Context, TemplateSyntaxError, engines
+from django.template.response import SimpleTemplateResponse
from django.test import Client, TestCase, ignore_warnings, override_settings
from django.test.client import RedirectCycleError, RequestFactory, encode_file
from django.test.utils import ContextList, str_prefix
-from django.template.response import SimpleTemplateResponse
-from django.utils.deprecation import RemovedInDjango20Warning
from django.utils._os import upath
+from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.translation import ugettext_lazy
-from django.http import HttpResponse
-from django.contrib.auth.signals import user_logged_out, user_logged_in
-from django.contrib.auth.models import User
from .models import CustomUser
from .views import CustomTestException
diff --git a/tests/test_client_regress/urls.py b/tests/test_client_regress/urls.py
index a69a774555..fd7c131797 100644
--- a/tests/test_client_regress/urls.py
+++ b/tests/test_client_regress/urls.py
@@ -1,9 +1,8 @@
-from django.conf.urls import url, include
+from django.conf.urls import include, url
from django.views.generic import RedirectView
from . import views
-
urlpatterns = [
url(r'', include('test_client.urls')),
diff --git a/tests/test_client_regress/views.py b/tests/test_client_regress/views.py
index 1c5e221a2a..6046564ee4 100644
--- a/tests/test_client_regress/views.py
+++ b/tests/test_client_regress/views.py
@@ -2,9 +2,9 @@ import json
from django.conf import settings
from django.contrib.auth.decorators import login_required
+from django.core.serializers.json import DjangoJSONEncoder
from django.http import HttpResponse, HttpResponseRedirect
from django.shortcuts import render_to_response
-from django.core.serializers.json import DjangoJSONEncoder
from django.template import RequestContext
from django.template.loader import render_to_string
from django.test import Client
diff --git a/tests/test_runner/test_discover_runner.py b/tests/test_runner/test_discover_runner.py
index ecf83f9f70..758f2d1198 100644
--- a/tests/test_runner/test_discover_runner.py
+++ b/tests/test_runner/test_discover_runner.py
@@ -1,5 +1,5 @@
-from contextlib import contextmanager
import os
+from contextlib import contextmanager
from unittest import TestSuite, TextTestRunner, defaultTestLoader
from django.test import TestCase
diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py
index a8ce8d947c..d94d264321 100644
--- a/tests/test_runner/tests.py
+++ b/tests/test_runner/tests.py
@@ -5,17 +5,20 @@ from __future__ import unicode_literals
import unittest
+from admin_scripts.tests import AdminScriptTestCase
+
from django import db
from django.conf import settings
from django.core.exceptions import ImproperlyConfigured
from django.core.management import call_command
from django.db.backends.dummy.base import DatabaseCreation
-from django.test import TestCase, TransactionTestCase, mock, skipUnlessDBFeature
+from django.test import (
+ TestCase, TransactionTestCase, mock, skipUnlessDBFeature,
+)
from django.test.runner import DiscoverRunner, dependency_ordered
from django.test.testcases import connections_support_transactions
from django.utils import six
-from admin_scripts.tests import AdminScriptTestCase
from .models import Person
diff --git a/tests/test_utils/tests.py b/tests/test_utils/tests.py
index 1deda66b2e..9c6861393a 100644
--- a/tests/test_utils/tests.py
+++ b/tests/test_utils/tests.py
@@ -4,7 +4,7 @@ from __future__ import unicode_literals
import unittest
from django.conf.urls import url
-from django.contrib.staticfiles.finders import get_finders, get_finder
+from django.contrib.staticfiles.finders import get_finder, get_finders
from django.contrib.staticfiles.storage import staticfiles_storage
from django.core.files.storage import default_storage
from django.core.urlresolvers import NoReverseMatch, reverse
@@ -12,7 +12,9 @@ from django.db import connection, router
from django.forms import EmailField, IntegerField
from django.http import HttpResponse
from django.template.loader import render_to_string
-from django.test import SimpleTestCase, TestCase, skipIfDBFeature, skipUnlessDBFeature
+from django.test import (
+ SimpleTestCase, TestCase, skipIfDBFeature, skipUnlessDBFeature,
+)
from django.test.html import HTMLParseError, parse_html
from django.test.utils import CaptureQueriesContext, override_settings
from django.utils import six
diff --git a/tests/test_utils/urls.py b/tests/test_utils/urls.py
index 4193cabf91..a886451721 100644
--- a/tests/test_utils/urls.py
+++ b/tests/test_utils/urls.py
@@ -2,7 +2,6 @@ from django.conf.urls import url
from . import views
-
urlpatterns = [
url(r'^test_utils/get_person/([0-9]+)/$', views.get_person),
url(r'^test_utils/no_template_used/$', views.no_template_used),
diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py
index a8ee433464..8534b9f8de 100644
--- a/tests/timezones/tests.py
+++ b/tests/timezones/tests.py
@@ -3,30 +3,35 @@ from __future__ import unicode_literals
import datetime
import re
import sys
-from unittest import skipIf
import warnings
+from unittest import skipIf
from xml.dom.minidom import parseString
-try:
- import pytz
-except ImportError:
- pytz = None
-
from django.core import serializers
from django.core.urlresolvers import reverse
-from django.db.models import Min, Max
+from django.db.models import Max, Min
from django.http import HttpRequest
from django.template import (
- context_processors, Context, RequestContext, Template, TemplateSyntaxError)
+ Context, RequestContext, Template, TemplateSyntaxError, context_processors,
+)
from django.test import (
- TestCase, override_settings, skipIfDBFeature, skipUnlessDBFeature)
+ TestCase, override_settings, skipIfDBFeature, skipUnlessDBFeature,
+)
from django.test.utils import requires_tz_support
-from django.utils import six
-from django.utils import timezone
+from django.utils import six, timezone
-from .forms import EventForm, EventSplitForm, EventLocalizedForm, EventModelForm, EventLocalizedModelForm
-from .models import Event, MaybeEvent, Session, SessionEvent, Timestamp, AllDayEvent
+from .forms import (
+ EventForm, EventLocalizedForm, EventLocalizedModelForm, EventModelForm,
+ EventSplitForm,
+)
+from .models import (
+ AllDayEvent, Event, MaybeEvent, Session, SessionEvent, Timestamp,
+)
+try:
+ import pytz
+except ImportError:
+ pytz = None
# These tests use the EAT (Eastern Africa Time) and ICT (Indochina Time)
# who don't have Daylight Saving Time, so we can represent them easily
diff --git a/tests/transactions/tests.py b/tests/transactions/tests.py
index bf4735e0d2..dab406dbac 100644
--- a/tests/transactions/tests.py
+++ b/tests/transactions/tests.py
@@ -5,9 +5,13 @@ import threading
import time
from unittest import skipIf, skipUnless
-from django.db import (connection, transaction,
- DatabaseError, Error, IntegrityError, OperationalError)
-from django.test import TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature
+from django.db import (
+ DatabaseError, Error, IntegrityError, OperationalError, connection,
+ transaction,
+)
+from django.test import (
+ TransactionTestCase, skipIfDBFeature, skipUnlessDBFeature,
+)
from django.utils import six
from .models import Reporter
diff --git a/tests/unmanaged_models/models.py b/tests/unmanaged_models/models.py
index b0dd5c8719..61eb67a620 100644
--- a/tests/unmanaged_models/models.py
+++ b/tests/unmanaged_models/models.py
@@ -6,6 +6,7 @@ is generated for the table on various manage.py operations.
from django.db import models
from django.utils.encoding import python_2_unicode_compatible
+
# All of these models are created in the database by Django.
diff --git a/tests/unmanaged_models/tests.py b/tests/unmanaged_models/tests.py
index b103cd3adc..4ed07bf0d2 100644
--- a/tests/unmanaged_models/tests.py
+++ b/tests/unmanaged_models/tests.py
@@ -3,7 +3,7 @@ from __future__ import unicode_literals
from django.db import connection
from django.test import TestCase
-from .models import A01, A02, B01, B02, C01, C02, Unmanaged2, Managed1
+from .models import A01, A02, B01, B02, C01, C02, Managed1, Unmanaged2
class SimpleTests(TestCase):
diff --git a/tests/update/tests.py b/tests/update/tests.py
index 578b3ab440..1ed316c958 100644
--- a/tests/update/tests.py
+++ b/tests/update/tests.py
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
from django.test import TestCase
-from .models import A, B, D, DataPoint, RelatedPoint, Foo, Bar
+from .models import A, B, D, Bar, DataPoint, Foo, RelatedPoint
class SimpleTest(TestCase):
diff --git a/tests/update_only_fields/tests.py b/tests/update_only_fields/tests.py
index 095858fa49..34519cce4c 100644
--- a/tests/update_only_fields/tests.py
+++ b/tests/update_only_fields/tests.py
@@ -1,9 +1,9 @@
from __future__ import unicode_literals
-from django.db.models.signals import pre_save, post_save
+from django.db.models.signals import post_save, pre_save
from django.test import TestCase
-from .models import Person, Employee, ProxyEmployee, Profile, Account
+from .models import Account, Employee, Person, Profile, ProxyEmployee
class UpdateOnlyFieldsTests(TestCase):
diff --git a/tests/urlpatterns_reverse/extra_urls.py b/tests/urlpatterns_reverse/extra_urls.py
index c30a61a99a..d9c518c219 100644
--- a/tests/urlpatterns_reverse/extra_urls.py
+++ b/tests/urlpatterns_reverse/extra_urls.py
@@ -2,11 +2,10 @@
Some extra URL patterns that are included at the top level.
"""
-from django.conf.urls import url, include
+from django.conf.urls import include, url
from .views import empty_view
-
urlpatterns = [
url(r'^e-places/([0-9]+)/$', empty_view, name='extra-places'),
url(r'^e-people/(?P<name>\w+)/$', empty_view, name="extra-people"),
diff --git a/tests/urlpatterns_reverse/included_named_urls.py b/tests/urlpatterns_reverse/included_named_urls.py
index a4c6afea57..fac37ef714 100644
--- a/tests/urlpatterns_reverse/included_named_urls.py
+++ b/tests/urlpatterns_reverse/included_named_urls.py
@@ -1,8 +1,7 @@
-from django.conf.urls import url, include
+from django.conf.urls import include, url
from .views import empty_view
-
urlpatterns = [
url(r'^$', empty_view, name="named-url3"),
url(r'^extra/(?P<extra>\w+)/$', empty_view, name="named-url4"),
diff --git a/tests/urlpatterns_reverse/included_named_urls2.py b/tests/urlpatterns_reverse/included_named_urls2.py
index 47411ec620..4d617c3790 100644
--- a/tests/urlpatterns_reverse/included_named_urls2.py
+++ b/tests/urlpatterns_reverse/included_named_urls2.py
@@ -2,7 +2,6 @@ from django.conf.urls import url
from .views import empty_view
-
urlpatterns = [
url(r'^$', empty_view, name="named-url5"),
url(r'^extra/(?P<extra>\w+)/$', empty_view, name="named-url6"),
diff --git a/tests/urlpatterns_reverse/included_namespace_urls.py b/tests/urlpatterns_reverse/included_namespace_urls.py
index 2472e7c07d..8769f112e9 100644
--- a/tests/urlpatterns_reverse/included_namespace_urls.py
+++ b/tests/urlpatterns_reverse/included_namespace_urls.py
@@ -1,12 +1,11 @@
import warnings
-from django.conf.urls import patterns, url, include
+from django.conf.urls import include, patterns, url
from django.utils.deprecation import RemovedInDjango20Warning
from .namespace_urls import URLObject
from .views import view_class_instance
-
testobj3 = URLObject('testapp', 'test-ns3')
# test deprecated patterns() function. convert to list of urls() in Django 2.0
diff --git a/tests/urlpatterns_reverse/included_no_kwargs_urls.py b/tests/urlpatterns_reverse/included_no_kwargs_urls.py
index 0c291e0de2..f124a09b2f 100644
--- a/tests/urlpatterns_reverse/included_no_kwargs_urls.py
+++ b/tests/urlpatterns_reverse/included_no_kwargs_urls.py
@@ -2,7 +2,6 @@ from django.conf.urls import url
from .views import empty_view
-
urlpatterns = [
url(r'^inner-no-kwargs/([0-9]+)/', empty_view, name="inner-no-kwargs")
]
diff --git a/tests/urlpatterns_reverse/included_urls.py b/tests/urlpatterns_reverse/included_urls.py
index f8e69cb761..240d9e5665 100644
--- a/tests/urlpatterns_reverse/included_urls.py
+++ b/tests/urlpatterns_reverse/included_urls.py
@@ -2,7 +2,6 @@ from django.conf.urls import url
from .views import empty_view
-
urlpatterns = [
url(r'^$', empty_view, name="inner-nothing"),
url(r'^extra/(?P<extra>\w+)/$', empty_view, name="inner-extra"),
diff --git a/tests/urlpatterns_reverse/included_urls2.py b/tests/urlpatterns_reverse/included_urls2.py
index ac8c770e7f..4a4aef8d95 100644
--- a/tests/urlpatterns_reverse/included_urls2.py
+++ b/tests/urlpatterns_reverse/included_urls2.py
@@ -9,7 +9,6 @@ from django.conf.urls import url
from .views import empty_view
-
urlpatterns = [
url(r'^part/(?P<value>\w+)/$', empty_view, name="part"),
url(r'^part2/(?:(?P<value>\w+)/)?$', empty_view, name="part2"),
diff --git a/tests/urlpatterns_reverse/named_urls.py b/tests/urlpatterns_reverse/named_urls.py
index 3f31249735..647c2630cf 100644
--- a/tests/urlpatterns_reverse/named_urls.py
+++ b/tests/urlpatterns_reverse/named_urls.py
@@ -1,8 +1,7 @@
-from django.conf.urls import url, include
+from django.conf.urls import include, url
from .views import empty_view
-
urlpatterns = [
url(r'^$', empty_view, name="named-url1"),
url(r'^extra/(?P<extra>\w+)/$', empty_view, name="named-url2"),
diff --git a/tests/urlpatterns_reverse/namespace_urls.py b/tests/urlpatterns_reverse/namespace_urls.py
index 12cf85f7d3..e1bb7479e9 100644
--- a/tests/urlpatterns_reverse/namespace_urls.py
+++ b/tests/urlpatterns_reverse/namespace_urls.py
@@ -1,4 +1,4 @@
-from django.conf.urls import url, include
+from django.conf.urls import include, url
from . import views
diff --git a/tests/urlpatterns_reverse/reverse_lazy_urls.py b/tests/urlpatterns_reverse/reverse_lazy_urls.py
index 57358f6254..694b23fad6 100644
--- a/tests/urlpatterns_reverse/reverse_lazy_urls.py
+++ b/tests/urlpatterns_reverse/reverse_lazy_urls.py
@@ -1,6 +1,6 @@
from django.conf.urls import url
-from .views import empty_view, LazyRedirectView, login_required_view
+from .views import LazyRedirectView, empty_view, login_required_view
urlpatterns = [
url(r'^redirected_to/$', empty_view, name='named-lazy-url-redirected-to'),
diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py
index 7b46d0a0a3..3835e09c08 100644
--- a/tests/urlpatterns_reverse/tests.py
+++ b/tests/urlpatterns_reverse/tests.py
@@ -7,24 +7,26 @@ from __future__ import unicode_literals
import sys
import unittest
-from django.contrib.auth.models import User
+from admin_scripts.tests import AdminScriptTestCase
+
from django.conf import settings
+from django.contrib.auth.models import User
from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist
-from django.core.urlresolvers import (reverse, reverse_lazy, resolve, get_callable,
- get_resolver, NoReverseMatch, Resolver404, ResolverMatch, RegexURLResolver,
- RegexURLPattern)
-from django.http import HttpRequest, HttpResponseRedirect, HttpResponsePermanentRedirect
+from django.core.urlresolvers import (
+ NoReverseMatch, RegexURLPattern, RegexURLResolver, Resolver404,
+ ResolverMatch, get_callable, get_resolver, resolve, reverse, reverse_lazy,
+)
+from django.http import (
+ HttpRequest, HttpResponsePermanentRedirect, HttpResponseRedirect,
+)
from django.shortcuts import redirect
from django.test import TestCase, ignore_warnings, override_settings
from django.utils import six
from django.utils.deprecation import RemovedInDjango20Warning
-from admin_scripts.tests import AdminScriptTestCase
-
-from . import urlconf_outer, middleware, views
+from . import middleware, urlconf_outer, views
from .views import empty_view
-
resolve_test_data = (
# These entries are in the format: (path, url_name, app_name, namespace, view_name, func, args, kwargs)
# Simple case
diff --git a/tests/urlpatterns_reverse/urlconf_inner.py b/tests/urlpatterns_reverse/urlconf_inner.py
index d55c4dc650..2a8ed7e26f 100644
--- a/tests/urlpatterns_reverse/urlconf_inner.py
+++ b/tests/urlpatterns_reverse/urlconf_inner.py
@@ -1,6 +1,6 @@
from django.conf.urls import url
-from django.template import Template, Context
from django.http import HttpResponse
+from django.template import Context, Template
def inner_view(request):
diff --git a/tests/urlpatterns_reverse/urlconf_outer.py b/tests/urlpatterns_reverse/urlconf_outer.py
index 36b6529efa..65cf507aa4 100644
--- a/tests/urlpatterns_reverse/urlconf_outer.py
+++ b/tests/urlpatterns_reverse/urlconf_outer.py
@@ -1,8 +1,7 @@
-from django.conf.urls import url, include
+from django.conf.urls import include, url
from . import urlconf_inner
-
urlpatterns = [
url(r'^test/me/$', urlconf_inner.inner_view, name='outer'),
url(r'^inner_urlconf/', include(urlconf_inner.__name__))
diff --git a/tests/urlpatterns_reverse/urls.py b/tests/urlpatterns_reverse/urls.py
index 825ded40a2..9b5a5f29fa 100644
--- a/tests/urlpatterns_reverse/urls.py
+++ b/tests/urlpatterns_reverse/urls.py
@@ -1,6 +1,6 @@
import warnings
-from django.conf.urls import patterns, url, include
+from django.conf.urls import include, patterns, url
from django.utils.deprecation import RemovedInDjango20Warning
from .views import (
@@ -8,7 +8,6 @@ from .views import (
empty_view_wrapped, nested_view,
)
-
other_patterns = [
url(r'non_path_include/$', empty_view, name='non_path_include'),
url(r'nested_path/$', nested_view),
diff --git a/tests/urlpatterns_reverse/urls_error_handlers_callables.py b/tests/urlpatterns_reverse/urls_error_handlers_callables.py
index 5fe8c728ff..4a8d35116e 100644
--- a/tests/urlpatterns_reverse/urls_error_handlers_callables.py
+++ b/tests/urlpatterns_reverse/urls_error_handlers_callables.py
@@ -2,7 +2,6 @@
from .views import empty_view
-
urlpatterns = []
handler400 = empty_view
diff --git a/tests/urlpatterns_reverse/urls_without_full_import.py b/tests/urlpatterns_reverse/urls_without_full_import.py
index 5178a9cfe0..5bbb0955e6 100644
--- a/tests/urlpatterns_reverse/urls_without_full_import.py
+++ b/tests/urlpatterns_reverse/urls_without_full_import.py
@@ -3,8 +3,7 @@
# import pattern.
from django.conf.urls import url
-from .views import empty_view, bad_view
-
+from .views import bad_view, empty_view
urlpatterns = [
url(r'^test_view/$', empty_view, name="test_view"),
diff --git a/tests/urlpatterns_reverse/views.py b/tests/urlpatterns_reverse/views.py
index efd5689c31..9fd2ad166e 100644
--- a/tests/urlpatterns_reverse/views.py
+++ b/tests/urlpatterns_reverse/views.py
@@ -1,10 +1,9 @@
from functools import partial, update_wrapper
+from django.contrib.auth.decorators import user_passes_test
+from django.core.urlresolvers import reverse_lazy
from django.http import HttpResponse
from django.views.generic import RedirectView
-from django.core.urlresolvers import reverse_lazy
-
-from django.contrib.auth.decorators import user_passes_test
def empty_view(request, *args, **kwargs):
diff --git a/tests/user_commands/tests.py b/tests/user_commands/tests.py
index 40ffca95cb..35de5367ca 100644
--- a/tests/user_commands/tests.py
+++ b/tests/user_commands/tests.py
@@ -1,15 +1,15 @@
import os
from django.apps import apps
-from django.db import connection
from django.core import management
from django.core.management import BaseCommand, CommandError, find_commands
from django.core.management.utils import find_command, popen_wrapper
+from django.db import connection
from django.test import SimpleTestCase, ignore_warnings
from django.test.utils import captured_stderr, captured_stdout, extend_sys_path
from django.utils import translation
-from django.utils.deprecation import RemovedInDjango20Warning
from django.utils._os import upath
+from django.utils.deprecation import RemovedInDjango20Warning
from django.utils.six import StringIO
diff --git a/tests/utils_tests/test_archive.py b/tests/utils_tests/test_archive.py
index 6f1b66b14b..d1dc5f2841 100644
--- a/tests/utils_tests/test_archive.py
+++ b/tests/utils_tests/test_archive.py
@@ -3,9 +3,8 @@ import shutil
import tempfile
import unittest
-from django.utils.archive import Archive, extract
from django.utils._os import upath
-
+from django.utils.archive import Archive, extract
TEST_DIR = os.path.join(os.path.dirname(upath(__file__)), 'archives')
diff --git a/tests/utils_tests/test_autoreload.py b/tests/utils_tests/test_autoreload.py
index c0865cba57..c3d20325cd 100644
--- a/tests/utils_tests/test_autoreload.py
+++ b/tests/utils_tests/test_autoreload.py
@@ -1,12 +1,12 @@
-from importlib import import_module
import os
import tempfile
+from importlib import import_module
from django import conf
from django.contrib import admin
from django.test import TestCase, override_settings
-from django.utils.autoreload import gen_filenames
from django.utils._os import upath
+from django.utils.autoreload import gen_filenames
LOCALE_PATH = os.path.join(os.path.dirname(__file__), 'locale')
diff --git a/tests/utils_tests/test_baseconv.py b/tests/utils_tests/test_baseconv.py
index 26ba126eb7..94c2d73b73 100644
--- a/tests/utils_tests/test_baseconv.py
+++ b/tests/utils_tests/test_baseconv.py
@@ -1,6 +1,8 @@
from unittest import TestCase
-from django.utils.baseconv import base2, base16, base36, base56, base62, base64, BaseConverter
+from django.utils.baseconv import (
+ BaseConverter, base2, base16, base36, base56, base62, base64,
+)
from django.utils.six.moves import range
diff --git a/tests/utils_tests/test_datastructures.py b/tests/utils_tests/test_datastructures.py
index 425186c578..8562cd0d42 100644
--- a/tests/utils_tests/test_datastructures.py
+++ b/tests/utils_tests/test_datastructures.py
@@ -5,9 +5,11 @@ Tests for stuff in django.utils.datastructures.
import copy
from django.test import SimpleTestCase
-from django.utils.datastructures import (DictWrapper, ImmutableList,
- MultiValueDict, MultiValueDictKeyError, OrderedSet)
from django.utils import six
+from django.utils.datastructures import (
+ DictWrapper, ImmutableList, MultiValueDict, MultiValueDictKeyError,
+ OrderedSet,
+)
class OrderedSetTests(SimpleTestCase):
diff --git a/tests/utils_tests/test_dateformat.py b/tests/utils_tests/test_dateformat.py
index c65f8beb1c..1edf01422d 100644
--- a/tests/utils_tests/test_dateformat.py
+++ b/tests/utils_tests/test_dateformat.py
@@ -1,13 +1,14 @@
from __future__ import unicode_literals
-from datetime import datetime, date
+from datetime import date, datetime
from django.test import TestCase, override_settings
from django.test.utils import TZ_SUPPORT, requires_tz_support
+from django.utils import dateformat, translation
from django.utils.dateformat import format
-from django.utils import dateformat
-from django.utils.timezone import utc, get_fixed_timezone, get_default_timezone, make_aware
-from django.utils import translation
+from django.utils.timezone import (
+ get_default_timezone, get_fixed_timezone, make_aware, utc,
+)
@override_settings(TIME_ZONE='Europe/Copenhagen')
diff --git a/tests/utils_tests/test_dateparse.py b/tests/utils_tests/test_dateparse.py
index a224e3b174..7d4767feb7 100644
--- a/tests/utils_tests/test_dateparse.py
+++ b/tests/utils_tests/test_dateparse.py
@@ -1,9 +1,11 @@
from __future__ import unicode_literals
-from datetime import date, time, datetime, timedelta
import unittest
+from datetime import date, datetime, time, timedelta
-from django.utils.dateparse import parse_date, parse_time, parse_datetime, parse_duration
+from django.utils.dateparse import (
+ parse_date, parse_datetime, parse_duration, parse_time,
+)
from django.utils.timezone import get_fixed_timezone
diff --git a/tests/utils_tests/test_datetime_safe.py b/tests/utils_tests/test_datetime_safe.py
index 655a7350d5..dcb519b8fb 100644
--- a/tests/utils_tests/test_datetime_safe.py
+++ b/tests/utils_tests/test_datetime_safe.py
@@ -1,6 +1,9 @@
import unittest
+from datetime import (
+ date as original_date, datetime as original_datetime,
+ time as original_time,
+)
-from datetime import date as original_date, datetime as original_datetime, time as original_time
from django.utils.datetime_safe import date, datetime, time
diff --git a/tests/utils_tests/test_decorators.py b/tests/utils_tests/test_decorators.py
index 8ef4737e54..16b861bf1a 100644
--- a/tests/utils_tests/test_decorators.py
+++ b/tests/utils_tests/test_decorators.py
@@ -1,7 +1,7 @@
from django.http import HttpResponse
from django.template import engines
from django.template.response import TemplateResponse
-from django.test import TestCase, RequestFactory
+from django.test import RequestFactory, TestCase
from django.utils.decorators import decorator_from_middleware
diff --git a/tests/utils_tests/test_encoding.py b/tests/utils_tests/test_encoding.py
index be2670854f..81024bdf12 100644
--- a/tests/utils_tests/test_encoding.py
+++ b/tests/utils_tests/test_encoding.py
@@ -1,13 +1,13 @@
# -*- encoding: utf-8 -*-
from __future__ import unicode_literals
-import unittest
import datetime
+import unittest
from django.utils import six
from django.utils.encoding import (
- filepath_to_uri, force_bytes, force_text, escape_uri_path,
- iri_to_uri, uri_to_iri, smart_text,
+ escape_uri_path, filepath_to_uri, force_bytes, force_text, iri_to_uri,
+ smart_text, uri_to_iri,
)
from django.utils.http import urlquote_plus
diff --git a/tests/utils_tests/test_functional.py b/tests/utils_tests/test_functional.py
index e8956a7a29..5f7687edf5 100644
--- a/tests/utils_tests/test_functional.py
+++ b/tests/utils_tests/test_functional.py
@@ -1,6 +1,6 @@
import unittest
-from django.utils.functional import lazy, lazy_property, cached_property
+from django.utils.functional import cached_property, lazy, lazy_property
class FunctionalTestCase(unittest.TestCase):
diff --git a/tests/utils_tests/test_html.py b/tests/utils_tests/test_html.py
index 6375f2280b..db49046682 100644
--- a/tests/utils_tests/test_html.py
+++ b/tests/utils_tests/test_html.py
@@ -1,8 +1,8 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from datetime import datetime
import os
+from datetime import datetime
from unittest import TestCase
from django.test import ignore_warnings
diff --git a/tests/utils_tests/test_http.py b/tests/utils_tests/test_http.py
index ac103f15d6..19bfa79f1a 100644
--- a/tests/utils_tests/test_http.py
+++ b/tests/utils_tests/test_http.py
@@ -1,12 +1,11 @@
from __future__ import unicode_literals
-from datetime import datetime
import sys
import unittest
+from datetime import datetime
+from django.utils import http, six
from django.utils.datastructures import MultiValueDict
-from django.utils import http
-from django.utils import six
class TestUtilsHttp(unittest.TestCase):
diff --git a/tests/utils_tests/test_ipv6.py b/tests/utils_tests/test_ipv6.py
index 6cd0cebc84..802f0f596e 100644
--- a/tests/utils_tests/test_ipv6.py
+++ b/tests/utils_tests/test_ipv6.py
@@ -2,7 +2,7 @@ from __future__ import unicode_literals
import unittest
-from django.utils.ipv6 import is_valid_ipv6_address, clean_ipv6_address
+from django.utils.ipv6 import clean_ipv6_address, is_valid_ipv6_address
class TestUtilsIPv6(unittest.TestCase):
diff --git a/tests/utils_tests/test_module/another_bad_module.py b/tests/utils_tests/test_module/another_bad_module.py
index eac25c4aa5..766456242d 100644
--- a/tests/utils_tests/test_module/another_bad_module.py
+++ b/tests/utils_tests/test_module/another_bad_module.py
@@ -1,4 +1,5 @@
from . import site
+
content = 'Another Bad Module'
site._registry.update({
diff --git a/tests/utils_tests/test_module/another_good_module.py b/tests/utils_tests/test_module/another_good_module.py
index fd69a3b30c..eccdaa4c59 100644
--- a/tests/utils_tests/test_module/another_good_module.py
+++ b/tests/utils_tests/test_module/another_good_module.py
@@ -1,4 +1,5 @@
from . import site
+
content = 'Another Good Module'
site._registry.update({
diff --git a/tests/utils_tests/test_module_loading.py b/tests/utils_tests/test_module_loading.py
index 2addc2649a..8d600cb6f0 100644
--- a/tests/utils_tests/test_module_loading.py
+++ b/tests/utils_tests/test_module_loading.py
@@ -1,16 +1,17 @@
import imp
-from importlib import import_module
import os
import sys
import unittest
+from importlib import import_module
from zipimport import zipimporter
from django.test import SimpleTestCase, modify_settings
from django.test.utils import extend_sys_path
from django.utils import six
-from django.utils.module_loading import (autodiscover_modules, import_string,
- module_has_submodule)
from django.utils._os import upath
+from django.utils.module_loading import (
+ autodiscover_modules, import_string, module_has_submodule,
+)
class DefaultLoader(unittest.TestCase):
diff --git a/tests/utils_tests/test_safestring.py b/tests/utils_tests/test_safestring.py
index e23851815b..c3f18f12d4 100644
--- a/tests/utils_tests/test_safestring.py
+++ b/tests/utils_tests/test_safestring.py
@@ -1,13 +1,13 @@
from __future__ import unicode_literals
-from django.template import Template, Context
+from django.template import Context, Template
from django.test import TestCase
-from django.utils.encoding import force_text, force_bytes
+from django.utils import html, six, text
+from django.utils.encoding import force_bytes, force_text
from django.utils.functional import lazy
-from django.utils.safestring import mark_safe, mark_for_escaping, SafeData, EscapeData
-from django.utils import six
-from django.utils import text
-from django.utils import html
+from django.utils.safestring import (
+ EscapeData, SafeData, mark_for_escaping, mark_safe,
+)
lazystr = lazy(force_text, six.text_type)
lazybytes = lazy(force_bytes, bytes)
diff --git a/tests/utils_tests/test_termcolors.py b/tests/utils_tests/test_termcolors.py
index 9bbeb16f0c..6e1aa50124 100644
--- a/tests/utils_tests/test_termcolors.py
+++ b/tests/utils_tests/test_termcolors.py
@@ -1,7 +1,9 @@
import unittest
-from django.utils.termcolors import (parse_color_setting, PALETTES,
- DEFAULT_PALETTE, LIGHT_PALETTE, DARK_PALETTE, NOCOLOR_PALETTE, colorize)
+from django.utils.termcolors import (
+ DARK_PALETTE, DEFAULT_PALETTE, LIGHT_PALETTE, NOCOLOR_PALETTE, PALETTES,
+ colorize, parse_color_setting,
+)
class TermColorTests(unittest.TestCase):
diff --git a/tests/utils_tests/test_timesince.py b/tests/utils_tests/test_timesince.py
index 376e425a88..90d33d00f7 100644
--- a/tests/utils_tests/test_timesince.py
+++ b/tests/utils_tests/test_timesince.py
@@ -4,8 +4,8 @@ import datetime
import unittest
from django.test.utils import requires_tz_support
-from django.utils.timesince import timesince, timeuntil
from django.utils import timezone
+from django.utils.timesince import timesince, timeuntil
class TimesinceTests(unittest.TestCase):
diff --git a/tests/utils_tests/test_timezone.py b/tests/utils_tests/test_timezone.py
index 9414a6097e..ff1a210e8b 100644
--- a/tests/utils_tests/test_timezone.py
+++ b/tests/utils_tests/test_timezone.py
@@ -3,15 +3,14 @@ import datetime
import pickle
import unittest
+from django.test import override_settings
+from django.utils import timezone
+
try:
import pytz
except ImportError:
pytz = None
-from django.test import override_settings
-from django.utils import timezone
-
-
if pytz is not None:
CET = pytz.timezone("Europe/Paris")
EAT = timezone.get_fixed_timezone(180) # Africa/Nairobi
diff --git a/tests/validation/test_unique.py b/tests/validation/test_unique.py
index 76c7ec174f..2abe85c82c 100644
--- a/tests/validation/test_unique.py
+++ b/tests/validation/test_unique.py
@@ -8,9 +8,10 @@ from django.core.exceptions import ValidationError
from django.db import models
from django.test import TestCase
-from .models import (CustomPKModel, UniqueTogetherModel, UniqueFieldsModel,
- UniqueForDateModel, ModelToValidate, Post, FlexibleDatePost,
- UniqueErrorsModel)
+from .models import (
+ CustomPKModel, FlexibleDatePost, ModelToValidate, Post, UniqueErrorsModel,
+ UniqueFieldsModel, UniqueForDateModel, UniqueTogetherModel,
+)
class GetUniqueCheckTests(unittest.TestCase):
diff --git a/tests/validation/tests.py b/tests/validation/tests.py
index 2a7549a461..defd66edec 100644
--- a/tests/validation/tests.py
+++ b/tests/validation/tests.py
@@ -5,8 +5,10 @@ from django.core.exceptions import NON_FIELD_ERRORS
from django.test import TestCase
from . import ValidationTestCase
-from .models import (Author, Article, ModelToValidate,
- GenericIPAddressTestModel, GenericIPAddrUnpackUniqueTest)
+from .models import (
+ Article, Author, GenericIPAddressTestModel, GenericIPAddrUnpackUniqueTest,
+ ModelToValidate,
+)
class BaseModelValidationTests(ValidationTestCase):
diff --git a/tests/validators/tests.py b/tests/validators/tests.py
index 3e434910d8..869c6d91cb 100644
--- a/tests/validators/tests.py
+++ b/tests/validators/tests.py
@@ -1,11 +1,11 @@
# -*- coding: utf-8 -*-
from __future__ import unicode_literals
-from datetime import datetime, timedelta
import io
import os
import re
import types
+from datetime import datetime, timedelta
from unittest import TestCase
from django.core.exceptions import ValidationError
@@ -13,14 +13,13 @@ from django.core.validators import (
BaseValidator, EmailValidator, MaxLengthValidator, MaxValueValidator,
MinLengthValidator, MinValueValidator, RegexValidator, URLValidator,
validate_comma_separated_integer_list, validate_email, validate_integer,
- validate_ipv46_address, validate_ipv4_address, validate_ipv6_address,
+ validate_ipv4_address, validate_ipv6_address, validate_ipv46_address,
validate_slug,
)
from django.test import SimpleTestCase
from django.test.utils import str_prefix
from django.utils._os import upath
-
NOW = datetime.now()
EXTENDED_SCHEMES = ['http', 'https', 'ftp', 'ftps', 'git', 'file']
diff --git a/tests/view_tests/default_urls.py b/tests/view_tests/default_urls.py
index 1e202472f4..2811bf7740 100644
--- a/tests/view_tests/default_urls.py
+++ b/tests/view_tests/default_urls.py
@@ -1,5 +1,4 @@
from django.conf.urls import include, url
-
from django.contrib import admin
urlpatterns = [
diff --git a/tests/view_tests/generic_urls.py b/tests/view_tests/generic_urls.py
index ed15f55486..9e73a07649 100644
--- a/tests/view_tests/generic_urls.py
+++ b/tests/view_tests/generic_urls.py
@@ -5,8 +5,8 @@ from django.conf.urls import url
from django.contrib.auth import views as auth_views
from django.views.generic import RedirectView
-from .models import Article, DateArticle
from . import views
+from .models import Article, DateArticle
date_based_info_dict = {
'queryset': Article.objects.all(),
diff --git a/tests/view_tests/templatetags/debugtags.py b/tests/view_tests/templatetags/debugtags.py
index 1b9f3f9828..443a89f32c 100644
--- a/tests/view_tests/templatetags/debugtags.py
+++ b/tests/view_tests/templatetags/debugtags.py
@@ -2,7 +2,6 @@ from django import template
from ..views import BrokenException
-
register = template.Library()
diff --git a/tests/view_tests/tests/test_csrf.py b/tests/view_tests/tests/test_csrf.py
index 26ec221e01..4d82588f88 100644
--- a/tests/view_tests/tests/test_csrf.py
+++ b/tests/view_tests/tests/test_csrf.py
@@ -1,4 +1,4 @@
-from django.test import TestCase, override_settings, Client
+from django.test import Client, TestCase, override_settings
from django.utils.translation import override
diff --git a/tests/view_tests/tests/test_debug.py b/tests/view_tests/tests/test_debug.py
index 8645bd3e8e..547b96ffc3 100644
--- a/tests/view_tests/tests/test_debug.py
+++ b/tests/view_tests/tests/test_debug.py
@@ -16,16 +16,17 @@ from django.core import mail
from django.core.files.uploadedfile import SimpleUploadedFile
from django.core.urlresolvers import reverse
from django.template.base import TemplateDoesNotExist
-from django.test import TestCase, RequestFactory, override_settings
-from django.utils.encoding import force_text, force_bytes
+from django.test import RequestFactory, TestCase, override_settings
from django.utils import six
+from django.utils.encoding import force_bytes, force_text
from django.views.debug import CallableSettingWrapper, ExceptionReporter
from .. import BrokenException, except_args
-from ..views import (sensitive_view, non_sensitive_view, paranoid_view,
- custom_exception_reporter_filter_view, sensitive_method_view,
- sensitive_args_function_caller, sensitive_kwargs_function_caller,
- multivalue_dict_key_error)
+from ..views import (
+ custom_exception_reporter_filter_view, multivalue_dict_key_error,
+ non_sensitive_view, paranoid_view, sensitive_args_function_caller,
+ sensitive_kwargs_function_caller, sensitive_method_view, sensitive_view,
+)
class CallableSettingWrapperTests(TestCase):
diff --git a/tests/view_tests/tests/test_i18n.py b/tests/view_tests/tests/test_i18n.py
index ba51d3289b..2f47007b04 100644
--- a/tests/view_tests/tests/test_i18n.py
+++ b/tests/view_tests/tests/test_i18n.py
@@ -2,17 +2,18 @@
import gettext
import json
import os
-from os import path
import unittest
+from os import path
from django.conf import settings
from django.core.urlresolvers import reverse
from django.test import (
- LiveServerTestCase, TestCase, modify_settings, override_settings)
+ LiveServerTestCase, TestCase, modify_settings, override_settings,
+)
from django.utils import six
from django.utils._os import upath
from django.utils.module_loading import import_string
-from django.utils.translation import override, LANGUAGE_SESSION_KEY
+from django.utils.translation import LANGUAGE_SESSION_KEY, override
from ..urls import locale_dir
diff --git a/tests/view_tests/tests/test_static.py b/tests/view_tests/tests/test_static.py
index 5a353806e1..f1b0bf5b75 100644
--- a/tests/view_tests/tests/test_static.py
+++ b/tests/view_tests/tests/test_static.py
@@ -1,8 +1,8 @@
from __future__ import unicode_literals
import mimetypes
-from os import path
import unittest
+from os import path
from django.conf.urls.static import static
from django.http import FileResponse, HttpResponseNotModified
diff --git a/tests/view_tests/urls.py b/tests/view_tests/urls.py
index 0dfc2d4446..0bfcd587c2 100644
--- a/tests/view_tests/urls.py
+++ b/tests/view_tests/urls.py
@@ -1,13 +1,12 @@
# -*- coding: utf-8 -*-
from os import path
-from django.conf.urls import url, include
+from django.conf.urls import include, url
from django.utils._os import upath
from django.views import defaults, i18n, static
from . import views
-
base_dir = path.dirname(path.abspath(upath(__file__)))
media_dir = path.join(base_dir, 'media')
locale_dir = path.join(base_dir, 'locale')
diff --git a/tests/view_tests/views.py b/tests/view_tests/views.py
index 16bee28248..4be67bfc6f 100644
--- a/tests/view_tests/views.py
+++ b/tests/view_tests/views.py
@@ -6,14 +6,18 @@ import sys
from django.core.exceptions import PermissionDenied, SuspiciousOperation
from django.core.urlresolvers import get_resolver
-from django.http import HttpResponse, HttpResponseRedirect, JsonResponse, Http404
-from django.shortcuts import render_to_response, render
+from django.http import (
+ Http404, HttpResponse, HttpResponseRedirect, JsonResponse,
+)
+from django.shortcuts import render, render_to_response
from django.template import TemplateDoesNotExist
-from django.views.debug import technical_500_response, SafeExceptionReporterFilter
-from django.views.decorators.debug import (sensitive_post_parameters,
- sensitive_variables)
from django.utils.log import getLogger
-
+from django.views.debug import (
+ SafeExceptionReporterFilter, technical_500_response,
+)
+from django.views.decorators.debug import (
+ sensitive_post_parameters, sensitive_variables,
+)
from django.views.generic import View
from . import BrokenException, except_args
diff --git a/tests/wsgi/urls.py b/tests/wsgi/urls.py
index e7505c717b..1d7f91b689 100644
--- a/tests/wsgi/urls.py
+++ b/tests/wsgi/urls.py
@@ -1,5 +1,5 @@
from django.conf.urls import url
-from django.http import HttpResponse, FileResponse
+from django.http import FileResponse, HttpResponse
def helloworld(request):