From a8b70d251d238b4e6cfc7bb4296da15494f8dff3 Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Mon, 9 Feb 2015 13:19:34 -0500 Subject: [PATCH] [1.8.x] Sorted imports with isort; refs #23860. Backport of 0ed7d155635da9f79d4dd67e4889087d3673c6da from master --- django/apps/config.py | 5 +- django/apps/registry.py | 4 +- .../project_template/project_name/settings.py | 1 + .../project_template/project_name/wsgi.py | 4 +- django/contrib/admin/actions.py | 4 +- django/contrib/admin/apps.py | 2 +- django/contrib/admin/checks.py | 8 ++- django/contrib/admin/filters.py | 14 ++-- django/contrib/admin/forms.py | 1 - django/contrib/admin/helpers.py | 11 +-- .../contrib/admin/migrations/0001_initial.py | 4 +- django/contrib/admin/models.py | 9 ++- django/contrib/admin/options.py | 44 ++++++------ django/contrib/admin/sites.py | 15 +++-- .../contrib/admin/templatetags/admin_list.py | 19 +++--- django/contrib/admin/util.py | 2 +- django/contrib/admin/utils.py | 2 +- django/contrib/admin/validation.py | 6 +- django/contrib/admin/views/main.py | 30 +++++---- django/contrib/admin/widgets.py | 12 ++-- django/contrib/admindocs/apps.py | 1 - django/contrib/admindocs/middleware.py | 2 +- django/contrib/admindocs/utils.py | 5 +- django/contrib/admindocs/views.py | 20 +++--- django/contrib/auth/admin.py | 16 ++--- django/contrib/auth/apps.py | 2 +- django/contrib/auth/backends.py | 1 + django/contrib/auth/decorators.py | 3 +- django/contrib/auth/forms.py | 13 ++-- django/contrib/auth/handlers/modwsgi.py | 2 +- django/contrib/auth/hashers.py | 14 ++-- .../contrib/auth/migrations/0001_initial.py | 6 +- .../0002_alter_permission_name_max_length.py | 2 +- .../0003_alter_user_email_max_length.py | 2 +- .../0004_alter_user_username_opts.py | 2 +- .../0005_alter_user_last_login_null.py | 2 +- django/contrib/auth/models.py | 21 +++--- django/contrib/auth/tests/backend_alias.py | 4 +- django/contrib/auth/tests/custom_user.py | 11 +-- django/contrib/auth/tests/settings.py | 1 - .../contrib/auth/tests/test_auth_backends.py | 11 +-- django/contrib/auth/tests/test_basic.py | 2 +- .../auth/tests/test_context_processors.py | 4 +- django/contrib/auth/tests/test_forms.py | 12 ++-- django/contrib/auth/tests/test_handlers.py | 9 +-- django/contrib/auth/tests/test_hashers.py | 10 +-- django/contrib/auth/tests/test_management.py | 17 +++-- django/contrib/auth/tests/test_models.py | 4 +- django/contrib/auth/tests/test_signals.py | 3 +- django/contrib/auth/tests/test_templates.py | 7 +- django/contrib/auth/tests/test_tokens.py | 4 +- django/contrib/auth/tests/test_views.py | 23 ++++--- django/contrib/auth/tests/urls.py | 10 +-- django/contrib/auth/tests/urls_admin.py | 4 +- django/contrib/auth/tokens.py | 5 +- django/contrib/auth/views.py | 25 ++++--- django/contrib/contenttypes/admin.py | 2 +- django/contrib/contenttypes/checks.py | 2 +- django/contrib/contenttypes/fields.py | 9 ++- django/contrib/contenttypes/forms.py | 2 +- django/contrib/contenttypes/generic.py | 12 ++-- .../contenttypes/migrations/0001_initial.py | 2 +- .../0002_remove_content_type_name.py | 2 +- django/contrib/contenttypes/models.py | 2 +- django/contrib/contenttypes/tests/tests.py | 5 +- django/contrib/flatpages/admin.py | 2 +- django/contrib/flatpages/apps.py | 1 - django/contrib/flatpages/middleware.py | 2 +- .../flatpages/migrations/0001_initial.py | 2 +- django/contrib/flatpages/models.py | 4 +- .../flatpages/templatetags/flatpages.py | 1 - django/contrib/flatpages/tests/settings.py | 1 - django/contrib/flatpages/tests/test_csrf.py | 3 +- django/contrib/flatpages/tests/test_models.py | 2 +- .../flatpages/tests/test_templatetags.py | 2 +- django/contrib/gis/admin/options.py | 2 +- django/contrib/gis/admin/widgets.py | 8 +-- django/contrib/gis/apps.py | 1 - django/contrib/gis/db/backends/mysql/base.py | 3 +- .../contrib/gis/db/backends/mysql/features.py | 3 +- .../gis/db/backends/mysql/operations.py | 3 +- .../contrib/gis/db/backends/mysql/schema.py | 2 +- .../contrib/gis/db/backends/oracle/adapter.py | 1 + django/contrib/gis/db/backends/oracle/base.py | 3 +- .../gis/db/backends/oracle/features.py | 3 +- .../gis/db/backends/oracle/introspection.py | 4 +- .../gis/db/backends/oracle/operations.py | 4 +- .../contrib/gis/db/backends/postgis/base.py | 5 +- .../gis/db/backends/postgis/features.py | 5 +- .../gis/db/backends/postgis/introspection.py | 3 +- .../contrib/gis/db/backends/postgis/models.py | 2 +- .../gis/db/backends/postgis/operations.py | 6 +- .../gis/db/backends/spatialite/adapter.py | 2 +- .../gis/db/backends/spatialite/features.py | 3 +- .../db/backends/spatialite/introspection.py | 4 +- .../gis/db/backends/spatialite/models.py | 4 +- .../gis/db/backends/spatialite/operations.py | 5 +- .../gis/db/backends/spatialite/schema.py | 2 +- django/contrib/gis/db/backends/util.py | 2 +- django/contrib/gis/db/models/aggregates.py | 2 +- django/contrib/gis/db/models/fields.py | 6 +- django/contrib/gis/db/models/lookups.py | 3 +- django/contrib/gis/db/models/manager.py | 2 +- django/contrib/gis/db/models/query.py | 12 ++-- .../contrib/gis/db/models/sql/aggregates.py | 1 - django/contrib/gis/forms/fields.py | 4 +- django/contrib/gis/forms/widgets.py | 5 +- django/contrib/gis/gdal/datasource.py | 4 +- django/contrib/gis/gdal/driver.py | 2 +- django/contrib/gis/gdal/envelope.py | 1 + django/contrib/gis/gdal/feature.py | 6 +- django/contrib/gis/gdal/field.py | 1 + django/contrib/gis/gdal/geometries.py | 18 ++--- django/contrib/gis/gdal/geomtype.py | 1 - django/contrib/gis/gdal/layer.py | 19 +++--- django/contrib/gis/gdal/libgdal.py | 2 +- django/contrib/gis/gdal/prototypes/ds.py | 9 ++- .../contrib/gis/gdal/prototypes/errcheck.py | 4 +- .../contrib/gis/gdal/prototypes/generation.py | 6 +- django/contrib/gis/gdal/prototypes/geom.py | 9 ++- django/contrib/gis/gdal/prototypes/raster.py | 8 ++- django/contrib/gis/gdal/prototypes/srs.py | 9 ++- django/contrib/gis/gdal/raster/source.py | 9 +-- django/contrib/gis/gdal/srs.py | 1 - django/contrib/gis/gdal/tests/test_ds.py | 4 +- django/contrib/gis/gdal/tests/test_geom.py | 12 ++-- django/contrib/gis/geoip/base.py | 10 +-- django/contrib/gis/geoip/libgeoip.py | 1 + django/contrib/gis/geoip/prototypes.py | 5 +- django/contrib/gis/geoip/tests.py | 3 +- django/contrib/gis/geometry/backend/geos.py | 3 +- django/contrib/gis/geometry/test_data.py | 1 - django/contrib/gis/geos/collections.py | 7 +- django/contrib/gis/geos/coordseq.py | 5 +- django/contrib/gis/geos/factory.py | 3 +- django/contrib/gis/geos/geometry.py | 34 ++++------ django/contrib/gis/geos/io.py | 4 +- django/contrib/gis/geos/libgeos.py | 2 +- django/contrib/gis/geos/linestring.py | 2 +- django/contrib/gis/geos/mutable_list.py | 2 +- django/contrib/gis/geos/point.py | 3 +- django/contrib/gis/geos/polygon.py | 9 +-- .../contrib/gis/geos/prototypes/coordseq.py | 9 ++- .../contrib/gis/geos/prototypes/errcheck.py | 2 +- django/contrib/gis/geos/prototypes/geom.py | 6 +- django/contrib/gis/geos/prototypes/io.py | 8 ++- django/contrib/gis/geos/prototypes/misc.py | 3 +- .../contrib/gis/geos/prototypes/predicates.py | 1 + .../contrib/gis/geos/prototypes/prepared.py | 5 +- .../contrib/gis/geos/prototypes/threadsafe.py | 5 +- .../contrib/gis/geos/prototypes/topology.py | 5 +- django/contrib/gis/geos/tests/test_geos.py | 6 +- django/contrib/gis/geos/tests/test_io.py | 2 +- .../gis/management/commands/inspectdb.py | 3 +- django/contrib/gis/maps/google/gmap.py | 5 +- django/contrib/gis/maps/google/overlays.py | 8 ++- django/contrib/gis/maps/google/zoom.py | 5 +- django/contrib/gis/measure.py | 2 +- django/contrib/gis/serializers/geojson.py | 4 +- django/contrib/gis/sitemaps/kml.py | 4 +- django/contrib/gis/sitemaps/views.py | 4 +- django/contrib/gis/tests/distapp/tests.py | 8 ++- django/contrib/gis/tests/geo3d/tests.py | 2 +- django/contrib/gis/tests/geoadmin/models.py | 2 +- django/contrib/gis/tests/geoapp/sitemaps.py | 1 - django/contrib/gis/tests/geoapp/test_feeds.py | 4 +- .../contrib/gis/tests/geoapp/test_sitemaps.py | 5 +- django/contrib/gis/tests/geoapp/tests.py | 6 +- django/contrib/gis/tests/geoapp/urls.py | 3 +- .../gis_migrations/migrations/0001_initial.py | 2 +- .../gis/tests/gis_migrations/test_commands.py | 2 +- .../tests/gis_migrations/test_operations.py | 2 +- django/contrib/gis/tests/inspectapp/tests.py | 4 +- django/contrib/gis/tests/layermap/tests.py | 6 +- django/contrib/gis/tests/test_geoforms.py | 2 +- django/contrib/gis/tests/test_measure.py | 2 +- .../contrib/gis/tests/test_spatialrefsys.py | 6 +- django/contrib/gis/utils/layermapping.py | 15 +++-- django/contrib/gis/utils/ogrinspect.py | 6 +- django/contrib/gis/utils/srs.py | 2 +- django/contrib/humanize/apps.py | 1 - .../contrib/humanize/templatetags/humanize.py | 2 +- django/contrib/humanize/tests.py | 17 ++--- django/contrib/messages/apps.py | 1 - django/contrib/messages/storage/base.py | 3 +- django/contrib/messages/storage/cookie.py | 4 +- django/contrib/messages/storage/session.py | 4 +- django/contrib/messages/tests/base.py | 4 +- django/contrib/messages/tests/test_api.py | 3 +- django/contrib/messages/tests/test_cookie.py | 7 +- .../contrib/messages/tests/test_fallback.py | 15 +++-- django/contrib/messages/tests/test_mixins.py | 2 +- django/contrib/messages/tests/test_session.py | 4 +- django/contrib/messages/tests/urls.py | 7 +- django/contrib/postgres/fields/array.py | 3 +- django/contrib/postgres/fields/hstore.py | 3 +- django/contrib/postgres/fields/ranges.py | 7 +- django/contrib/postgres/forms/array.py | 8 ++- django/contrib/postgres/forms/hstore.py | 1 - django/contrib/postgres/forms/ranges.py | 7 +- django/contrib/postgres/signals.py | 4 +- django/contrib/postgres/validators.py | 4 +- django/contrib/redirects/apps.py | 1 - django/contrib/redirects/middleware.py | 2 +- .../redirects/migrations/0001_initial.py | 2 +- django/contrib/redirects/models.py | 4 +- django/contrib/sessions/apps.py | 1 - django/contrib/sessions/backends/base.py | 11 ++- django/contrib/sessions/backends/cache.py | 2 +- django/contrib/sessions/backends/cached_db.py | 3 +- django/contrib/sessions/backends/db.py | 7 +- django/contrib/sessions/backends/file.py | 9 +-- .../sessions/backends/signed_cookies.py | 3 +- django/contrib/sessions/middleware.py | 2 +- .../sessions/migrations/0001_initial.py | 2 +- django/contrib/sessions/models.py | 3 +- django/contrib/sessions/serializers.py | 1 + django/contrib/sessions/tests.py | 24 ++++--- django/contrib/sitemaps/apps.py | 1 - .../management/commands/ping_google.py | 2 +- .../contrib/sitemaps/tests/test_flatpages.py | 2 +- django/contrib/sitemaps/tests/test_generic.py | 2 +- django/contrib/sitemaps/tests/test_http.py | 6 +- django/contrib/sitemaps/tests/urls/http.py | 8 ++- django/contrib/sitemaps/views.py | 2 +- django/contrib/sites/apps.py | 1 - .../contrib/sites/migrations/0001_initial.py | 4 +- django/contrib/sites/models.py | 3 +- django/contrib/sites/tests.py | 2 +- django/contrib/staticfiles/apps.py | 1 - django/contrib/staticfiles/finders.py | 17 ++--- django/contrib/staticfiles/handlers.py | 7 +- .../management/commands/collectstatic.py | 7 +- .../management/commands/findstatic.py | 4 +- .../management/commands/runserver.py | 4 +- django/contrib/staticfiles/storage.py | 17 +++-- .../staticfiles/templatetags/staticfiles.py | 2 +- django/contrib/staticfiles/testing.py | 3 +- django/contrib/staticfiles/utils.py | 3 +- django/contrib/staticfiles/views.py | 3 +- django/contrib/syndication/apps.py | 1 - django/contrib/syndication/views.py | 7 +- django/contrib/webdesign/apps.py | 1 - django/core/cache/backends/base.py | 2 +- django/core/cache/backends/db.py | 14 ++-- django/core/cache/backends/dummy.py | 2 +- django/core/cache/backends/filebased.py | 4 +- django/core/cache/backends/locmem.py | 9 +-- django/core/cache/backends/memcached.py | 8 ++- django/core/cache/utils.py | 1 + .../core/checks/compatibility/django_1_7_0.py | 2 +- django/core/checks/messages.py | 3 +- django/core/checks/security/base.py | 3 +- django/core/checks/security/csrf.py | 3 +- django/core/checks/security/sessions.py | 2 +- django/core/context_processors.py | 3 +- django/core/files/move.py | 1 - django/core/files/storage.py | 15 ++--- django/core/files/temp.py | 1 + django/core/files/uploadedfile.py | 2 +- django/core/files/uploadhandler.py | 4 +- django/core/handlers/base.py | 9 +-- django/core/handlers/wsgi.py | 10 ++- django/core/mail/backends/filebased.py | 3 +- django/core/mail/backends/smtp.py | 2 +- django/core/mail/message.py | 16 ++--- django/core/management/base.py | 10 +-- django/core/management/color.py | 3 +- .../management/commands/createcachetable.py | 4 +- django/core/management/commands/dbshell.py | 2 +- django/core/management/commands/dumpdata.py | 5 +- django/core/management/commands/flush.py | 6 +- django/core/management/commands/inspectdb.py | 4 +- django/core/management/commands/loaddata.py | 12 ++-- .../core/management/commands/makemessages.py | 11 +-- .../management/commands/makemigrations.py | 10 +-- django/core/management/commands/migrate.py | 12 ++-- django/core/management/commands/runserver.py | 17 +++-- .../management/commands/showmigrations.py | 2 +- django/core/management/commands/sql.py | 2 +- django/core/management/commands/sqlall.py | 2 +- django/core/management/commands/sqlclear.py | 2 +- django/core/management/commands/sqlcustom.py | 2 +- .../management/commands/sqldropindexes.py | 2 +- django/core/management/commands/sqlflush.py | 2 +- django/core/management/commands/sqlindexes.py | 2 +- django/core/management/commands/sqlmigrate.py | 2 +- .../management/commands/sqlsequencereset.py | 2 +- .../management/commands/squashmigrations.py | 10 +-- django/core/management/commands/syncdb.py | 2 +- django/core/management/commands/test.py | 2 +- django/core/management/templates.py | 12 ++-- django/core/management/utils.py | 4 +- django/core/serializers/json.py | 8 +-- django/core/serializers/python.py | 2 +- django/core/serializers/pyyaml.py | 10 +-- django/core/serializers/xml_serializer.py | 13 ++-- django/core/servers/basehttp.py | 2 +- django/core/urlresolvers.py | 9 ++- django/core/validators.py | 5 +- django/db/backends/base/base.py | 7 +- django/db/backends/base/creation.py | 1 - django/db/backends/base/introspection.py | 1 - django/db/backends/base/operations.py | 2 +- django/db/backends/dummy/base.py | 2 +- django/db/backends/mysql/base.py | 20 +++--- django/db/backends/mysql/introspection.py | 8 +-- django/db/backends/oracle/base.py | 14 ++-- django/db/backends/oracle/creation.py | 1 - django/db/backends/oracle/operations.py | 2 +- django/db/backends/oracle/schema.py | 6 +- .../db/backends/postgresql_psycopg2/base.py | 18 ++--- .../postgresql_psycopg2/introspection.py | 2 +- .../postgresql_psycopg2/operations.py | 4 +- .../db/backends/postgresql_psycopg2/schema.py | 4 +- django/db/backends/sqlite3/base.py | 14 ++-- django/db/backends/sqlite3/introspection.py | 1 - django/db/backends/sqlite3/operations.py | 6 +- django/db/backends/sqlite3/schema.py | 4 +- django/db/backends/util.py | 2 +- django/db/backends/utils.py | 1 - django/db/migrations/autodetector.py | 9 ++- django/db/migrations/executor.py | 3 +- django/db/migrations/graph.py | 1 + django/db/migrations/loader.py | 3 +- django/db/migrations/migration.py | 1 + django/db/migrations/operations/base.py | 1 + django/db/migrations/operations/fields.py | 1 + django/db/migrations/operations/models.py | 4 +- django/db/migrations/state.py | 11 +-- django/db/migrations/writer.py | 5 +- django/db/models/aggregates.py | 2 +- django/db/models/deletion.py | 2 +- django/db/models/expressions.py | 2 +- django/db/models/fields/files.py | 10 +-- django/db/models/fields/related.py | 21 +++--- django/db/models/loading.py | 1 - django/db/models/lookups.py | 2 +- django/db/models/manager.py | 2 +- django/db/models/options.py | 8 ++- django/db/models/query.py | 25 ++++--- django/db/models/query_utils.py | 4 +- django/db/models/sql/aggregates.py | 3 +- django/db/models/sql/compiler.py | 11 +-- django/db/models/sql/query.py | 29 ++++---- django/db/models/sql/subqueries.py | 1 - django/db/models/sql/where.py | 8 +-- django/db/transaction.py | 4 +- django/db/utils.py | 9 ++- django/dispatch/weakref_backports.py | 1 - django/forms/extras/widgets.py | 9 ++- django/forms/fields.py | 36 +++++----- django/forms/forms.py | 15 +++-- django/forms/formsets.py | 7 +- django/forms/models.py | 21 +++--- django/forms/util.py | 2 +- django/forms/utils.py | 20 +++--- django/forms/widgets.py | 6 +- django/http/cookie.py | 4 +- django/http/multipartparser.py | 6 +- django/http/request.py | 9 +-- django/http/response.py | 8 +-- django/middleware/cache.py | 8 ++- django/middleware/common.py | 9 ++- django/middleware/csrf.py | 3 +- django/middleware/gzip.py | 2 +- django/middleware/locale.py | 7 +- django/shortcuts.py | 16 +++-- django/template/backends/base.py | 3 +- django/template/backends/django.py | 3 +- django/template/backends/jinja2.py | 4 +- django/template/base.py | 30 +++++---- django/template/context.py | 3 +- django/template/debug.py | 8 ++- django/template/defaultfilters.py | 25 +++---- django/template/defaulttags.py | 29 ++++---- django/template/engine.py | 4 +- django/template/loader.py | 8 +-- django/template/loader_tags.py | 7 +- django/template/loaders/cached.py | 1 + django/template/loaders/eggs.py | 10 +-- django/template/response.py | 2 +- django/template/utils.py | 5 +- django/templatetags/cache.py | 6 +- django/templatetags/future.py | 7 +- django/templatetags/i18n.py | 9 +-- django/templatetags/l10n.py | 3 +- django/templatetags/tz.py | 7 +- django/test/client.py | 19 +++--- django/test/html.py | 7 +- django/test/runner.py | 2 +- django/test/signals.py | 4 +- django/test/testcases.py | 27 ++++---- django/test/utils.py | 10 +-- django/utils/_os.py | 4 +- django/utils/autoreload.py | 3 +- django/utils/cache.py | 2 +- django/utils/crypto.py | 19 +++--- django/utils/dateformat.py | 12 ++-- django/utils/dateparse.py | 4 +- django/utils/dates.py | 2 +- django/utils/datetime_safe.py | 4 +- django/utils/deconstruct.py | 4 +- django/utils/decorators.py | 2 +- django/utils/dictconfig.py | 10 +-- django/utils/encoding.py | 5 +- django/utils/feedgenerator.py | 6 +- django/utils/formats.py | 14 ++-- django/utils/functional.py | 2 +- django/utils/html.py | 11 +-- django/utils/html_parser.py | 3 +- django/utils/http.py | 8 +-- django/utils/importlib.py | 3 +- django/utils/ipv6.py | 2 +- django/utils/jslex.py | 1 + django/utils/log.py | 7 +- django/utils/module_loading.py | 5 +- django/utils/numberformat.py | 2 +- django/utils/safestring.py | 2 +- django/utils/text.py | 10 +-- django/utils/timezone.py | 12 ++-- django/utils/translation/trans_real.py | 16 +++-- django/utils/tzinfo.py | 6 +- django/views/csrf.py | 1 + django/views/debug.py | 13 ++-- django/views/decorators/cache.py | 7 +- django/views/decorators/csrf.py | 5 +- django/views/decorators/gzip.py | 2 +- django/views/decorators/http.py | 10 ++- django/views/decorators/vary.py | 1 + django/views/defaults.py | 2 +- django/views/generic/base.py | 4 +- django/views/generic/dates.py | 13 ++-- django/views/generic/detail.py | 2 +- django/views/generic/edit.py | 7 +- django/views/generic/list.py | 4 +- django/views/i18n.py | 14 ++-- django/views/static.py | 10 +-- docs/_ext/applyxrefs.py | 2 +- docs/_ext/djangodocs.py | 7 +- docs/_ext/literals_to_xrefs.py | 2 +- scripts/manage_translations.py | 5 +- setup.py | 4 +- tests/admin_autodiscover/admin.py | 1 - tests/admin_changelist/admin.py | 5 +- tests/admin_changelist/tests.py | 27 ++++---- tests/admin_changelist/urls.py | 1 - tests/admin_checks/models.py | 4 +- tests/admin_checks/tests.py | 2 +- tests/admin_custom_urls/tests.py | 2 +- tests/admin_custom_urls/urls.py | 1 - tests/admin_docs/tests.py | 4 +- tests/admin_docs/views.py | 2 +- tests/admin_filters/models.py | 4 +- tests/admin_filters/tests.py | 12 ++-- tests/admin_inlines/admin.py | 2 +- tests/admin_inlines/models.py | 3 +- tests/admin_inlines/tests.py | 8 +-- tests/admin_inlines/urls.py | 1 - tests/admin_ordering/tests.py | 8 ++- tests/admin_registration/tests.py | 2 +- tests/admin_scripts/app_with_import/models.py | 2 +- tests/admin_scripts/complex_app/admin/foo.py | 1 - tests/admin_scripts/tests.py | 16 +++-- tests/admin_scripts/urls.py | 1 + tests/admin_utils/tests.py | 16 +++-- tests/admin_validation/tests.py | 2 +- tests/admin_views/admin.py | 53 +++++++-------- .../custom_has_permission_admin.py | 2 +- tests/admin_views/customadmin.py | 6 +- tests/admin_views/models.py | 4 +- tests/admin_views/tests.py | 67 ++++++++++--------- tests/admin_views/urls.py | 3 +- tests/admin_widgets/models.py | 2 +- tests/admin_widgets/tests.py | 20 +++--- tests/admin_widgets/urls.py | 1 - tests/aggregation/tests.py | 13 ++-- tests/aggregation_regress/models.py | 2 +- tests/aggregation_regress/tests.py | 10 +-- tests/annotations/tests.py | 8 +-- tests/apps/models.py | 1 - tests/apps/tests.py | 9 ++- tests/backends/models.py | 2 +- tests/backends/tests.py | 20 +++--- tests/basic/tests.py | 15 +++-- tests/builtin_server/tests.py | 3 +- tests/bulk_create/tests.py | 7 +- tests/cache/models.py | 3 +- tests/cache/tests.py | 39 ++++++----- .../test_model_field_deprecation.py | 2 +- tests/check_framework/test_security.py | 5 +- tests/check_framework/tests.py | 7 +- tests/choices/models.py | 1 - tests/commands_sql/tests.py | 8 ++- .../migrations/0001_initial.py | 2 +- tests/commands_sql_migrations/tests.py | 7 +- tests/conditional_processing/tests.py | 1 - tests/conditional_processing/urls.py | 1 - tests/conditional_processing/views.py | 4 +- tests/contenttypes_tests/tests.py | 8 +-- tests/context_processors/urls.py | 1 - tests/csrf_tests/tests.py | 7 +- tests/custom_columns/tests.py | 2 +- tests/custom_lookups/tests.py | 6 +- tests/custom_managers/models.py | 4 +- tests/custom_managers/tests.py | 8 ++- tests/custom_pk/models.py | 2 +- tests/custom_pk/tests.py | 4 +- tests/dates/tests.py | 2 +- tests/datetimes/tests.py | 11 ++- tests/db_functions/tests.py | 6 +- tests/db_typecasts/tests.py | 1 - tests/decorators/tests.py | 24 ++++--- tests/defer/tests.py | 4 +- tests/defer_regress/tests.py | 10 +-- tests/delete/tests.py | 11 +-- tests/delete_regress/models.py | 2 +- tests/delete_regress/tests.py | 12 ++-- tests/deprecation/tests.py | 2 +- tests/dispatch/tests.py | 1 - tests/distinct_on_fields/tests.py | 2 +- tests/expressions/tests.py | 20 +++--- tests/expressions_case/tests.py | 8 +-- tests/extra_regress/tests.py | 4 +- tests/field_subclassing/fields.py | 4 +- tests/field_subclassing/models.py | 5 +- tests/field_subclassing/tests.py | 2 +- tests/file_storage/models.py | 2 +- tests/file_storage/tests.py | 15 ++--- tests/file_storage/urls.py | 1 - tests/file_uploads/tests.py | 6 +- tests/file_uploads/urls.py | 1 - tests/file_uploads/views.py | 2 +- tests/files/tests.py | 10 +-- tests/fixtures/tests.py | 8 ++- tests/fixtures_migration/tests.py | 2 +- tests/fixtures_regress/tests.py | 33 ++++----- tests/force_insert_update/tests.py | 7 +- tests/foreign_object/models.py | 3 +- tests/foreign_object/tests.py | 13 ++-- tests/forms_tests/models.py | 1 - .../forms_tests/tests/test_error_messages.py | 6 +- tests/forms_tests/tests/test_extra.py | 7 +- tests/forms_tests/tests/test_fields.py | 24 +++---- tests/forms_tests/tests/test_forms.py | 12 ++-- tests/forms_tests/tests/test_formsets.py | 6 +- tests/forms_tests/tests/test_input_formats.py | 5 +- tests/forms_tests/tests/test_media.py | 4 +- tests/forms_tests/tests/test_regressions.py | 4 +- tests/forms_tests/tests/test_utils.py | 6 +- tests/forms_tests/tests/test_widgets.py | 10 +-- tests/forms_tests/tests/tests.py | 10 ++- tests/forms_tests/urls.py | 1 - tests/from_db_value/tests.py | 2 +- tests/generic_inline_admin/admin.py | 6 +- tests/generic_inline_admin/models.py | 2 +- tests/generic_inline_admin/tests.py | 8 ++- tests/generic_relations/models.py | 2 +- tests/generic_relations/tests.py | 9 +-- tests/generic_relations_regress/models.py | 5 +- tests/generic_relations_regress/tests.py | 13 ++-- tests/generic_views/test_base.py | 8 ++- tests/generic_views/test_edit.py | 4 +- tests/generic_views/test_list.py | 4 +- tests/generic_views/urls.py | 4 +- tests/generic_views/views.py | 2 +- tests/get_earliest_or_latest/tests.py | 2 +- tests/get_object_or_404/tests.py | 4 +- tests/get_or_create/tests.py | 12 ++-- tests/handlers/tests.py | 9 +-- tests/http_utils/tests.py | 6 +- tests/httpwrappers/tests.py | 17 ++--- tests/i18n/contenttypes/tests.py | 3 +- tests/i18n/patterns/tests.py | 8 ++- tests/i18n/patterns/urls/default.py | 1 - tests/i18n/patterns/urls/included.py | 1 - tests/i18n/patterns/urls/namespace.py | 1 - tests/i18n/patterns/urls/path_unused.py | 1 - tests/i18n/patterns/urls/wrong.py | 1 - tests/i18n/patterns/urls/wrong_namespace.py | 1 - tests/i18n/test_compilation.py | 13 ++-- tests/i18n/test_extraction.py | 12 ++-- tests/i18n/tests.py | 43 ++++++------ tests/i18n/urls.py | 1 - tests/indexes/models.py | 3 +- tests/initial_sql_regress/tests.py | 2 +- tests/inline_formsets/tests.py | 2 +- tests/introspection/tests.py | 2 +- tests/invalid_models_tests/test_models.py | 2 +- .../test_relative_fields.py | 2 +- tests/known_related_objects/tests.py | 2 +- tests/logging_tests/tests.py | 9 ++- tests/logging_tests/views.py | 2 +- tests/lookup/tests.py | 2 +- tests/m2m_and_m2o/tests.py | 2 +- tests/m2m_intermediary/tests.py | 2 +- tests/m2m_regress/tests.py | 6 +- tests/m2m_signals/tests.py | 2 +- tests/m2m_through/tests.py | 8 ++- tests/m2m_through_regress/tests.py | 7 +- tests/mail/tests.py | 17 ++--- tests/managers_regress/models.py | 4 +- tests/managers_regress/tests.py | 14 +--- tests/many_to_one/tests.py | 10 +-- tests/max_lengths/tests.py | 2 +- tests/middleware/test_security.py | 2 +- tests/middleware/tests.py | 14 ++-- tests/middleware/views.py | 10 +-- tests/middleware_exceptions/tests.py | 2 +- tests/migrate_signals/tests.py | 3 +- .../migrations/0001_initial.py | 2 +- .../migration_test_data_persistence/tests.py | 3 +- .../lookuperror_a/migrations/0001_initial.py | 2 +- .../lookuperror_a/migrations/0002_a2.py | 2 +- .../lookuperror_a/migrations/0003_a3.py | 2 +- .../lookuperror_a/migrations/0004_a4.py | 2 +- .../lookuperror_b/migrations/0001_initial.py | 2 +- .../lookuperror_b/migrations/0002_b2.py | 2 +- .../lookuperror_b/migrations/0003_b3.py | 2 +- .../lookuperror_c/migrations/0001_initial.py | 2 +- .../lookuperror_c/migrations/0002_c2.py | 2 +- .../lookuperror_c/migrations/0003_c3.py | 2 +- .../unmigrated_app/models.py | 1 + tests/migrations/test_autodetector.py | 10 +-- tests/migrations/test_commands.py | 2 +- tests/migrations/test_executor.py | 4 +- tests/migrations/test_graph.py | 4 +- tests/migrations/test_loader.py | 5 +- .../0001_initial.py | 2 +- .../test_migrations_no_changes/0003_third.py | 2 +- .../0001_initial.py | 2 +- tests/migrations/test_multidb.py | 12 ++-- tests/migrations/test_operations.py | 10 +-- tests/migrations/test_optimizer.py | 5 +- tests/migrations/test_state.py | 9 ++- tests/migrations/test_writer.py | 20 +++--- tests/model_fields/models.py | 22 +++--- tests/model_fields/test_field_flags.py | 6 +- tests/model_fields/test_uuid.py | 2 +- tests/model_fields/tests.py | 28 ++++---- tests/model_forms/models.py | 3 +- tests/model_forms/tests.py | 30 +++++---- tests/model_formsets/tests.py | 18 +++-- tests/model_formsets_regress/tests.py | 11 +-- tests/model_inheritance/models.py | 1 + .../same_model_name/models.py | 4 +- tests/model_inheritance/tests.py | 7 +- tests/model_inheritance_regress/tests.py | 14 ++-- tests/model_meta/models.py | 7 +- tests/model_meta/results.py | 4 +- tests/model_meta/test_legacy.py | 2 +- tests/model_meta/tests.py | 12 ++-- tests/model_options/models/tablespaces.py | 1 + .../test_default_related_name.py | 2 +- tests/model_options/test_tablespaces.py | 5 +- tests/model_package/tests.py | 4 +- tests/model_permalink/views.py | 10 +-- tests/model_regress/models.py | 1 - tests/model_regress/test_pickle.py | 2 +- tests/model_regress/tests.py | 10 +-- tests/model_validation/tests.py | 4 +- tests/modeladmin/tests.py | 14 ++-- tests/multiple_database/models.py | 2 +- tests/multiple_database/tests.py | 4 +- tests/nested_foreign_keys/tests.py | 4 +- tests/null_fk/tests.py | 5 +- tests/null_fk_ordering/tests.py | 2 +- tests/null_queries/tests.py | 4 +- tests/one_to_one/tests.py | 8 ++- tests/order_with_respect_to/tests.py | 5 +- tests/pagination/custom.py | 2 +- tests/pagination/tests.py | 9 +-- .../array_default_migrations/0001_initial.py | 2 +- .../0002_integerarraymodel_field_2.py | 2 +- .../migrations/0001_setup_extensions.py | 4 +- .../migrations/0002_create_test_models.py | 2 +- tests/postgres_tests/models.py | 4 +- tests/postgres_tests/test_array.py | 9 ++- tests/postgres_tests/test_ranges.py | 10 +-- tests/prefetch_related/models.py | 2 +- tests/prefetch_related/tests.py | 12 ++-- tests/proxy_model_inheritance/tests.py | 5 +- tests/proxy_models/admin.py | 2 +- tests/proxy_models/models.py | 1 + tests/proxy_models/tests.py | 16 ++--- tests/proxy_models/urls.py | 1 - tests/queries/tests.py | 38 ++++++----- tests/queryset_pickle/models.py | 2 +- tests/queryset_pickle/tests.py | 4 +- tests/raw_query/tests.py | 2 +- tests/requests/tests.py | 12 ++-- tests/resolve_url/tests.py | 4 +- tests/reverse_lookup/tests.py | 2 +- tests/runtests.py | 11 +-- tests/schema/fields.py | 5 +- tests/schema/tests.py | 16 +++-- tests/select_for_update/tests.py | 8 +-- tests/select_related/models.py | 6 +- tests/select_related/tests.py | 6 +- tests/select_related_onetoone/tests.py | 7 +- tests/select_related_regress/tests.py | 8 ++- tests/serializers/tests.py | 28 ++++---- tests/serializers_regress/models.py | 5 +- tests/serializers_regress/tests.py | 42 ++++++------ tests/servers/tests.py | 6 +- tests/servers/urls.py | 1 - tests/servers/views.py | 1 + tests/settings_tests/tests.py | 8 ++- tests/shortcuts/tests.py | 2 +- tests/shortcuts/views.py | 3 +- tests/signing/tests.py | 2 +- .../migrations/0001_initial.py | 2 +- tests/sites_framework/tests.py | 5 +- tests/staticfiles_tests/storage.py | 3 +- tests/staticfiles_tests/test_liveserver.py | 6 +- tests/staticfiles_tests/tests.py | 15 ++--- tests/string_lookup/tests.py | 3 +- tests/swappable_models/tests.py | 5 +- tests/syndication_tests/tests.py | 12 ++-- tests/syndication_tests/urls.py | 1 - tests/template_backends/test_django.py | 6 +- tests/template_backends/test_jinja2.py | 5 +- tests/template_loader/tests.py | 7 +- tests/template_tests/alternate_urls.py | 1 - .../filter_tests/test_autoescape.py | 2 +- .../template_tests/filter_tests/test_date.py | 2 +- .../template_tests/filter_tests/test_time.py | 2 +- .../filter_tests/test_timesince.py | 2 +- .../filter_tests/test_timeuntil.py | 2 +- .../syntax_tests/test_autoescape.py | 2 +- .../template_tests/syntax_tests/test_basic.py | 3 +- .../syntax_tests/test_exceptions.py | 2 +- .../syntax_tests/test_extends.py | 1 - .../syntax_tests/test_filter_syntax.py | 2 +- tests/template_tests/syntax_tests/test_if.py | 4 +- .../syntax_tests/test_include.py | 3 +- .../template_tests/syntax_tests/test_numpy.py | 2 +- tests/template_tests/syntax_tests/test_ssi.py | 6 +- .../syntax_tests/test_static.py | 2 +- tests/template_tests/syntax_tests/test_url.py | 2 +- tests/template_tests/templatetags/bad_tag.py | 1 - .../template_tests/templatetags/inclusion.py | 1 - tests/template_tests/test_context.py | 4 +- tests/template_tests/test_loaders.py | 20 +++--- tests/template_tests/test_parser.py | 4 +- tests/template_tests/test_response.py | 12 ++-- tests/template_tests/test_unicode.py | 4 +- tests/template_tests/tests.py | 13 ++-- tests/template_tests/urls.py | 2 +- tests/template_tests/utils.py | 3 +- tests/test_client/tests.py | 3 +- tests/test_client/urls.py | 1 - tests/test_client/views.py | 6 +- tests/test_client_regress/models.py | 2 +- tests/test_client_regress/tests.py | 18 ++--- tests/test_client_regress/urls.py | 2 +- tests/test_client_regress/views.py | 2 +- tests/test_runner/test_discover_runner.py | 2 +- tests/test_runner/tests.py | 7 +- tests/test_utils/tests.py | 6 +- tests/test_utils/urls.py | 1 - tests/timezones/tests.py | 38 ++++++----- tests/transactions/tests.py | 10 ++- tests/unmanaged_models/models.py | 1 + tests/unmanaged_models/tests.py | 2 +- tests/update/tests.py | 2 +- tests/update_only_fields/tests.py | 4 +- tests/urlpatterns_reverse/extra_urls.py | 3 +- .../included_named_urls.py | 3 +- .../included_named_urls2.py | 1 - .../included_namespace_urls.py | 3 +- .../included_no_kwargs_urls.py | 1 - tests/urlpatterns_reverse/included_urls.py | 1 - tests/urlpatterns_reverse/included_urls2.py | 1 - tests/urlpatterns_reverse/named_urls.py | 3 +- tests/urlpatterns_reverse/namespace_urls.py | 2 +- .../urlpatterns_reverse/reverse_lazy_urls.py | 2 +- tests/urlpatterns_reverse/tests.py | 20 +++--- tests/urlpatterns_reverse/urlconf_inner.py | 2 +- tests/urlpatterns_reverse/urlconf_outer.py | 3 +- tests/urlpatterns_reverse/urls.py | 3 +- .../urls_error_handlers_callables.py | 1 - .../urls_without_full_import.py | 3 +- tests/urlpatterns_reverse/views.py | 5 +- tests/user_commands/tests.py | 4 +- tests/utils_tests/test_archive.py | 3 +- tests/utils_tests/test_autoreload.py | 4 +- tests/utils_tests/test_baseconv.py | 4 +- tests/utils_tests/test_datastructures.py | 8 ++- tests/utils_tests/test_dateformat.py | 9 +-- tests/utils_tests/test_dateparse.py | 6 +- tests/utils_tests/test_datetime_safe.py | 5 +- tests/utils_tests/test_decorators.py | 2 +- tests/utils_tests/test_encoding.py | 6 +- tests/utils_tests/test_functional.py | 2 +- tests/utils_tests/test_html.py | 2 +- tests/utils_tests/test_http.py | 5 +- tests/utils_tests/test_ipv6.py | 2 +- .../test_module/another_bad_module.py | 1 + .../test_module/another_good_module.py | 1 + tests/utils_tests/test_module_loading.py | 9 +-- tests/utils_tests/test_safestring.py | 12 ++-- tests/utils_tests/test_termcolors.py | 6 +- tests/utils_tests/test_timesince.py | 2 +- tests/utils_tests/test_timezone.py | 6 +- tests/utils_tests/test_tzinfo.py | 1 - tests/validation/test_unique.py | 7 +- tests/validation/tests.py | 6 +- tests/validators/tests.py | 5 +- tests/view_tests/default_urls.py | 1 - tests/view_tests/generic_urls.py | 2 +- tests/view_tests/templatetags/debugtags.py | 1 - tests/view_tests/tests/test_csrf.py | 2 +- tests/view_tests/tests/test_debug.py | 13 ++-- tests/view_tests/tests/test_i18n.py | 7 +- tests/view_tests/tests/test_static.py | 2 +- tests/view_tests/urls.py | 3 +- tests/view_tests/views.py | 16 +++-- tests/wsgi/urls.py | 2 +- 819 files changed, 2631 insertions(+), 2401 deletions(-) diff --git a/django/apps/config.py b/django/apps/config.py index fd0e2fe78c4..76b3014d9d0 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 efef0c9174e..0cda55d8fa1 100644 --- a/django/apps/registry.py +++ b/django/apps/registry.py @@ -1,13 +1,13 @@ -from collections import Counter, defaultdict, OrderedDict import os 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 -from django.utils.deprecation import RemovedInDjango19Warning from django.utils._os import upath +from django.utils.deprecation import RemovedInDjango19Warning from .config import AppConfig diff --git a/django/conf/project_template/project_name/settings.py b/django/conf/project_template/project_name/settings.py index a0a30560753..b3c629ec6ee 100644 --- a/django/conf/project_template/project_name/settings.py +++ b/django/conf/project_template/project_name/settings.py @@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os + 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 94d60c8cf9f..0d68b956459 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 2dafd3ea3a2..3478145b30b 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 b052746ff4e..c965cdbc893 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 f90793daec2..d8f7fe57e43 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 0c0eb339ce9..863da768181 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 ede6f257ad2..2e482b9c15d 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 bd41063e43a..07ea9a48139 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 b9872dcc443..088d36becd6 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 9ecb367e058..4e1d2aed04f 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 39c27c1b256..7ea550ddd14 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -1,37 +1,42 @@ -from collections import OrderedDict import copy import operator -from functools import partial, reduce, update_wrapper import warnings +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 import validation -from django.contrib.admin.checks import (BaseModelAdminChecks, ModelAdminChecks, - InlineModelAdminChecks) +from django.contrib.admin import helpers, validation, 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 import checks -from django.core.exceptions import (PermissionDenied, ValidationError, - FieldDoesNotExist, FieldError, ImproperlyConfigured) +from django.core.exceptions import ( + FieldDoesNotExist, FieldError, ImproperlyConfigured, 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 @@ -42,14 +47,11 @@ from django.utils.deprecation import RemovedInDjango19Warning 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 bcd05ed800c..af408806ae2 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 6f7c530aa72..55fba4f90ce 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/util.py b/django/contrib/admin/util.py index 416b75e7b2c..94f0dd2f4dc 100644 --- a/django/contrib/admin/util.py +++ b/django/contrib/admin/util.py @@ -6,4 +6,4 @@ warnings.warn( "The django.contrib.admin.util module has been renamed. " "Use django.contrib.admin.utils instead.", RemovedInDjango19Warning) -from django.contrib.admin.utils import * # NOQA +from django.contrib.admin.utils import * # NOQA isort:skip diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py index 95cbe634b2e..f704ef3af73 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/validation.py b/django/contrib/admin/validation.py index 67b97f776ed..fab31663e95 100644 --- a/django/contrib/admin/validation.py +++ b/django/contrib/admin/validation.py @@ -1,7 +1,9 @@ +from django.contrib.admin.utils import NotRelationField, get_fields_from_path from django.core.exceptions import FieldDoesNotExist, ImproperlyConfigured from django.db import models -from django.forms.models import BaseModelForm, BaseModelFormSet, _get_foreign_key -from django.contrib.admin.utils import get_fields_from_path, NotRelationField +from django.forms.models import ( + BaseModelForm, BaseModelFormSet, _get_foreign_key, +) """ Does basic ModelAdmin option validation. Calls custom validation diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index 07457a87fc5..fa91ceae3ad 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 django.core.exceptions import FieldDoesNotExist, SuspiciousOperation, ImproperlyConfigured -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 collections import OrderedDict 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.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.http import urlencode +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 10ac364f742..19b4187b524 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 7994f618cd4..28ddbfb92a6 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 330b76423b6..2e4cede0b90 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 779a8a446b7..f366025f891 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 4ce64c3a530..91ca143508a 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.core.exceptions import ImproperlyConfigured, ViewDoesNotExist -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.core import urlresolvers +from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist +from django.db import models +from django.http import Http404 +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 2df33c3c86d..928236914ac 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 bbfcb7dbd1e..109a34dff63 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 00a772fd4f8..9f082590389 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 99e2983e630..9b2504b33cb 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 3d19b2247e2..cc3be5ba0be 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 8ada9750f19..6b91ed9c6ea 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 9a85ebbbade..f7f143b78f6 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 33c8e001530..a58f73ab1ae 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 -from django.core import validators -from django.db import models, migrations -from django.utils import timezone import django.contrib.auth.models +from django.core import validators +from django.db import migrations, models +from django.utils import timezone 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 8e82223237a..8b58e7814b1 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 a9b8058089b..0a082f2656a 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 80a156e0019..0f7bfdf3a7e 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 128a4e49628..b8b9289787a 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 89b3054b70a..4dc49c2d0c1 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -1,21 +1,20 @@ from __future__ import unicode_literals -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.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) + 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.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.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 1f31f7a16af..ae14d1538c7 100644 --- a/django/contrib/auth/tests/backend_alias.py +++ b/django/contrib/auth/tests/backend_alias.py @@ -1,2 +1,4 @@ # For testing that auth backends can be referenced using a convenience import -from django.contrib.auth.tests.test_auth_backends import ImportedModelBackend # NOQA +from .test_auth_backends import ImportedModelBackend + +__all__ = ['ImportedModelBackend'] diff --git a/django/contrib/auth/tests/custom_user.py b/django/contrib/auth/tests/custom_user.py index c856431bba4..e7ce6162e93 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 ce2aa7d1521..6fd02261de6 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 d3b6c5de0c0..8ccb6287e8f 100644 --- a/django/contrib/auth/tests/test_auth_backends.py +++ b/django/contrib/auth/tests/test_auth_backends.py @@ -1,17 +1,20 @@ from __future__ import unicode_literals + from datetime import date from django.conf import settings +from django.contrib.auth import BACKEND_SESSION_KEY, authenticate, get_user from django.contrib.auth.backends import ModelBackend -from django.contrib.auth.models import User, Group, Permission, AnonymousUser +from django.contrib.auth.hashers import MD5PasswordHasher +from django.contrib.auth.models import AnonymousUser, Group, Permission, User +from django.contrib.auth.tests.custom_user import ( + CustomPermissionsUser, CustomUser, ExtensionUser, +) from django.contrib.auth.tests.utils import skipIfCustomUser -from django.contrib.auth.tests.custom_user import ExtensionUser, CustomPermissionsUser, CustomUser from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ImproperlyConfigured, PermissionDenied -from django.contrib.auth import authenticate, BACKEND_SESSION_KEY, get_user from django.http import HttpRequest from django.test import TestCase, override_settings -from django.contrib.auth.hashers import MD5PasswordHasher class CountingMD5PasswordHasher(MD5PasswordHasher): diff --git a/django/contrib/auth/tests/test_basic.py b/django/contrib/auth/tests/test_basic.py index fed94db82fe..ca7db755e6f 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 f96eac9db74..bb3c1820f65 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 93ce9ad0732..4628840400e 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 f4fa3030de9..a6a4f9cd068 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 0c280ae158f..de5d9233b3d 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 3d2aaceee98..6a395bbe7b4 100644 --- a/django/contrib/auth/tests/test_management.py +++ b/django/contrib/auth/tests/test_management.py @@ -1,20 +1,23 @@ from __future__ import unicode_literals -from datetime import date import locale import sys +from datetime import date from django.apps import apps -from django.contrib.auth import models, management +from django.contrib.auth import management, models from django.contrib.auth.checks import check_user_model from django.contrib.auth.management import create_permissions -from django.contrib.auth.management.commands import changepassword, createsuperuser -from django.contrib.auth.models import User, Group -from django.contrib.auth.tests.custom_user import CustomUser, CustomUserWithFK, Email +from django.contrib.auth.management.commands import ( + changepassword, createsuperuser, +) +from django.contrib.auth.models import Group, User +from django.contrib.auth.tests.custom_user import ( + CustomUser, CustomUserWithFK, Email, +) from django.contrib.auth.tests.utils import skipIfCustomUser from django.contrib.contenttypes.models import ContentType -from django.core import checks -from django.core import exceptions +from django.core import checks, exceptions from django.core.management import call_command from django.core.management.base import CommandError from django.test import TestCase, override_settings, override_system_checks diff --git a/django/contrib/auth/tests/test_models.py b/django/contrib/auth/tests/test_models.py index b0a35a445a9..ee51b15a984 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 04c5b89e0bb..0f099c53be4 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 e2bb466d682..607db8764e2 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 583546ab3aa..b9433bdcfab 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 e5538517d00..76a97b56236 100644 --- a/django/contrib/auth/tests/test_views.py +++ b/django/contrib/auth/tests/test_views.py @@ -1,31 +1,32 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from importlib import import_module import itertools import re +from importlib import import_module from django.apps import apps from django.conf import settings -from django.contrib.sites.requests import RequestSite from django.contrib.admin.models import LogEntry -from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME -from django.contrib.auth.forms import (AuthenticationForm, PasswordChangeForm, - SetPasswordForm) +from django.contrib.auth import REDIRECT_FIELD_NAME, SESSION_KEY +from django.contrib.auth.forms import ( + AuthenticationForm, PasswordChangeForm, SetPasswordForm, +) from django.contrib.auth.models import User from django.contrib.auth.views import login as login_view, redirect_to_login +from django.contrib.sessions.middleware import SessionMiddleware +from django.contrib.sites.requests import RequestSite from django.core import mail from django.core.urlresolvers import NoReverseMatch, reverse, reverse_lazy -from django.http import QueryDict, HttpRequest +from django.http import HttpRequest, QueryDict +from django.middleware.csrf import CsrfViewMiddleware +from django.test import TestCase, ignore_warnings, override_settings +from django.test.utils import patch_logger from django.utils.deprecation import RemovedInDjango20Warning from django.utils.encoding import force_text from django.utils.http import urlquote -from django.utils.six.moves.urllib.parse import urlparse, ParseResult +from django.utils.six.moves.urllib.parse import ParseResult, urlparse from django.utils.translation import LANGUAGE_SESSION_KEY -from django.test import TestCase, ignore_warnings, override_settings -from django.test.utils import patch_logger -from django.middleware.csrf import CsrfViewMiddleware -from django.contrib.sessions.middleware import SessionMiddleware # Needed so model is installed when tests are run independently: from .custom_user import CustomUser # NOQA diff --git a/django/contrib/auth/tests/urls.py b/django/contrib/auth/tests/urls.py index 41e742a93b0..6f83e0f4207 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 49d6f38447a..8d2fe3fd106 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 89100daeb2f..b925c21effa 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 348fca87456..de76157bdc6 100644 --- a/django/contrib/auth/views.py +++ b/django/contrib/auth/views.py @@ -1,25 +1,28 @@ import warnings from django.conf import settings +# Avoid shadowing the login() and logout() views below. +from django.contrib.auth import ( + REDIRECT_FIELD_NAME, get_user_model, login as auth_login, + logout as auth_logout, update_session_auth_hash, +) +from django.contrib.auth.decorators import login_required +from django.contrib.auth.forms import ( + AuthenticationForm, PasswordChangeForm, PasswordResetForm, SetPasswordForm, +) +from django.contrib.auth.tokens import default_token_generator +from django.contrib.sites.shortcuts import get_current_site from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, QueryDict +from django.shortcuts import resolve_url from django.template.response import TemplateResponse from django.utils.deprecation import RemovedInDjango20Warning from django.utils.http import is_safe_url, urlsafe_base64_decode -from django.utils.translation import ugettext as _ from django.utils.six.moves.urllib.parse import urlparse, urlunparse -from django.shortcuts import resolve_url -from django.views.decorators.debug import sensitive_post_parameters +from django.utils.translation import ugettext as _ from django.views.decorators.cache import never_cache from django.views.decorators.csrf import csrf_protect - -# Avoid shadowing the login() and logout() views below. -from django.contrib.auth import (REDIRECT_FIELD_NAME, login as auth_login, - logout as auth_logout, get_user_model, update_session_auth_hash) -from django.contrib.auth.decorators import login_required -from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm, SetPasswordForm, PasswordChangeForm -from django.contrib.auth.tokens import default_token_generator -from django.contrib.sites.shortcuts import get_current_site +from django.views.decorators.debug import sensitive_post_parameters @sensitive_post_parameters() diff --git a/django/contrib/contenttypes/admin.py b/django/contrib/contenttypes/admin.py index 3db9d2d612c..85bf3227e3f 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 890859505a0..1b3df21353d 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 fba8e0c222a..7bd9b79415d 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 693628d3deb..e590c3db05f 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/generic.py b/django/contrib/contenttypes/generic.py index 19622d33d8b..92df783d020 100644 --- a/django/contrib/contenttypes/generic.py +++ b/django/contrib/contenttypes/generic.py @@ -10,12 +10,12 @@ warnings.warn( 'submodules of django.contrib.contenttypes.'), RemovedInDjango19Warning, stacklevel=2 ) -from django.contrib.contenttypes.admin import ( # NOQA - GenericInlineModelAdmin, GenericStackedInline, GenericTabularInline +from django.contrib.contenttypes.admin import ( # NOQA isort:skip + GenericInlineModelAdmin, GenericStackedInline, GenericTabularInline, ) -from django.contrib.contenttypes.fields import ( # NOQA - GenericForeignKey, GenericRelation +from django.contrib.contenttypes.fields import ( # NOQA isort:skip + GenericForeignKey, GenericRelation, ) -from django.contrib.contenttypes.forms import ( # NOQA - BaseGenericInlineFormSet, generic_inlineformset_factory +from django.contrib.contenttypes.forms import ( # NOQA isort:skip + BaseGenericInlineFormSet, generic_inlineformset_factory, ) diff --git a/django/contrib/contenttypes/migrations/0001_initial.py b/django/contrib/contenttypes/migrations/0001_initial.py index 09519f1d75a..68190b2a2b3 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 1b91437dbc5..b2e18846b9a 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 684380c8324..5205ec80f9d 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 5ce9b395f19..8e4dae3b37d 100644 --- a/django/contrib/contenttypes/tests/tests.py +++ b/django/contrib/contenttypes/tests/tests.py @@ -9,7 +9,10 @@ from django.http import Http404, HttpRequest from django.test import TestCase, override_settings 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 5711a9466e0..06ed824c45d 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 c35bebf721a..ac966c81f5b 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 9fe595d0cf9..32d881ffa4a 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 5f583a1051c..fe0a3f33740 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 1bddb0b8d22..eac4edd122e 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 d7ced97d179..db82c4aa2c1 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 b10ebe564c5..ad888f9d95e 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 7b35f621fda..e661b12c7a8 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 f091f3e0eaa..c48dc38637f 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 f771adbafbe..21d90da32eb 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 8ca0d92c295..f9412336e35 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 c85e7a61259..52b624a112e 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 6ca51e9b422..919272b064c 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 62702d1ffe4..9fb339ee26d 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 .creation import MySQLCreation from .features import DatabaseFeatures diff --git a/django/contrib/gis/db/backends/mysql/features.py b/django/contrib/gis/db/backends/mysql/features.py index 02c611b2923..a547ec967a5 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 9d0d2a99280..130c103ac27 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 4d708686bae..e60f3d2fcc0 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 e26603e531f..60961af817f 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 9d7ab7debda..cfc88ea3e1a 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 .creation import OracleCreation from .features import DatabaseFeatures diff --git a/django/contrib/gis/db/backends/oracle/features.py b/django/contrib/gis/db/backends/oracle/features.py index ef56ec627dd..df0aedcf325 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 53a449bb5a1..764ce7d2431 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 277126a77ee..9d405056322 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 083f76d0a8c..8d17b16c122 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 dfa225c6e7a..1cc15bde38d 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 631844a0302..5e08b2f9ce1 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 a438ffcc20a..83b254cb39f 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 2255897f2f2..e0af0c1ecb2 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 70ad9000467..c1184f4685f 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 4ab382e00bb..613087b51ec 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 b81a2e4089d..c1ed7629b9b 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 a1f0f2d44b6..d1b58b75826 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 c4700e7aef6..73adb02b052 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 e067bfc03b1..bdf2b937402 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/backends/util.py b/django/contrib/gis/db/backends/util.py index 08f1ca8d808..64568eb5cb9 100644 --- a/django/contrib/gis/db/backends/util.py +++ b/django/contrib/gis/db/backends/util.py @@ -7,4 +7,4 @@ warnings.warn( "Use django.contrib.gis.db.backends.utils instead.", RemovedInDjango19Warning, stacklevel=2) -from django.contrib.gis.db.backends.utils import * # NOQA +from django.contrib.gis.db.backends.utils import * # NOQA isort:skip diff --git a/django/contrib/gis/db/models/aggregates.py b/django/contrib/gis/db/models/aggregates.py index 42198d9287c..60954951e67 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 acfb0915dd9..df26b8b9f8b 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 eb64eff6c7e..b739e468cef 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 609bdf36379..22d009a972e 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 6e231a8607a..f287c778da5 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 fe0e396f2f3..b83bafda707 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 af481b8be75..ea64a716c3c 100644 --- a/django/contrib/gis/forms/fields.py +++ b/django/contrib/gis/forms/fields.py @@ -1,11 +1,11 @@ from __future__ import unicode_literals from django import forms -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 django.utils.translation import ugettext_lazy as _ + from .widgets import OpenLayersWidget diff --git a/django/contrib/gis/forms/widgets.py b/django/contrib/gis/forms/widgets.py index 26cc0565b0f..37c9be8fbc5 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 7fa9d83e128..f5349f4480d 100644 --- a/django/contrib/gis/gdal/datasource.py +++ b/django/contrib/gis/gdal/datasource.py @@ -41,12 +41,10 @@ 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 7628e360b9e..51d0c9fe33d 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 59d48b7bff1..ae9ba434e7c 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 b1a0b19fd0c..7e9d5a6986f 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 fb77480fa10..8da4256bf47 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 b984eea4eee..8c092145bec 100644 --- a/django/contrib/gis/gdal/geometries.py +++ b/django/contrib/gis/gdal/geometries.py @@ -38,27 +38,23 @@ >>> 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 # diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py index 9a06bad7899..abb184e2f93 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 b5c73077676..82b0d8dd5d8 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 fd9a9946a01..f2f62b727d3 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 1b24df4bf39..c24e4b79a2e 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 2940079b03c..a7210876545 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 79b7b47825e..39bf621796d 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 15f4d5b8938..2bcc5a021cc 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 781c4ded89d..08ec9df9615 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 424853704d8..96b5130a2c1 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 e89e70d2e89..bb72db49ee1 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 9450277275f..e946222fe7c 100644 --- a/django/contrib/gis/gdal/srs.py +++ b/django/contrib/gis/gdal/srs.py @@ -32,7 +32,6 @@ from ctypes import byref, c_char_p, c_int 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 diff --git a/django/contrib/gis/gdal/tests/test_ds.py b/django/contrib/gis/gdal/tests/test_ds.py index 04b1c0f982a..ef62c160cc0 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 d0651fcaf2c..33b70b4df37 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 de0bfd18a7d..0b160ffea35 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 cc4d92c7d02..a6023ff2293 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 751b4c4b051..257e0ffacd0 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 06558e00939..8d1309a671e 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 b4d48dbc98e..02ca3dd29e9 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 d6a8bf8263b..58d82dbdcc4 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 82a2169ab01..0b787f9d53f 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 d11c6fbde39..de3583e4998 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 87ee660020d..eb06da2c00d 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 dd110c02363..a0e0ecabbd6 100644 --- a/django/contrib/gis/geos/geometry.py +++ b/django/contrib/gis/geos/geometry.py @@ -7,29 +7,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 - +from django.contrib.gis.geos.mutable_list import ListMixin # 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.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 @@ -681,13 +671,15 @@ class GEOSGeometry(GEOSBase, ListMixin): "Clones this Geometry." return GEOSGeometry(capi.geom_clone(self.ptr), srid=self.srid) + # 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 f12be89830e..daf67dd28c2 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 f218b17f6f7..66c61f3a822 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 ec06cb19e80..7b2cc540bab 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 cea37106224..6b60465431b 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 dadab29bbf1..e53a4569bfe 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 89dd0f06f6b..fdf7515bed9 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 django.contrib.gis.geos.geometry import GEOSGeometry -from django.contrib.gis.geos.libgeos import get_pointer_arr, GEOM_PTR -from django.contrib.gis.geos.linestring import LinearRing +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 GEOM_PTR, get_pointer_arr +from django.contrib.gis.geos.linestring import LinearRing 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 d5aa3da318c..1cdc4ccdcc5 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 0a624ccec7f..b97440ab010 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 5416625c678..da2452c169a 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 8083d93ee07..168d472311e 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 b256fd3d0bb..0a8b3886185 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 0bd1fabf9fa..6ef979422c4 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 ced56395b0c..2c93e1eb2f9 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 61b13792bc7..45c87d60045 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 06daa12cca6..5729256d9df 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 794ed6d75e7..7c9c1e829ea 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 06ca76e33d6..08ff6c13e88 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 502f816ea40..229be74276a 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 845b39a806e..d40c3b8218e 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 d9ba31380a2..f249e5d809f 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 a34748bb8e3..d169fbd59b5 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 90b316bb603..527512f71bf 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 573f85c045e..eb0533bdeda 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 d052cf63506..4dcaa8f5950 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 d12ed53298e..ae882da29c9 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 5f898e3ddab..4c2ea609503 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 9530cd9b550..022a8063ab5 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 381a752570c..cf8470e792c 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 16f1f0146e8..1a3101290ae 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 1b89823ecba..19a6f69b008 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 4ef2bb97023..6a2d1f40b83 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 830fe72e623..23a74372316 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 238c64ad51c..40a48053c72 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.*)/$', 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 212f7023209..aceaaa301e0 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 bb0186fad53..076215465dd 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 8052e7ab1df..9bfe55b0bf3 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 82b2cfefd6a..8e2f54c5178 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 45709e30ce1..85f105f4a0b 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 fa72cd1facc..bcbb5f08045 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 f6b89ce1ca7..771c10fe9df 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 7f43124e5d0..1a4b151f2b4 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 410024e324a..c9badc75220 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 16732556d41..1bc2caab4bc 100644 --- a/django/contrib/gis/utils/ogrinspect.py +++ b/django/contrib/gis/utils/ogrinspect.py @@ -3,11 +3,13 @@ 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 1460be2de90..59ba77c6dda 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 67b3012175e..c518ee12df8 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 81c6d2a04c2..bb9bc7b1cac 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 a9882e479fd..84528fd29db 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 +from django.contrib.humanize.templatetags import humanize +from django.template import Context, Template, defaultfilters +from django.test import TestCase, override_settings +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 -from django.contrib.humanize.templatetags import humanize -from django.template import Template, Context, 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.translation import ugettext as _ - # 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 1a9189383ef..de48c8aa4d6 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 43dd3dbdd2c..74f1ce7d9c5 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 71eee0cdfa8..eb927411a73 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 c3e293c22e9..7903fb03c19 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 139d32c0677..d1f951789f5 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 335a2004504..f79db958660 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 ba7b4dc08b0..c986a174cae 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 cd0b1888f38..0afbe75ae66 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 35bb86d057d..bb0bb797d48 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 940e1c02d03..cca659d3d8d 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 43cc6063cb4..d7486900447 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 %}