From 0ed7d155635da9f79d4dd67e4889087d3673c6da Mon Sep 17 00:00:00 2001 From: Tim Graham Date: Wed, 28 Jan 2015 07:35:27 -0500 Subject: [PATCH] Sorted imports with isort; refs #23860. --- django/apps/config.py | 5 +- django/apps/registry.py | 2 +- .../project_template/project_name/settings.py | 3 +- .../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 | 40 ++++++------ django/contrib/admin/sites.py | 15 +++-- .../contrib/admin/templatetags/admin_list.py | 19 +++--- django/contrib/admin/utils.py | 2 +- 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 | 21 +++--- 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 | 27 ++++---- 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 | 24 ++++--- django/contrib/contenttypes/admin.py | 2 +- django/contrib/contenttypes/checks.py | 2 +- django/contrib/contenttypes/fields.py | 9 ++- django/contrib/contenttypes/forms.py | 2 +- .../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 | 7 +- 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/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 | 7 +- 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 | 20 ++---- 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 | 3 - 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 | 36 ++++------- 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 | 7 +- 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 | 2 +- django/contrib/sessions/backends/db.py | 6 +- 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 | 2 +- django/contrib/sessions/serializers.py | 1 + django/contrib/sessions/tests.py | 24 +++---- django/contrib/sitemaps/apps.py | 1 - .../management/commands/ping_google.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 | 6 +- 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 | 4 +- 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 | 2 +- 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 | 5 +- django/core/management/color.py | 3 +- .../management/commands/createcachetable.py | 4 +- django/core/management/commands/dbshell.py | 2 +- django/core/management/commands/dumpdata.py | 4 +- django/core/management/commands/flush.py | 6 +- django/core/management/commands/inspectdb.py | 4 +- django/core/management/commands/loaddata.py | 10 +-- .../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/sqlflush.py | 2 +- django/core/management/commands/sqlmigrate.py | 2 +- .../management/commands/sqlsequencereset.py | 2 +- .../management/commands/squashmigrations.py | 10 +-- 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/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 | 18 +++--- 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/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 | 11 ++-- 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/base.py | 25 +++++--- 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/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 | 25 ++++---- django/db/models/sql/subqueries.py | 1 - django/db/models/sql/where.py | 1 - django/db/transaction.py | 4 +- django/db/utils.py | 7 +- django/dispatch/weakref_backports.py | 1 - django/forms/fields.py | 22 ++++--- django/forms/forms.py | 15 +++-- django/forms/formsets.py | 7 +- django/forms/models.py | 19 +++--- django/forms/utils.py | 18 ++---- 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 | 35 +++++----- 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 | 3 +- 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 | 25 ++++---- django/test/utils.py | 10 +-- django/utils/_os.py | 4 +- django/utils/autoreload.py | 3 +- django/utils/cache.py | 2 +- django/utils/crypto.py | 18 +++--- 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/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/ipv6.py | 2 +- django/utils/jslex.py | 1 + django/utils/module_loading.py | 5 +- django/utils/numberformat.py | 2 +- django/utils/safestring.py | 2 +- django/utils/text.py | 8 +-- django/utils/timezone.py | 12 ++-- django/utils/translation/trans_real.py | 16 +++-- 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.cfg | 7 ++ 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 | 21 +++--- 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 | 18 +++--- tests/admin_scripts/urls.py | 1 + tests/admin_utils/tests.py | 16 +++-- tests/admin_views/admin.py | 51 ++++++++------- .../custom_has_permission_admin.py | 2 +- tests/admin_views/customadmin.py | 6 +- tests/admin_views/models.py | 4 +- tests/admin_views/tests.py | 64 +++++++++---------- tests/admin_views/urls.py | 3 +- tests/admin_widgets/models.py | 2 +- tests/admin_widgets/tests.py | 19 +++--- 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/app_loading/tests.py | 2 +- 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 | 35 +++++----- .../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/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 | 22 +++++-- 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/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_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 | 4 +- tests/forms_tests/tests/test_fields.py | 24 ++++--- tests/forms_tests/tests/test_forms.py | 10 +-- 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 | 2 +- tests/forms_tests/tests/test_utils.py | 6 +- tests/forms_tests/tests/test_widgets.py | 4 +- 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 | 3 +- 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 | 4 +- 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/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 +- .../0001_initial.py | 2 +- .../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 | 12 ++-- 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 | 36 ++++++----- 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 | 40 ++++++------ 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 | 11 ++-- tests/syndication_tests/urls.py | 1 - tests/template_backends/test_django.py | 6 +- tests/template_backends/test_jinja2.py | 4 +- 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 | 2 +- .../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 | 21 +++--- 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 | 16 ++--- tests/test_client_regress/urls.py | 3 +- 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 | 39 ++++++----- 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 | 6 +- 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 | 7 +- 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 | 7 +- 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 +- 793 files changed, 2551 insertions(+), 2333 deletions(-) diff --git a/django/apps/config.py b/django/apps/config.py index fd0e2fe78c..76b3014d9d 100644 --- a/django/apps/config.py +++ b/django/apps/config.py @@ -1,10 +1,9 @@ -from importlib import import_module import os +from importlib import import_module from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured -from django.utils.module_loading import module_has_submodule from django.utils._os import upath - +from django.utils.module_loading import module_has_submodule MODELS_MODULE_NAME = 'models' diff --git a/django/apps/registry.py b/django/apps/registry.py index 9ddd56462a..c64106cd6f 100644 --- a/django/apps/registry.py +++ b/django/apps/registry.py @@ -1,7 +1,7 @@ -from collections import Counter, defaultdict, OrderedDict import sys import threading import warnings +from collections import Counter, OrderedDict, defaultdict from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured from django.utils import lru_cache diff --git a/django/conf/project_template/project_name/settings.py b/django/conf/project_template/project_name/settings.py index 9d4b38d171..c0db27cbdc 100644 --- a/django/conf/project_template/project_name/settings.py +++ b/django/conf/project_template/project_name/settings.py @@ -10,8 +10,9 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/ """ -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) diff --git a/django/conf/project_template/project_name/wsgi.py b/django/conf/project_template/project_name/wsgi.py index 94d60c8cf9..0d68b95645 100644 --- a/django/conf/project_template/project_name/wsgi.py +++ b/django/conf/project_template/project_name/wsgi.py @@ -8,7 +8,9 @@ https://docs.djangoproject.com/en/{{ docs_version }}/howto/deployment/wsgi/ """ import os -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings") from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings") + application = get_wsgi_application() diff --git a/django/contrib/admin/actions.py b/django/contrib/admin/actions.py index 2dafd3ea3a..3478145b30 100644 --- a/django/contrib/admin/actions.py +++ b/django/contrib/admin/actions.py @@ -2,14 +2,14 @@ Built-in, globally-available admin actions. """ -from django.core.exceptions import PermissionDenied from django.contrib import messages from django.contrib.admin import helpers from django.contrib.admin.utils import get_deleted_objects, model_ngettext +from django.core.exceptions import PermissionDenied from django.db import router from django.template.response import TemplateResponse from django.utils.encoding import force_text -from django.utils.translation import ugettext_lazy, ugettext as _ +from django.utils.translation import ugettext as _, ugettext_lazy def delete_selected(modeladmin, request, queryset): diff --git a/django/contrib/admin/apps.py b/django/contrib/admin/apps.py index b052746ff4..c965cdbc89 100644 --- a/django/contrib/admin/apps.py +++ b/django/contrib/admin/apps.py @@ -1,6 +1,6 @@ from django.apps import AppConfig -from django.core import checks from django.contrib.admin.checks import check_admin_app +from django.core import checks from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py index f90793daec..d8f7fe57e4 100644 --- a/django/contrib/admin/checks.py +++ b/django/contrib/admin/checks.py @@ -3,11 +3,15 @@ from __future__ import unicode_literals from itertools import chain -from django.contrib.admin.utils import get_fields_from_path, NotRelationField, flatten +from django.contrib.admin.utils import ( + NotRelationField, flatten, get_fields_from_path, +) from django.core import checks from django.core.exceptions import FieldDoesNotExist from django.db import models -from django.forms.models import BaseModelForm, _get_foreign_key, BaseModelFormSet +from django.forms.models import ( + BaseModelForm, BaseModelFormSet, _get_foreign_key, +) def check_admin_app(**kwargs): diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py index 0c0eb339ce..863da76818 100644 --- a/django/contrib/admin/filters.py +++ b/django/contrib/admin/filters.py @@ -7,15 +7,17 @@ certain test -- e.g. being a DateField or ForeignKey. """ import datetime +from django.contrib.admin.options import IncorrectLookupParameters +from django.contrib.admin.utils import ( + get_limit_choices_to_from_path, get_model_from_relation, + prepare_lookup_value, reverse_field_path, +) +from django.core.exceptions import ImproperlyConfigured, ValidationError from django.db import models from django.db.models.fields.related import ForeignObjectRel, ManyToManyField -from django.core.exceptions import ImproperlyConfigured, ValidationError -from django.utils.encoding import smart_text, force_text -from django.utils.translation import ugettext_lazy as _ from django.utils import timezone -from django.contrib.admin.utils import (get_model_from_relation, - reverse_field_path, get_limit_choices_to_from_path, prepare_lookup_value) -from django.contrib.admin.options import IncorrectLookupParameters +from django.utils.encoding import force_text, smart_text +from django.utils.translation import ugettext_lazy as _ class ListFilter(object): diff --git a/django/contrib/admin/forms.py b/django/contrib/admin/forms.py index ede6f257ad..2e482b9c15 100644 --- a/django/contrib/admin/forms.py +++ b/django/contrib/admin/forms.py @@ -1,7 +1,6 @@ from __future__ import unicode_literals from django import forms - from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py index bd41063e43..07ea9a4813 100644 --- a/django/contrib/admin/helpers.py +++ b/django/contrib/admin/helpers.py @@ -3,22 +3,23 @@ from __future__ import unicode_literals import warnings from django import forms -from django.contrib.admin.utils import (flatten_fieldsets, lookup_field, - display_for_field, label_for_field, help_text_for_field) +from django.conf import settings from django.contrib.admin.templatetags.admin_static import static +from django.contrib.admin.utils import ( + display_for_field, flatten_fieldsets, help_text_for_field, label_for_field, + lookup_field, +) from django.core.exceptions import ObjectDoesNotExist from django.db.models.fields.related import ManyToManyRel from django.forms.utils import flatatt from django.template.defaultfilters import capfirst, linebreaksbr +from django.utils import six from django.utils.deprecation import RemovedInDjango20Warning from django.utils.encoding import force_text, smart_text from django.utils.functional import cached_property from django.utils.html import conditional_escape, format_html from django.utils.safestring import mark_safe -from django.utils import six from django.utils.translation import ugettext_lazy as _ -from django.conf import settings - ACTION_CHECKBOX_NAME = '_selected_action' diff --git a/django/contrib/admin/migrations/0001_initial.py b/django/contrib/admin/migrations/0001_initial.py index b9872dcc44..088d36becd 100644 --- a/django/contrib/admin/migrations/0001_initial.py +++ b/django/contrib/admin/migrations/0001_initial.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations -from django.conf import settings import django.contrib.admin.models +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/admin/models.py b/django/contrib/admin/models.py index 9ecb367e05..4e1d2aed04 100644 --- a/django/contrib/admin/models.py +++ b/django/contrib/admin/models.py @@ -1,13 +1,12 @@ from __future__ import unicode_literals -from django.db import models from django.conf import settings -from django.contrib.contenttypes.models import ContentType from django.contrib.admin.utils import quote -from django.core.urlresolvers import reverse, NoReverseMatch +from django.contrib.contenttypes.models import ContentType +from django.core.urlresolvers import NoReverseMatch, reverse +from django.db import models +from django.utils.encoding import python_2_unicode_compatible, smart_text from django.utils.translation import ugettext, ugettext_lazy as _ -from django.utils.encoding import smart_text -from django.utils.encoding import python_2_unicode_compatible ADDITION = 1 CHANGE = 2 diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 1419e86589..f0fd4c1a90 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -1,34 +1,39 @@ -from collections import OrderedDict import copy import operator +from collections import OrderedDict from functools import partial, reduce, update_wrapper from django import forms from django.conf import settings from django.contrib import messages -from django.contrib.admin import widgets, helpers -from django.contrib.admin.checks import (BaseModelAdminChecks, ModelAdminChecks, - InlineModelAdminChecks) +from django.contrib.admin import helpers, widgets +from django.contrib.admin.checks import ( + BaseModelAdminChecks, InlineModelAdminChecks, ModelAdminChecks, +) from django.contrib.admin.exceptions import DisallowedModelAdminToField -from django.contrib.admin.utils import (quote, unquote, flatten_fieldsets, - get_deleted_objects, model_format_dict, NestedObjects, - lookup_needs_distinct) from django.contrib.admin.templatetags.admin_static import static from django.contrib.admin.templatetags.admin_urls import add_preserved_filters +from django.contrib.admin.utils import ( + NestedObjects, flatten_fieldsets, get_deleted_objects, + lookup_needs_distinct, model_format_dict, quote, unquote, +) from django.contrib.auth import get_permission_codename -from django.core.exceptions import (PermissionDenied, ValidationError, - FieldDoesNotExist, FieldError) +from django.core.exceptions import ( + FieldDoesNotExist, FieldError, PermissionDenied, ValidationError, +) from django.core.paginator import Paginator from django.core.urlresolvers import reverse -from django.db import models, transaction, router +from django.db import models, router, transaction from django.db.models.constants import LOOKUP_SEP from django.db.models.fields import BLANK_CHOICE_DASH from django.db.models.fields.related import ForeignObjectRel from django.db.models.sql.constants import QUERY_TERMS -from django.forms.formsets import all_valid, DELETION_FIELD_NAME -from django.forms.models import (modelform_factory, modelformset_factory, - inlineformset_factory, BaseInlineFormSet, modelform_defines_fields) -from django.forms.widgets import SelectMultiple, CheckboxSelectMultiple +from django.forms.formsets import DELETION_FIELD_NAME, all_valid +from django.forms.models import ( + BaseInlineFormSet, inlineformset_factory, modelform_defines_fields, + modelform_factory, modelformset_factory, +) +from django.forms.widgets import CheckboxSelectMultiple, SelectMultiple from django.http import Http404, HttpResponseRedirect from django.http.response import HttpResponseBase from django.shortcuts import get_object_or_404 @@ -38,14 +43,11 @@ from django.utils.decorators import method_decorator from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.html import escape, escapejs from django.utils.http import urlencode -from django.utils.text import capfirst, get_text_list -from django.utils.translation import string_concat -from django.utils.translation import ugettext as _ -from django.utils.translation import ungettext from django.utils.safestring import mark_safe +from django.utils.text import capfirst, get_text_list +from django.utils.translation import string_concat, ugettext as _, ungettext from django.views.decorators.csrf import csrf_protect - IS_POPUP_VAR = '_popup' TO_FIELD_VAR = '_to_field' diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py index 8389a3fe09..4b5ee57746 100644 --- a/django/contrib/admin/sites.py +++ b/django/contrib/admin/sites.py @@ -1,19 +1,20 @@ from functools import update_wrapper -from django.http import Http404, HttpResponseRedirect + +from django.apps import apps +from django.conf import settings from django.contrib.admin import ModelAdmin, actions from django.contrib.auth import REDIRECT_FIELD_NAME -from django.views.decorators.csrf import csrf_protect -from django.db.models.base import ModelBase -from django.apps import apps from django.core.exceptions import ImproperlyConfigured, PermissionDenied -from django.core.urlresolvers import reverse, NoReverseMatch +from django.core.urlresolvers import NoReverseMatch, reverse +from django.db.models.base import ModelBase +from django.http import Http404, HttpResponseRedirect from django.template.engine import Engine from django.template.response import TemplateResponse from django.utils import six from django.utils.text import capfirst -from django.utils.translation import ugettext_lazy, ugettext as _ +from django.utils.translation import ugettext as _, ugettext_lazy from django.views.decorators.cache import never_cache -from django.conf import settings +from django.views.decorators.csrf import csrf_protect system_check_errors = [] diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py index 6f7c530aa7..55fba4f90c 100644 --- a/django/contrib/admin/templatetags/admin_list.py +++ b/django/contrib/admin/templatetags/admin_list.py @@ -2,24 +2,25 @@ from __future__ import unicode_literals import datetime -from django.contrib.admin.templatetags.admin_urls import add_preserved_filters -from django.contrib.admin.utils import (lookup_field, display_for_field, - display_for_value, label_for_field) -from django.contrib.admin.views.main import (ALL_VAR, EMPTY_CHANGELIST_VALUE, - ORDER_VAR, PAGE_VAR, SEARCH_VAR) from django.contrib.admin.templatetags.admin_static import static +from django.contrib.admin.templatetags.admin_urls import add_preserved_filters +from django.contrib.admin.utils import ( + display_for_field, display_for_value, label_for_field, lookup_field, +) +from django.contrib.admin.views.main import ( + ALL_VAR, EMPTY_CHANGELIST_VALUE, ORDER_VAR, PAGE_VAR, SEARCH_VAR, +) from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import NoReverseMatch from django.db import models +from django.template import Library +from django.template.loader import get_template from django.utils import formats +from django.utils.encoding import force_text from django.utils.html import escapejs, format_html from django.utils.safestring import mark_safe from django.utils.text import capfirst from django.utils.translation import ugettext as _ -from django.utils.encoding import force_text -from django.template import Library -from django.template.loader import get_template - register = Library() diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py index 95cbe634b2..f704ef3af7 100644 --- a/django/contrib/admin/utils.py +++ b/django/contrib/admin/utils.py @@ -6,7 +6,7 @@ from collections import defaultdict from django.contrib.auth import get_permission_codename from django.core.exceptions import FieldDoesNotExist -from django.core.urlresolvers import reverse, NoReverseMatch +from django.core.urlresolvers import NoReverseMatch, reverse from django.db import models from django.db.models.constants import LOOKUP_SEP from django.db.models.deletion import Collector diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index 07457a87fc..fa91ceae3a 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -1,22 +1,26 @@ -from collections import OrderedDict import sys - -from 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 10ac364f74..19b4187b52 100644 --- a/django/contrib/admin/widgets.py +++ b/django/contrib/admin/widgets.py @@ -9,15 +9,17 @@ from django import forms from django.contrib.admin.templatetags.admin_static import static from django.core.urlresolvers import reverse from django.db.models.deletion import CASCADE -from django.forms.widgets import Media, RadioFieldRenderer from django.forms.utils import flatatt +from django.forms.widgets import Media, RadioFieldRenderer from django.template.loader import render_to_string -from django.utils.html import escape, format_html, format_html_join, smart_urlquote +from django.utils import six +from django.utils.encoding import force_text +from django.utils.html import ( + escape, format_html, format_html_join, smart_urlquote, +) +from django.utils.safestring import mark_safe from django.utils.text import Truncator from django.utils.translation import ugettext as _ -from django.utils.safestring import mark_safe -from django.utils.encoding import force_text -from django.utils import six class FilteredSelectMultiple(forms.SelectMultiple): diff --git a/django/contrib/admindocs/apps.py b/django/contrib/admindocs/apps.py index 7994f618cd..28ddbfb92a 100644 --- a/django/contrib/admindocs/apps.py +++ b/django/contrib/admindocs/apps.py @@ -1,5 +1,4 @@ from django.apps import AppConfig - from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/admindocs/middleware.py b/django/contrib/admindocs/middleware.py index 330b76423b..2e4cede0b9 100644 --- a/django/contrib/admindocs/middleware.py +++ b/django/contrib/admindocs/middleware.py @@ -1,5 +1,5 @@ -from django.conf import settings from django import http +from django.conf import settings class XViewMiddleware(object): diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py index 779a8a446b..f366025f89 100644 --- a/django/contrib/admindocs/utils.py +++ b/django/contrib/admindocs/utils.py @@ -1,12 +1,13 @@ "Misc. utility functions/classes for admin documentation generator." import re -from email.parser import HeaderParser from email.errors import HeaderParseError +from email.parser import HeaderParser -from django.utils.safestring import mark_safe from django.core.urlresolvers import reverse from django.utils.encoding import force_bytes +from django.utils.safestring import mark_safe + try: import docutils.core import docutils.nodes diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py index 4ce64c3a53..91ca143508 100644 --- a/django/contrib/admindocs/views.py +++ b/django/contrib/admindocs/views.py @@ -1,23 +1,25 @@ -from importlib import import_module import inspect import os import re +from importlib import import_module from django.apps import apps from django.conf import settings from django.contrib import admin from django.contrib.admin.views.decorators import staff_member_required -from django.db import models -from django.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 90394c8f09..b791609031 100644 --- a/django/contrib/auth/admin.py +++ b/django/contrib/auth/admin.py @@ -1,19 +1,19 @@ -from django.db import transaction from django.conf import settings from django.conf.urls import url -from django.contrib import admin +from django.contrib import admin, messages from django.contrib.admin.options import IS_POPUP_VAR from django.contrib.auth import update_session_auth_hash -from django.contrib.auth.forms import (UserCreationForm, UserChangeForm, - AdminPasswordChangeForm) -from django.contrib.auth.models import User, Group -from django.contrib import messages +from django.contrib.auth.forms import ( + AdminPasswordChangeForm, UserChangeForm, UserCreationForm, +) +from django.contrib.auth.models import Group, User from django.core.exceptions import PermissionDenied -from django.http import HttpResponseRedirect, Http404 +from django.db import transaction +from django.http import Http404, HttpResponseRedirect from django.shortcuts import get_object_or_404 from django.template.response import TemplateResponse -from django.utils.html import escape from django.utils.decorators import method_decorator +from django.utils.html import escape from django.utils.translation import ugettext, ugettext_lazy as _ from django.views.decorators.csrf import csrf_protect from django.views.decorators.debug import sensitive_post_parameters diff --git a/django/contrib/auth/apps.py b/django/contrib/auth/apps.py index bbfcb7dbd1..109a34dff6 100644 --- a/django/contrib/auth/apps.py +++ b/django/contrib/auth/apps.py @@ -1,6 +1,6 @@ from django.apps import AppConfig -from django.core import checks from django.contrib.auth.checks import check_user_model +from django.core import checks from django.db.models.signals import post_migrate from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py index 00a772fd4f..9f08259038 100644 --- a/django/contrib/auth/backends.py +++ b/django/contrib/auth/backends.py @@ -1,4 +1,5 @@ from __future__ import unicode_literals + from django.contrib.auth import get_user_model from django.contrib.auth.models import Permission diff --git a/django/contrib/auth/decorators.py b/django/contrib/auth/decorators.py index 99e2983e63..9b2504b33c 100644 --- a/django/contrib/auth/decorators.py +++ b/django/contrib/auth/decorators.py @@ -1,10 +1,11 @@ from functools import wraps + from django.conf import settings from django.contrib.auth import REDIRECT_FIELD_NAME from django.core.exceptions import PermissionDenied +from django.shortcuts import resolve_url from django.utils.decorators import available_attrs from django.utils.six.moves.urllib.parse import urlparse -from django.shortcuts import resolve_url def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py index 3d19b2247e..cc3be5ba0b 100644 --- a/django/contrib/auth/forms.py +++ b/django/contrib/auth/forms.py @@ -3,6 +3,13 @@ from __future__ import unicode_literals from collections import OrderedDict from django import forms +from django.contrib.auth import authenticate, get_user_model +from django.contrib.auth.hashers import ( + UNUSABLE_PASSWORD_PREFIX, identify_hasher, +) +from django.contrib.auth.models import User +from django.contrib.auth.tokens import default_token_generator +from django.contrib.sites.shortcuts import get_current_site from django.core.mail import EmailMultiAlternatives from django.forms.utils import flatatt from django.template import loader @@ -13,12 +20,6 @@ from django.utils.safestring import mark_safe from django.utils.text import capfirst from django.utils.translation import ugettext, ugettext_lazy as _ -from django.contrib.auth import authenticate, get_user_model -from django.contrib.auth.models import User -from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX, identify_hasher -from django.contrib.auth.tokens import default_token_generator -from django.contrib.sites.shortcuts import get_current_site - class ReadOnlyPasswordHashWidget(forms.Widget): def render(self, name, value, attrs): diff --git a/django/contrib/auth/handlers/modwsgi.py b/django/contrib/auth/handlers/modwsgi.py index 8ada9750f1..6b91ed9c6e 100644 --- a/django/contrib/auth/handlers/modwsgi.py +++ b/django/contrib/auth/handlers/modwsgi.py @@ -1,5 +1,5 @@ -from django.contrib import auth from django import db +from django.contrib import auth from django.utils.encoding import force_bytes diff --git a/django/contrib/auth/hashers.py b/django/contrib/auth/hashers.py index 44ebf89c36..59676f6562 100644 --- a/django/contrib/auth/hashers.py +++ b/django/contrib/auth/hashers.py @@ -2,22 +2,22 @@ from __future__ import unicode_literals import base64 import binascii -from collections import OrderedDict import hashlib import importlib +from collections import OrderedDict -from django.dispatch import receiver from django.conf import settings -from django.core.signals import setting_changed -from django.utils.encoding import force_bytes, force_str, force_text from django.core.exceptions import ImproperlyConfigured -from django.utils.crypto import ( - pbkdf2, constant_time_compare, get_random_string) +from django.core.signals import setting_changed +from django.dispatch import receiver from django.utils import lru_cache +from django.utils.crypto import ( + constant_time_compare, get_random_string, pbkdf2, +) +from django.utils.encoding import force_bytes, force_str, force_text from django.utils.module_loading import import_string from django.utils.translation import ugettext_noop as _ - UNUSABLE_PASSWORD_PREFIX = '!' # This will never be a valid encoded hash UNUSABLE_PASSWORD_SUFFIX_LENGTH = 40 # number of random chars to add after UNUSABLE_PASSWORD_PREFIX diff --git a/django/contrib/auth/migrations/0001_initial.py b/django/contrib/auth/migrations/0001_initial.py index 33c8e00153..a58f73ab1a 100644 --- a/django/contrib/auth/migrations/0001_initial.py +++ b/django/contrib/auth/migrations/0001_initial.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -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 8e82223237..8b58e7814b 100644 --- a/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py +++ b/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/auth/migrations/0003_alter_user_email_max_length.py b/django/contrib/auth/migrations/0003_alter_user_email_max_length.py index a9b8058089..0a082f2656 100644 --- a/django/contrib/auth/migrations/0003_alter_user_email_max_length.py +++ b/django/contrib/auth/migrations/0003_alter_user_email_max_length.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/auth/migrations/0004_alter_user_username_opts.py b/django/contrib/auth/migrations/0004_alter_user_username_opts.py index 80a156e001..0f7bfdf3a7 100644 --- a/django/contrib/auth/migrations/0004_alter_user_username_opts.py +++ b/django/contrib/auth/migrations/0004_alter_user_username_opts.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations import django.core.validators +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/auth/migrations/0005_alter_user_last_login_null.py b/django/contrib/auth/migrations/0005_alter_user_last_login_null.py index 128a4e4962..b8b9289787 100644 --- a/django/contrib/auth/migrations/0005_alter_user_last_login_null.py +++ b/django/contrib/auth/migrations/0005_alter_user_last_login_null.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index 89b3054b70..4dc49c2d0c 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -1,21 +1,20 @@ from __future__ import unicode_literals -from django.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 1f31f7a16a..7314bac4ee 100644 --- a/django/contrib/auth/tests/backend_alias.py +++ b/django/contrib/auth/tests/backend_alias.py @@ -1,2 +1,4 @@ # For testing that auth backends can be referenced using a convenience import -from django.contrib.auth.tests.test_auth_backends import ImportedModelBackend # NOQA +from django.contrib.auth.tests.test_auth_backends import ImportedModelBackend + +__all__ = ['ImportedModelBackend'] diff --git a/django/contrib/auth/tests/custom_user.py b/django/contrib/auth/tests/custom_user.py index c856431bba..e7ce6162e9 100644 --- a/django/contrib/auth/tests/custom_user.py +++ b/django/contrib/auth/tests/custom_user.py @@ -1,13 +1,8 @@ -from django.db import models from django.contrib.auth.models import ( - BaseUserManager, - AbstractBaseUser, - AbstractUser, - UserManager, - PermissionsMixin, - Group, - Permission, + AbstractBaseUser, AbstractUser, BaseUserManager, Group, Permission, + PermissionsMixin, UserManager, ) +from django.db import models # The custom User uses email as the unique identifier, and requires diff --git a/django/contrib/auth/tests/settings.py b/django/contrib/auth/tests/settings.py index b3e1eff156..7da6144d4b 100644 --- a/django/contrib/auth/tests/settings.py +++ b/django/contrib/auth/tests/settings.py @@ -2,7 +2,6 @@ import os from django.utils._os import upath - AUTH_MIDDLEWARE_CLASSES = [ 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', diff --git a/django/contrib/auth/tests/test_auth_backends.py b/django/contrib/auth/tests/test_auth_backends.py index 383fae759e..2abdc4d797 100644 --- a/django/contrib/auth/tests/test_auth_backends.py +++ b/django/contrib/auth/tests/test_auth_backends.py @@ -1,16 +1,19 @@ from __future__ import unicode_literals + from datetime import date +from django.contrib.auth import BACKEND_SESSION_KEY, authenticate, get_user from django.contrib.auth.backends import ModelBackend -from django.contrib.auth.models import User, Group, Permission, AnonymousUser +from django.contrib.auth.hashers import MD5PasswordHasher +from django.contrib.auth.models import AnonymousUser, Group, Permission, User +from django.contrib.auth.tests.custom_user import ( + CustomPermissionsUser, CustomUser, ExtensionUser, +) from django.contrib.auth.tests.utils import skipIfCustomUser -from django.contrib.auth.tests.custom_user import ExtensionUser, CustomPermissionsUser, CustomUser from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ImproperlyConfigured, PermissionDenied -from django.contrib.auth import authenticate, BACKEND_SESSION_KEY, get_user from django.http import HttpRequest from django.test import TestCase, modify_settings, override_settings -from django.contrib.auth.hashers import MD5PasswordHasher class CountingMD5PasswordHasher(MD5PasswordHasher): diff --git a/django/contrib/auth/tests/test_basic.py b/django/contrib/auth/tests/test_basic.py index fed94db82f..ca7db755e6 100644 --- a/django/contrib/auth/tests/test_basic.py +++ b/django/contrib/auth/tests/test_basic.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals from django.apps import apps from django.contrib.auth import get_user_model -from django.contrib.auth.models import User, AnonymousUser +from django.contrib.auth.models import AnonymousUser, User from django.contrib.auth.tests.custom_user import CustomUser from django.contrib.auth.tests.utils import skipIfCustomUser from django.core.exceptions import ImproperlyConfigured diff --git a/django/contrib/auth/tests/test_context_processors.py b/django/contrib/auth/tests/test_context_processors.py index 2f7e5ab4b2..3e1c19e91d 100644 --- a/django/contrib/auth/tests/test_context_processors.py +++ b/django/contrib/auth/tests/test_context_processors.py @@ -1,7 +1,7 @@ from django.contrib.auth import authenticate -from django.contrib.auth.models import User, Permission +from django.contrib.auth.context_processors import PermLookupDict, PermWrapper +from django.contrib.auth.models import Permission, User from django.contrib.contenttypes.models import ContentType -from django.contrib.auth.context_processors import PermWrapper, PermLookupDict from django.db.models import Q from django.test import TestCase, override_settings diff --git a/django/contrib/auth/tests/test_forms.py b/django/contrib/auth/tests/test_forms.py index 601c0868d7..6437ef6b2e 100644 --- a/django/contrib/auth/tests/test_forms.py +++ b/django/contrib/auth/tests/test_forms.py @@ -3,16 +3,18 @@ from __future__ import unicode_literals import re from django import forms +from django.contrib.auth.forms import ( + AuthenticationForm, PasswordChangeForm, PasswordResetForm, + ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget, SetPasswordForm, + UserChangeForm, UserCreationForm, +) from django.contrib.auth.models import User -from django.contrib.auth.forms import (UserCreationForm, AuthenticationForm, - PasswordChangeForm, SetPasswordForm, UserChangeForm, PasswordResetForm, - ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget) from django.core import mail from django.core.mail import EmailMultiAlternatives -from django.forms.fields import Field, CharField +from django.forms.fields import CharField, Field from django.test import TestCase, override_settings -from django.utils.encoding import force_text from django.utils import translation +from django.utils.encoding import force_text from django.utils.text import capfirst from django.utils.translation import ugettext as _ diff --git a/django/contrib/auth/tests/test_handlers.py b/django/contrib/auth/tests/test_handlers.py index f4fa3030de..a6a4f9cd06 100644 --- a/django/contrib/auth/tests/test_handlers.py +++ b/django/contrib/auth/tests/test_handlers.py @@ -1,11 +1,12 @@ from __future__ import unicode_literals -from django.contrib.auth.handlers.modwsgi import check_password, groups_for_user -from django.contrib.auth.models import User, Group +from django.contrib.auth.handlers.modwsgi import ( + check_password, groups_for_user, +) +from django.contrib.auth.models import Group, User from django.contrib.auth.tests.custom_user import CustomUser from django.contrib.auth.tests.utils import skipIfCustomUser -from django.test import TransactionTestCase -from django.test import override_settings +from django.test import TransactionTestCase, override_settings # This must be a TransactionTestCase because the WSGI auth handler performs diff --git a/django/contrib/auth/tests/test_hashers.py b/django/contrib/auth/tests/test_hashers.py index 740ba462a2..52253d6efb 100644 --- a/django/contrib/auth/tests/test_hashers.py +++ b/django/contrib/auth/tests/test_hashers.py @@ -4,14 +4,16 @@ from __future__ import unicode_literals from unittest import skipUnless from django.conf.global_settings import PASSWORD_HASHERS -from django.contrib.auth.hashers import (is_password_usable, BasePasswordHasher, - check_password, make_password, PBKDF2PasswordHasher, PBKDF2SHA1PasswordHasher, - get_hasher, identify_hasher, UNUSABLE_PASSWORD_PREFIX, UNUSABLE_PASSWORD_SUFFIX_LENGTH) +from django.contrib.auth.hashers import ( + UNUSABLE_PASSWORD_PREFIX, UNUSABLE_PASSWORD_SUFFIX_LENGTH, + BasePasswordHasher, PBKDF2PasswordHasher, PBKDF2SHA1PasswordHasher, + check_password, get_hasher, identify_hasher, is_password_usable, + make_password, +) from django.test import SimpleTestCase from django.test.utils import override_settings from django.utils import six - try: import crypt except ImportError: diff --git a/django/contrib/auth/tests/test_management.py b/django/contrib/auth/tests/test_management.py index 24e4317392..1a210a1915 100644 --- a/django/contrib/auth/tests/test_management.py +++ b/django/contrib/auth/tests/test_management.py @@ -1,23 +1,28 @@ from __future__ import unicode_literals -from datetime import date import locale import sys +from datetime import date from django.apps import apps -from django.contrib.auth import models, management +from django.contrib.auth import management, models from django.contrib.auth.checks import check_user_model from django.contrib.auth.management import create_permissions -from django.contrib.auth.management.commands import changepassword, createsuperuser -from django.contrib.auth.models import User, Group -from django.contrib.auth.tests.custom_user import CustomUser, CustomUserWithFK, Email +from django.contrib.auth.management.commands import ( + changepassword, createsuperuser, +) +from django.contrib.auth.models import Group, User +from django.contrib.auth.tests.custom_user import ( + CustomUser, CustomUserWithFK, Email, +) from django.contrib.auth.tests.utils import skipIfCustomUser from django.contrib.contenttypes.models import ContentType -from django.core import checks -from django.core import exceptions +from django.core import checks, exceptions from django.core.management import call_command from django.core.management.base import CommandError -from django.test import TestCase, override_settings, override_system_checks, skipUnlessDBFeature +from django.test import ( + TestCase, override_settings, override_system_checks, skipUnlessDBFeature, +) from django.utils import six from django.utils.encoding import force_str diff --git a/django/contrib/auth/tests/test_models.py b/django/contrib/auth/tests/test_models.py index b0a35a445a..ee51b15a98 100644 --- a/django/contrib/auth/tests/test_models.py +++ b/django/contrib/auth/tests/test_models.py @@ -1,5 +1,7 @@ from django.contrib.auth import get_user_model -from django.contrib.auth.models import AbstractUser, Group, Permission, User, UserManager +from django.contrib.auth.models import ( + AbstractUser, Group, Permission, User, UserManager, +) from django.contrib.auth.tests.utils import skipIfCustomUser from django.contrib.contenttypes.models import ContentType from django.core import mail diff --git a/django/contrib/auth/tests/test_signals.py b/django/contrib/auth/tests/test_signals.py index e3c89f2366..909c28a36d 100644 --- a/django/contrib/auth/tests/test_signals.py +++ b/django/contrib/auth/tests/test_signals.py @@ -1,9 +1,8 @@ from django.contrib.auth import signals from django.contrib.auth.models import User from django.contrib.auth.tests.utils import skipIfCustomUser -from django.test import TestCase +from django.test import TestCase, override_settings from django.test.client import RequestFactory -from django.test import override_settings @skipIfCustomUser diff --git a/django/contrib/auth/tests/test_templates.py b/django/contrib/auth/tests/test_templates.py index 409a1705f3..ab3aea42db 100644 --- a/django/contrib/auth/tests/test_templates.py +++ b/django/contrib/auth/tests/test_templates.py @@ -3,11 +3,10 @@ from django.contrib.auth.models import User from django.contrib.auth.tests.utils import skipIfCustomUser from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.contrib.auth.views import ( - password_reset, password_reset_done, password_reset_confirm, - password_reset_complete, password_change, password_change_done, + password_change, password_change_done, password_reset, + password_reset_complete, password_reset_confirm, password_reset_done, ) -from django.test import RequestFactory, TestCase -from django.test import override_settings +from django.test import RequestFactory, TestCase, override_settings from django.utils.encoding import force_bytes, force_text from django.utils.http import urlsafe_base64_encode diff --git a/django/contrib/auth/tests/test_tokens.py b/django/contrib/auth/tests/test_tokens.py index 583546ab3a..b9433bdcfa 100644 --- a/django/contrib/auth/tests/test_tokens.py +++ b/django/contrib/auth/tests/test_tokens.py @@ -1,11 +1,11 @@ -from datetime import date, timedelta import sys import unittest +from datetime import date, timedelta from django.conf import settings from django.contrib.auth.models import User -from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.contrib.auth.tests.utils import skipIfCustomUser +from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.test import TestCase diff --git a/django/contrib/auth/tests/test_views.py b/django/contrib/auth/tests/test_views.py index fd01909c2b..c065d30dbe 100644 --- a/django/contrib/auth/tests/test_views.py +++ b/django/contrib/auth/tests/test_views.py @@ -1,33 +1,34 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from importlib import import_module import itertools import re +from importlib import import_module from django.apps import apps from django.conf import settings -from django.contrib.sites.requests import RequestSite from django.contrib.admin.models import LogEntry -from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME -from django.contrib.auth.forms import (AuthenticationForm, PasswordChangeForm, - SetPasswordForm) +from django.contrib.auth import REDIRECT_FIELD_NAME, SESSION_KEY +from django.contrib.auth.forms import ( + AuthenticationForm, PasswordChangeForm, SetPasswordForm, +) from django.contrib.auth.models import User from django.contrib.auth.views import login as login_view, redirect_to_login +from django.contrib.sessions.middleware import SessionMiddleware +from django.contrib.sites.requests import RequestSite from django.core import mail from django.core.urlresolvers import NoReverseMatch, reverse, reverse_lazy -from django.http import QueryDict, HttpRequest -from django.utils.deprecation import RemovedInDjango20Warning -from django.utils.encoding import force_text -from django.utils.http import urlquote -from django.utils.six.moves.urllib.parse import urlparse, ParseResult -from django.utils.translation import LANGUAGE_SESSION_KEY +from django.http import HttpRequest, QueryDict +from django.middleware.csrf import CsrfViewMiddleware from django.test import ( TestCase, ignore_warnings, modify_settings, override_settings, ) from django.test.utils import patch_logger -from django.middleware.csrf import CsrfViewMiddleware -from django.contrib.sessions.middleware import SessionMiddleware +from django.utils.deprecation import RemovedInDjango20Warning +from django.utils.encoding import force_text +from django.utils.http import urlquote +from django.utils.six.moves.urllib.parse import ParseResult, urlparse +from django.utils.translation import LANGUAGE_SESSION_KEY # Needed so model is installed when tests are run independently: from .custom_user import CustomUser # NOQA diff --git a/django/contrib/auth/tests/urls.py b/django/contrib/auth/tests/urls.py index 41e742a93b..6f83e0f420 100644 --- a/django/contrib/auth/tests/urls.py +++ b/django/contrib/auth/tests/urls.py @@ -1,13 +1,13 @@ -from django.conf.urls import url, include +from django.conf.urls import include, url from django.contrib import admin -from django.contrib.auth.forms import AuthenticationForm -from django.contrib.auth.urls import urlpatterns from django.contrib.auth import views from django.contrib.auth.decorators import login_required +from django.contrib.auth.forms import AuthenticationForm +from django.contrib.auth.urls import urlpatterns from django.contrib.messages.api import info -from django.http import HttpResponse, HttpRequest +from django.http import HttpRequest, HttpResponse from django.shortcuts import render -from django.template import Template, RequestContext +from django.template import RequestContext, Template from django.views.decorators.cache import never_cache diff --git a/django/contrib/auth/tests/urls_admin.py b/django/contrib/auth/tests/urls_admin.py index 49d6f38447..8d2fe3fd10 100644 --- a/django/contrib/auth/tests/urls_admin.py +++ b/django/contrib/auth/tests/urls_admin.py @@ -4,8 +4,8 @@ Test URLs for auth admins. from django.conf.urls import include, url from django.contrib import admin -from django.contrib.auth.admin import UserAdmin, GroupAdmin -from django.contrib.auth.models import User, Group +from django.contrib.auth.admin import GroupAdmin, UserAdmin +from django.contrib.auth.models import Group, User from django.contrib.auth.urls import urlpatterns # Create a silo'd admin site for just the user/group admins. diff --git a/django/contrib/auth/tokens.py b/django/contrib/auth/tokens.py index 89100daeb2..b925c21eff 100644 --- a/django/contrib/auth/tokens.py +++ b/django/contrib/auth/tokens.py @@ -1,8 +1,9 @@ from datetime import date + from django.conf import settings -from django.utils.http import int_to_base36, base36_to_int -from django.utils.crypto import constant_time_compare, salted_hmac from django.utils import six +from django.utils.crypto import constant_time_compare, salted_hmac +from django.utils.http import base36_to_int, int_to_base36 class PasswordResetTokenGenerator(object): diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py index 348fca8745..deedb7f232 100644 --- a/django/contrib/auth/views.py +++ b/django/contrib/auth/views.py @@ -1,25 +1,31 @@ import warnings from django.conf import settings +# Avoid shadowing the login() and logout() views below. +from django.contrib.auth import ( + REDIRECT_FIELD_NAME, get_user_model, login as auth_login, + logout as auth_logout, update_session_auth_hash, +) +from django.contrib.auth.decorators import login_required +from django.contrib.auth.forms import ( + AuthenticationForm, PasswordChangeForm, PasswordResetForm, SetPasswordForm, +) +from django.contrib.auth.tokens import default_token_generator +from django.contrib.sites.shortcuts import get_current_site from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, QueryDict +from django.shortcuts import resolve_url from django.template.response import TemplateResponse from django.utils.deprecation import RemovedInDjango20Warning from django.utils.http import is_safe_url, urlsafe_base64_decode -from django.utils.translation import ugettext as _ from django.utils.six.moves.urllib.parse import urlparse, urlunparse -from django.shortcuts import resolve_url -from django.views.decorators.debug import sensitive_post_parameters +from django.utils.translation import ugettext as _ from django.views.decorators.cache import never_cache from django.views.decorators.csrf import csrf_protect +from django.views.decorators.debug import sensitive_post_parameters + # Avoid shadowing the login() and logout() views below. -from django.contrib.auth import (REDIRECT_FIELD_NAME, login as auth_login, - logout as auth_logout, get_user_model, update_session_auth_hash) -from django.contrib.auth.decorators import login_required -from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm, SetPasswordForm, PasswordChangeForm -from django.contrib.auth.tokens import default_token_generator -from django.contrib.sites.shortcuts import get_current_site @sensitive_post_parameters() diff --git a/django/contrib/contenttypes/admin.py b/django/contrib/contenttypes/admin.py index 3db9d2d612..85bf3227e3 100644 --- a/django/contrib/contenttypes/admin.py +++ b/django/contrib/contenttypes/admin.py @@ -6,7 +6,7 @@ from django.contrib.admin.checks import InlineModelAdminChecks from django.contrib.admin.options import InlineModelAdmin, flatten_fieldsets from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.forms import ( - BaseGenericInlineFormSet, generic_inlineformset_factory + BaseGenericInlineFormSet, generic_inlineformset_factory, ) from django.core import checks from django.core.exceptions import FieldDoesNotExist diff --git a/django/contrib/contenttypes/checks.py b/django/contrib/contenttypes/checks.py index 890859505a..1b3df21353 100644 --- a/django/contrib/contenttypes/checks.py +++ b/django/contrib/contenttypes/checks.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.utils import six from django.apps import apps +from django.utils import six def check_generic_foreign_keys(**kwargs): diff --git a/django/contrib/contenttypes/fields.py b/django/contrib/contenttypes/fields.py index b20d38768d..c11d6284c0 100644 --- a/django/contrib/contenttypes/fields.py +++ b/django/contrib/contenttypes/fields.py @@ -2,16 +2,15 @@ from __future__ import unicode_literals from collections import defaultdict +from django.contrib.contenttypes.models import ContentType from django.core import checks from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist -from django.db import connection -from django.db import models, router, transaction, DEFAULT_DB_ALIAS -from django.db.models import signals, DO_NOTHING +from django.db import DEFAULT_DB_ALIAS, connection, models, router, transaction +from django.db.models import DO_NOTHING, signals from django.db.models.base import ModelBase from django.db.models.fields.related import ForeignObject, ForeignObjectRel from django.db.models.query_utils import PathInfo -from django.contrib.contenttypes.models import ContentType -from django.utils.encoding import smart_text, python_2_unicode_compatible +from django.utils.encoding import python_2_unicode_compatible, smart_text @python_2_unicode_compatible diff --git a/django/contrib/contenttypes/forms.py b/django/contrib/contenttypes/forms.py index 693628d3de..e590c3db05 100644 --- a/django/contrib/contenttypes/forms.py +++ b/django/contrib/contenttypes/forms.py @@ -1,9 +1,9 @@ from __future__ import unicode_literals +from django.contrib.contenttypes.models import ContentType from django.db import models from django.forms import ModelForm, modelformset_factory from django.forms.models import BaseModelFormSet -from django.contrib.contenttypes.models import ContentType class BaseGenericInlineFormSet(BaseModelFormSet): diff --git a/django/contrib/contenttypes/migrations/0001_initial.py b/django/contrib/contenttypes/migrations/0001_initial.py index 09519f1d75..68190b2a2b 100644 --- a/django/contrib/contenttypes/migrations/0001_initial.py +++ b/django/contrib/contenttypes/migrations/0001_initial.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations import django.contrib.contenttypes.models +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py b/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py index 1b91437dbc..b2e18846b9 100644 --- a/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py +++ b/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations, models def add_legacy_name(apps, schema_editor): diff --git a/django/contrib/contenttypes/models.py b/django/contrib/contenttypes/models.py index 684380c832..5205ec80f9 100644 --- a/django/contrib/contenttypes/models.py +++ b/django/contrib/contenttypes/models.py @@ -5,9 +5,9 @@ import warnings from django.apps import apps from django.db import models from django.db.utils import OperationalError, ProgrammingError -from django.utils.translation import ugettext_lazy as _ from django.utils.deprecation import RemovedInDjango20Warning from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.translation import ugettext_lazy as _ class ContentTypeManager(models.Manager): diff --git a/django/contrib/contenttypes/tests/tests.py b/django/contrib/contenttypes/tests/tests.py index f41732b6b5..aed559c5fd 100644 --- a/django/contrib/contenttypes/tests/tests.py +++ b/django/contrib/contenttypes/tests/tests.py @@ -6,11 +6,14 @@ from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.views import shortcut from django.contrib.sites.shortcuts import get_current_site from django.core.management import call_command -from django.http import HttpRequest, Http404 +from django.http import Http404, HttpRequest from django.test import TestCase, override_settings, skipUnlessDBFeature from django.utils import six -from .models import ConcreteModel, ProxyModel, FooWithoutUrl, FooWithUrl, FooWithBrokenAbsoluteUrl +from .models import ( + ConcreteModel, FooWithBrokenAbsoluteUrl, FooWithoutUrl, FooWithUrl, + ProxyModel, +) class ContentTypesTests(TestCase): diff --git a/django/contrib/flatpages/admin.py b/django/contrib/flatpages/admin.py index 5711a9466e..06ed824c45 100644 --- a/django/contrib/flatpages/admin.py +++ b/django/contrib/flatpages/admin.py @@ -1,7 +1,7 @@ from django.contrib import admin +from django.contrib.flatpages.forms import FlatpageForm from django.contrib.flatpages.models import FlatPage from django.utils.translation import ugettext_lazy as _ -from django.contrib.flatpages.forms import FlatpageForm class FlatPageAdmin(admin.ModelAdmin): diff --git a/django/contrib/flatpages/apps.py b/django/contrib/flatpages/apps.py index c35bebf721..ac966c81f5 100644 --- a/django/contrib/flatpages/apps.py +++ b/django/contrib/flatpages/apps.py @@ -1,5 +1,4 @@ from django.apps import AppConfig - from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/flatpages/middleware.py b/django/contrib/flatpages/middleware.py index 9fe595d0cf..32d881ffa4 100644 --- a/django/contrib/flatpages/middleware.py +++ b/django/contrib/flatpages/middleware.py @@ -1,6 +1,6 @@ +from django.conf import settings from django.contrib.flatpages.views import flatpage from django.http import Http404 -from django.conf import settings class FlatpageFallbackMiddleware(object): diff --git a/django/contrib/flatpages/migrations/0001_initial.py b/django/contrib/flatpages/migrations/0001_initial.py index 5f583a1051..fe0a3f3374 100644 --- a/django/contrib/flatpages/migrations/0001_initial.py +++ b/django/contrib/flatpages/migrations/0001_initial.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/flatpages/models.py b/django/contrib/flatpages/models.py index 1bddb0b8d2..eac4edd122 100644 --- a/django/contrib/flatpages/models.py +++ b/django/contrib/flatpages/models.py @@ -1,10 +1,10 @@ from __future__ import unicode_literals -from django.db import models from django.contrib.sites.models import Site from django.core.urlresolvers import get_script_prefix -from django.utils.translation import ugettext_lazy as _ +from django.db import models from django.utils.encoding import iri_to_uri, python_2_unicode_compatible +from django.utils.translation import ugettext_lazy as _ @python_2_unicode_compatible diff --git a/django/contrib/flatpages/templatetags/flatpages.py b/django/contrib/flatpages/templatetags/flatpages.py index d7ced97d17..db82c4aa2c 100644 --- a/django/contrib/flatpages/templatetags/flatpages.py +++ b/django/contrib/flatpages/templatetags/flatpages.py @@ -3,7 +3,6 @@ from django.conf import settings from django.contrib.flatpages.models import FlatPage from django.contrib.sites.shortcuts import get_current_site - register = template.Library() diff --git a/django/contrib/flatpages/tests/settings.py b/django/contrib/flatpages/tests/settings.py index b10ebe564c..ad888f9d95 100644 --- a/django/contrib/flatpages/tests/settings.py +++ b/django/contrib/flatpages/tests/settings.py @@ -1,6 +1,5 @@ import os - FLATPAGES_TEMPLATES = [{ 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(os.path.dirname(__file__), 'templates')], diff --git a/django/contrib/flatpages/tests/test_csrf.py b/django/contrib/flatpages/tests/test_csrf.py index b9d7f32327..f8616b3913 100644 --- a/django/contrib/flatpages/tests/test_csrf.py +++ b/django/contrib/flatpages/tests/test_csrf.py @@ -1,7 +1,6 @@ from django.contrib.auth.models import User from django.contrib.auth.tests.utils import skipIfCustomUser -from django.test import TestCase, Client -from django.test import override_settings +from django.test import Client, TestCase, override_settings from .settings import FLATPAGES_TEMPLATES diff --git a/django/contrib/flatpages/tests/test_models.py b/django/contrib/flatpages/tests/test_models.py index f091f3e0ea..c48dc38637 100644 --- a/django/contrib/flatpages/tests/test_models.py +++ b/django/contrib/flatpages/tests/test_models.py @@ -2,8 +2,8 @@ from __future__ import unicode_literals -from django.core.urlresolvers import set_script_prefix, clear_script_prefix from django.contrib.flatpages.models import FlatPage +from django.core.urlresolvers import clear_script_prefix, set_script_prefix from django.test import TestCase diff --git a/django/contrib/flatpages/tests/test_templatetags.py b/django/contrib/flatpages/tests/test_templatetags.py index a4a65ce840..209332b79c 100644 --- a/django/contrib/flatpages/tests/test_templatetags.py +++ b/django/contrib/flatpages/tests/test_templatetags.py @@ -1,6 +1,6 @@ from django.contrib.auth.models import AnonymousUser, User from django.contrib.auth.tests.utils import skipIfCustomUser -from django.template import Template, Context, TemplateSyntaxError +from django.template import Context, Template, TemplateSyntaxError from django.test import TestCase, override_settings from .settings import FLATPAGES_TEMPLATES diff --git a/django/contrib/gis/admin/options.py b/django/contrib/gis/admin/options.py index 8ca0d92c29..f9412336e3 100644 --- a/django/contrib/gis/admin/options.py +++ b/django/contrib/gis/admin/options.py @@ -1,7 +1,7 @@ from django.contrib.admin import ModelAdmin from django.contrib.gis.admin.widgets import OpenLayersWidget -from django.contrib.gis.gdal import HAS_GDAL, OGRGeomType from django.contrib.gis.db import models +from django.contrib.gis.gdal import HAS_GDAL, OGRGeomType class GeoModelAdmin(ModelAdmin): diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py index c85e7a6125..52b624a112 100644 --- a/django/contrib/gis/admin/widgets.py +++ b/django/contrib/gis/admin/widgets.py @@ -1,12 +1,10 @@ import logging +from django.contrib.gis.gdal import GDALException +from django.contrib.gis.geos import GEOSException, GEOSGeometry from django.forms.widgets import Textarea from django.template import loader -from django.utils import six -from django.utils import translation - -from django.contrib.gis.gdal import GDALException -from django.contrib.gis.geos import GEOSGeometry, GEOSException +from django.utils import six, translation # Creating a template context that contains Django settings # values needed by admin map templates. diff --git a/django/contrib/gis/apps.py b/django/contrib/gis/apps.py index 6ca51e9b42..919272b064 100644 --- a/django/contrib/gis/apps.py +++ b/django/contrib/gis/apps.py @@ -1,6 +1,5 @@ from django.apps import AppConfig from django.core import serializers - from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/gis/db/backends/mysql/base.py b/django/contrib/gis/db/backends/mysql/base.py index afeed42203..d252b38804 100644 --- a/django/contrib/gis/db/backends/mysql/base.py +++ b/django/contrib/gis/db/backends/mysql/base.py @@ -1,4 +1,5 @@ -from django.db.backends.mysql.base import DatabaseWrapper as MySQLDatabaseWrapper +from django.db.backends.mysql.base import \ + DatabaseWrapper as MySQLDatabaseWrapper from .features import DatabaseFeatures from .introspection import MySQLIntrospection diff --git a/django/contrib/gis/db/backends/mysql/features.py b/django/contrib/gis/db/backends/mysql/features.py index 02c611b292..a547ec967a 100644 --- a/django/contrib/gis/db/backends/mysql/features.py +++ b/django/contrib/gis/db/backends/mysql/features.py @@ -1,5 +1,6 @@ from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures -from django.db.backends.mysql.features import DatabaseFeatures as MySQLDatabaseFeatures +from django.db.backends.mysql.features import \ + DatabaseFeatures as MySQLDatabaseFeatures class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures): diff --git a/django/contrib/gis/db/backends/mysql/operations.py b/django/contrib/gis/db/backends/mysql/operations.py index 9d0d2a9928..130c103ac2 100644 --- a/django/contrib/gis/db/backends/mysql/operations.py +++ b/django/contrib/gis/db/backends/mysql/operations.py @@ -1,5 +1,6 @@ from django.contrib.gis.db.backends.base.adapter import WKTAdapter -from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations +from django.contrib.gis.db.backends.base.operations import \ + BaseSpatialOperations from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.db.models import aggregates from django.db.backends.mysql.operations import DatabaseOperations diff --git a/django/contrib/gis/db/backends/mysql/schema.py b/django/contrib/gis/db/backends/mysql/schema.py index 4d708686ba..e60f3d2fcc 100644 --- a/django/contrib/gis/db/backends/mysql/schema.py +++ b/django/contrib/gis/db/backends/mysql/schema.py @@ -1,8 +1,8 @@ import logging from django.contrib.gis.db.models.fields import GeometryField -from django.db.utils import OperationalError from django.db.backends.mysql.schema import DatabaseSchemaEditor +from django.db.utils import OperationalError logger = logging.getLogger('django.contrib.gis') diff --git a/django/contrib/gis/db/backends/oracle/adapter.py b/django/contrib/gis/db/backends/oracle/adapter.py index e26603e531..60961af817 100644 --- a/django/contrib/gis/db/backends/oracle/adapter.py +++ b/django/contrib/gis/db/backends/oracle/adapter.py @@ -1,4 +1,5 @@ from cx_Oracle import CLOB + from django.contrib.gis.db.backends.base.adapter import WKTAdapter diff --git a/django/contrib/gis/db/backends/oracle/base.py b/django/contrib/gis/db/backends/oracle/base.py index d20ac2a9e7..167b61d01b 100644 --- a/django/contrib/gis/db/backends/oracle/base.py +++ b/django/contrib/gis/db/backends/oracle/base.py @@ -1,4 +1,5 @@ -from django.db.backends.oracle.base import DatabaseWrapper as OracleDatabaseWrapper +from django.db.backends.oracle.base import \ + DatabaseWrapper as OracleDatabaseWrapper from .features import DatabaseFeatures from .introspection import OracleIntrospection diff --git a/django/contrib/gis/db/backends/oracle/features.py b/django/contrib/gis/db/backends/oracle/features.py index ef56ec627d..df0aedcf32 100644 --- a/django/contrib/gis/db/backends/oracle/features.py +++ b/django/contrib/gis/db/backends/oracle/features.py @@ -1,5 +1,6 @@ from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures -from django.db.backends.oracle.features import DatabaseFeatures as OracleDatabaseFeatures +from django.db.backends.oracle.features import \ + DatabaseFeatures as OracleDatabaseFeatures class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures): diff --git a/django/contrib/gis/db/backends/oracle/introspection.py b/django/contrib/gis/db/backends/oracle/introspection.py index 53a449bb5a..764ce7d243 100644 --- a/django/contrib/gis/db/backends/oracle/introspection.py +++ b/django/contrib/gis/db/backends/oracle/introspection.py @@ -1,5 +1,7 @@ -import cx_Oracle import sys + +import cx_Oracle + from django.db.backends.oracle.introspection import DatabaseIntrospection from django.utils import six diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py index 277126a77e..9d40505632 100644 --- a/django/contrib/gis/db/backends/oracle/operations.py +++ b/django/contrib/gis/db/backends/oracle/operations.py @@ -9,7 +9,8 @@ """ import re -from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations +from django.contrib.gis.db.backends.base.operations import \ + BaseSpatialOperations from django.contrib.gis.db.backends.oracle.adapter import OracleSpatialAdapter from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.db.models import aggregates @@ -19,7 +20,6 @@ from django.db.backends.oracle.base import Database from django.db.backends.oracle.operations import DatabaseOperations from django.utils import six - DEFAULT_TOLERANCE = '0.05' diff --git a/django/contrib/gis/db/backends/postgis/base.py b/django/contrib/gis/db/backends/postgis/base.py index 083f76d0a8..8d17b16c12 100644 --- a/django/contrib/gis/db/backends/postgis/base.py +++ b/django/contrib/gis/db/backends/postgis/base.py @@ -1,8 +1,7 @@ from django.conf import settings from django.db.backends.base.base import NO_DB_ALIAS -from django.db.backends.postgresql_psycopg2.base import ( - DatabaseWrapper as Psycopg2DatabaseWrapper, -) +from django.db.backends.postgresql_psycopg2.base import \ + DatabaseWrapper as Psycopg2DatabaseWrapper from django.utils.functional import cached_property from .creation import PostGISCreation diff --git a/django/contrib/gis/db/backends/postgis/features.py b/django/contrib/gis/db/backends/postgis/features.py index dfa225c6e7..1cc15bde38 100644 --- a/django/contrib/gis/db/backends/postgis/features.py +++ b/django/contrib/gis/db/backends/postgis/features.py @@ -1,7 +1,6 @@ from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures -from django.db.backends.postgresql_psycopg2.features import ( - DatabaseFeatures as Psycopg2DatabaseFeatures, -) +from django.db.backends.postgresql_psycopg2.features import \ + DatabaseFeatures as Psycopg2DatabaseFeatures class DatabaseFeatures(BaseSpatialFeatures, Psycopg2DatabaseFeatures): diff --git a/django/contrib/gis/db/backends/postgis/introspection.py b/django/contrib/gis/db/backends/postgis/introspection.py index 631844a030..5e08b2f9ce 100644 --- a/django/contrib/gis/db/backends/postgis/introspection.py +++ b/django/contrib/gis/db/backends/postgis/introspection.py @@ -1,5 +1,6 @@ -from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrospection from django.contrib.gis.gdal import OGRGeomType +from django.db.backends.postgresql_psycopg2.introspection import \ + DatabaseIntrospection class GeoIntrospectionError(Exception): diff --git a/django/contrib/gis/db/backends/postgis/models.py b/django/contrib/gis/db/backends/postgis/models.py index a438ffcc20..83b254cb39 100644 --- a/django/contrib/gis/db/backends/postgis/models.py +++ b/django/contrib/gis/db/backends/postgis/models.py @@ -1,8 +1,8 @@ """ The GeometryColumns and SpatialRefSys models for the PostGIS backend. """ -from django.db import models from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin +from django.db import models from django.utils.encoding import python_2_unicode_compatible diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py index 2255897f2f..e0af0c1ecb 100644 --- a/django/contrib/gis/db/backends/postgis/operations.py +++ b/django/contrib/gis/db/backends/postgis/operations.py @@ -1,13 +1,15 @@ import re from django.conf import settings -from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations +from django.contrib.gis.db.backends.base.operations import \ + BaseSpatialOperations from django.contrib.gis.db.backends.postgis.adapter import PostGISAdapter from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.geometry.backend import Geometry from django.contrib.gis.measure import Distance from django.core.exceptions import ImproperlyConfigured -from django.db.backends.postgresql_psycopg2.operations import DatabaseOperations +from django.db.backends.postgresql_psycopg2.operations import \ + DatabaseOperations from django.db.utils import ProgrammingError from django.utils.functional import cached_property diff --git a/django/contrib/gis/db/backends/spatialite/adapter.py b/django/contrib/gis/db/backends/spatialite/adapter.py index 70ad900046..c1184f4685 100644 --- a/django/contrib/gis/db/backends/spatialite/adapter.py +++ b/django/contrib/gis/db/backends/spatialite/adapter.py @@ -1,5 +1,5 @@ -from django.db.backends.sqlite3.base import Database from django.contrib.gis.db.backends.base.adapter import WKTAdapter +from django.db.backends.sqlite3.base import Database class SpatiaLiteAdapter(WKTAdapter): diff --git a/django/contrib/gis/db/backends/spatialite/features.py b/django/contrib/gis/db/backends/spatialite/features.py index 4ab382e00b..613087b51e 100644 --- a/django/contrib/gis/db/backends/spatialite/features.py +++ b/django/contrib/gis/db/backends/spatialite/features.py @@ -1,5 +1,6 @@ from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures -from django.db.backends.sqlite3.features import DatabaseFeatures as SQLiteDatabaseFeatures +from django.db.backends.sqlite3.features import \ + DatabaseFeatures as SQLiteDatabaseFeatures from django.utils.functional import cached_property diff --git a/django/contrib/gis/db/backends/spatialite/introspection.py b/django/contrib/gis/db/backends/spatialite/introspection.py index b81a2e4089..c1ed7629b9 100644 --- a/django/contrib/gis/db/backends/spatialite/introspection.py +++ b/django/contrib/gis/db/backends/spatialite/introspection.py @@ -1,5 +1,7 @@ from django.contrib.gis.gdal import OGRGeomType -from django.db.backends.sqlite3.introspection import DatabaseIntrospection, FlexibleFieldLookupDict +from django.db.backends.sqlite3.introspection import ( + DatabaseIntrospection, FlexibleFieldLookupDict, +) from django.utils import six diff --git a/django/contrib/gis/db/backends/spatialite/models.py b/django/contrib/gis/db/backends/spatialite/models.py index a1f0f2d44b..d1b58b7582 100644 --- a/django/contrib/gis/db/backends/spatialite/models.py +++ b/django/contrib/gis/db/backends/spatialite/models.py @@ -1,10 +1,10 @@ """ The GeometryColumns and SpatialRefSys models for the SpatiaLite backend. """ -from django.db import connection, models -from django.db.backends.signals import connection_created from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin from django.contrib.gis.db.backends.spatialite.base import DatabaseWrapper +from django.db import connection, models +from django.db.backends.signals import connection_created from django.utils.encoding import python_2_unicode_compatible diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py index c4700e7aef..73adb02b05 100644 --- a/django/contrib/gis/db/backends/spatialite/operations.py +++ b/django/contrib/gis/db/backends/spatialite/operations.py @@ -1,9 +1,10 @@ import re import sys -from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations -from django.contrib.gis.db.backends.utils import SpatialOperator +from django.contrib.gis.db.backends.base.operations import \ + BaseSpatialOperations from django.contrib.gis.db.backends.spatialite.adapter import SpatiaLiteAdapter +from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.db.models import aggregates from django.contrib.gis.geometry.backend import Geometry from django.contrib.gis.measure import Distance diff --git a/django/contrib/gis/db/backends/spatialite/schema.py b/django/contrib/gis/db/backends/spatialite/schema.py index e067bfc03b..bdf2b93740 100644 --- a/django/contrib/gis/db/backends/spatialite/schema.py +++ b/django/contrib/gis/db/backends/spatialite/schema.py @@ -1,5 +1,5 @@ -from django.db.utils import DatabaseError from django.db.backends.sqlite3.schema import DatabaseSchemaEditor +from django.db.utils import DatabaseError class SpatialiteSchemaEditor(DatabaseSchemaEditor): diff --git a/django/contrib/gis/db/models/aggregates.py b/django/contrib/gis/db/models/aggregates.py index 42198d9287..60954951e6 100644 --- a/django/contrib/gis/db/models/aggregates.py +++ b/django/contrib/gis/db/models/aggregates.py @@ -1,5 +1,5 @@ -from django.db.models.aggregates import Aggregate from django.contrib.gis.db.models.fields import ExtentField +from django.db.models.aggregates import Aggregate __all__ = ['Collect', 'Extent', 'Extent3D', 'MakeLine', 'Union'] diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py index 5e70697a2b..af6d3da972 100644 --- a/django/contrib/gis/db/models/fields.py +++ b/django/contrib/gis/db/models/fields.py @@ -1,11 +1,11 @@ -from django.db.models.fields import Field -from django.db.models.expressions import ExpressionNode -from django.utils.translation import ugettext_lazy as _ from django.contrib.gis import forms from django.contrib.gis.db.models.lookups import gis_lookups from django.contrib.gis.db.models.proxy import GeometryProxy from django.contrib.gis.geometry.backend import Geometry, GeometryException +from django.db.models.expressions import ExpressionNode +from django.db.models.fields import Field from django.utils import six +from django.utils.translation import ugettext_lazy as _ # Local cache of the spatial_ref_sys table, which holds SRID data for each # spatial database alias. This cache exists so that the database isn't queried diff --git a/django/contrib/gis/db/models/lookups.py b/django/contrib/gis/db/models/lookups.py index eb64eff6c7..b739e468ce 100644 --- a/django/contrib/gis/db/models/lookups.py +++ b/django/contrib/gis/db/models/lookups.py @@ -1,10 +1,11 @@ from __future__ import unicode_literals + import re from django.core.exceptions import FieldDoesNotExist from django.db.models.constants import LOOKUP_SEP +from django.db.models.expressions import Col, ExpressionNode from django.db.models.lookups import Lookup -from django.db.models.expressions import ExpressionNode, Col from django.utils import six gis_lookups = {} diff --git a/django/contrib/gis/db/models/manager.py b/django/contrib/gis/db/models/manager.py index 609bdf3637..22d009a972 100644 --- a/django/contrib/gis/db/models/manager.py +++ b/django/contrib/gis/db/models/manager.py @@ -1,5 +1,5 @@ -from django.db.models.manager import Manager from django.contrib.gis.db.models.query import GeoQuerySet +from django.db.models.manager import Manager class GeoManager(Manager.from_queryset(GeoQuerySet)): diff --git a/django/contrib/gis/db/models/query.py b/django/contrib/gis/db/models/query.py index c36381ecaa..998acff79c 100644 --- a/django/contrib/gis/db/models/query.py +++ b/django/contrib/gis/db/models/query.py @@ -1,13 +1,8 @@ import warnings -from django.db import connections -from django.db.models.expressions import RawSQL -from django.db.models.fields import Field -from django.db.models.query import QuerySet - from django.contrib.gis.db.models import aggregates from django.contrib.gis.db.models.fields import ( - get_srid_info, LineStringField, GeometryField, PointField, + GeometryField, LineStringField, PointField, get_srid_info, ) from django.contrib.gis.db.models.lookups import GISLookup from django.contrib.gis.db.models.sql import ( @@ -15,7 +10,10 @@ from django.contrib.gis.db.models.sql import ( ) from django.contrib.gis.geometry.backend import Geometry from django.contrib.gis.measure import Area, Distance - +from django.db import connections +from django.db.models.expressions import RawSQL +from django.db.models.fields import Field +from django.db.models.query import QuerySet from django.utils import six from django.utils.deprecation import RemovedInDjango20Warning diff --git a/django/contrib/gis/db/models/sql/aggregates.py b/django/contrib/gis/db/models/sql/aggregates.py index fe0e396f2f..b83bafda70 100644 --- a/django/contrib/gis/db/models/sql/aggregates.py +++ b/django/contrib/gis/db/models/sql/aggregates.py @@ -1,7 +1,6 @@ from django.db.models.sql import aggregates from django.db.models.sql.aggregates import * # NOQA - __all__ = ['Collect', 'Extent', 'Extent3D', 'MakeLine', 'Union'] + aggregates.__all__ diff --git a/django/contrib/gis/forms/fields.py b/django/contrib/gis/forms/fields.py index af481b8be7..4ae56de88b 100644 --- a/django/contrib/gis/forms/fields.py +++ b/django/contrib/gis/forms/fields.py @@ -1,11 +1,9 @@ from __future__ import unicode_literals from django import forms +from django.contrib.gis.geos import GEOSException, GEOSGeometry from django.utils.translation import ugettext_lazy as _ -# While this couples the geographic forms to the GEOS library, -# it decouples from database (by not importing SpatialBackend). -from django.contrib.gis.geos import GEOSException, GEOSGeometry from .widgets import OpenLayersWidget diff --git a/django/contrib/gis/forms/widgets.py b/django/contrib/gis/forms/widgets.py index 26cc0565b0..37c9be8fbc 100644 --- a/django/contrib/gis/forms/widgets.py +++ b/django/contrib/gis/forms/widgets.py @@ -4,11 +4,10 @@ import logging from django.conf import settings from django.contrib.gis import gdal -from django.contrib.gis.geos import GEOSGeometry, GEOSException +from django.contrib.gis.geos import GEOSException, GEOSGeometry from django.forms.widgets import Widget from django.template import loader -from django.utils import six -from django.utils import translation +from django.utils import six, translation logger = logging.getLogger('django.contrib.gis') diff --git a/django/contrib/gis/gdal/datasource.py b/django/contrib/gis/gdal/datasource.py index ec9ab8c2a4..d574839cf4 100644 --- a/django/contrib/gis/gdal/datasource.py +++ b/django/contrib/gis/gdal/datasource.py @@ -33,20 +33,15 @@ # OFTReal returns floats, all else returns string. val = field.value """ -# ctypes prerequisites. from ctypes import byref -# The GDAL C library, OGR exceptions, and the Layer object. from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.driver import Driver from django.contrib.gis.gdal.error import GDALException, OGRIndexError from django.contrib.gis.gdal.layer import Layer - -# Getting the ctypes prototypes for the DataSource. from django.contrib.gis.gdal.prototypes import ds as capi - -from django.utils.encoding import force_bytes, force_text from django.utils import six +from django.utils.encoding import force_bytes, force_text from django.utils.six.moves import range diff --git a/django/contrib/gis/gdal/driver.py b/django/contrib/gis/gdal/driver.py index 7628e360b9..51d0c9fe33 100644 --- a/django/contrib/gis/gdal/driver.py +++ b/django/contrib/gis/gdal/driver.py @@ -1,8 +1,8 @@ from ctypes import c_void_p + from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.error import GDALException from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi - from django.utils import six from django.utils.encoding import force_bytes, force_text diff --git a/django/contrib/gis/gdal/envelope.py b/django/contrib/gis/gdal/envelope.py index 59d48b7bff..ae9ba434e7 100644 --- a/django/contrib/gis/gdal/envelope.py +++ b/django/contrib/gis/gdal/envelope.py @@ -11,6 +11,7 @@ Lower left (min_x, min_y) o----------+ """ from ctypes import Structure, c_double + from django.contrib.gis.gdal.error import GDALException diff --git a/django/contrib/gis/gdal/feature.py b/django/contrib/gis/gdal/feature.py index da86c70244..ce46ae5209 100644 --- a/django/contrib/gis/gdal/feature.py +++ b/django/contrib/gis/gdal/feature.py @@ -1,14 +1,10 @@ -# The GDAL C library, OGR exception, and the Field object from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.error import GDALException, OGRIndexError from django.contrib.gis.gdal.field import Field from django.contrib.gis.gdal.geometries import OGRGeometry, OGRGeomType - -# ctypes function prototypes from django.contrib.gis.gdal.prototypes import ds as capi, geom as geom_api - -from django.utils.encoding import force_bytes, force_text from django.utils import six +from django.utils.encoding import force_bytes, force_text from django.utils.six.moves import range diff --git a/django/contrib/gis/gdal/field.py b/django/contrib/gis/gdal/field.py index 487c29ea42..599ee60bf3 100644 --- a/django/contrib/gis/gdal/field.py +++ b/django/contrib/gis/gdal/field.py @@ -1,5 +1,6 @@ from ctypes import byref, c_int from datetime import date, datetime, time + from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.error import GDALException from django.contrib.gis.gdal.prototypes import ds as capi diff --git a/django/contrib/gis/gdal/geometries.py b/django/contrib/gis/gdal/geometries.py index d00aa1a785..e9abfbf439 100644 --- a/django/contrib/gis/gdal/geometries.py +++ b/django/contrib/gis/gdal/geometries.py @@ -38,33 +38,27 @@ >>> print(gt1 == 3, gt1 == 'Polygon') # Equivalence works w/non-OGRGeomType objects True True """ -# Python library requisites. import sys from binascii import a2b_hex, b2a_hex -from ctypes import byref, string_at, c_char_p, c_double, c_ubyte, c_void_p +from ctypes import byref, c_char_p, c_double, c_ubyte, c_void_p, string_at -# Getting GDAL prerequisites from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.envelope import Envelope, OGREnvelope -from django.contrib.gis.gdal.error import GDALException, OGRIndexError, SRSException +from django.contrib.gis.gdal.error import ( + GDALException, OGRIndexError, SRSException, +) from django.contrib.gis.gdal.geomtype import OGRGeomType -from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform - -# Getting the ctypes prototype functions that interface w/the GDAL C library. from django.contrib.gis.gdal.prototypes import geom as capi, srs as srs_api - -# For recognizing geometry input. -from django.contrib.gis.geometry.regex import hex_regex, wkt_regex, json_regex - +from django.contrib.gis.gdal.srs import CoordTransform, SpatialReference +from django.contrib.gis.geometry.regex import hex_regex, json_regex, wkt_regex from django.utils import six from django.utils.six.moves import range + # For more information, see the OGR C API source code: # http://www.gdal.org/ogr/ogr__api_8h.html # # The OGR_G_* routines are relevant here. - - class OGRGeometry(GDALBase): "Generally encapsulates an OGR geometry." diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py index 9a06bad789..abb184e2f9 100644 --- a/django/contrib/gis/gdal/geomtype.py +++ b/django/contrib/gis/gdal/geomtype.py @@ -1,5 +1,4 @@ from django.contrib.gis.gdal.error import GDALException - from django.utils import six diff --git a/django/contrib/gis/gdal/layer.py b/django/contrib/gis/gdal/layer.py index e2627a2da9..640d2ad938 100644 --- a/django/contrib/gis/gdal/layer.py +++ b/django/contrib/gis/gdal/layer.py @@ -1,21 +1,20 @@ -# Needed ctypes routines -from ctypes import c_double, byref +from ctypes import byref, c_double -# Other GDAL imports. from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.envelope import Envelope, OGREnvelope -from django.contrib.gis.gdal.error import GDALException, OGRIndexError, SRSException +from django.contrib.gis.gdal.error import ( + GDALException, OGRIndexError, SRSException, +) from django.contrib.gis.gdal.feature import Feature from django.contrib.gis.gdal.field import OGRFieldTypes -from django.contrib.gis.gdal.geomtype import OGRGeomType from django.contrib.gis.gdal.geometries import OGRGeometry +from django.contrib.gis.gdal.geomtype import OGRGeomType +from django.contrib.gis.gdal.prototypes import ( + ds as capi, geom as geom_api, srs as srs_api, +) from django.contrib.gis.gdal.srs import SpatialReference - -# GDAL ctypes function prototypes. -from django.contrib.gis.gdal.prototypes import ds as capi, geom as geom_api, srs as srs_api - -from django.utils.encoding import force_bytes, force_text from django.utils import six +from django.utils.encoding import force_bytes, force_text from django.utils.six.moves import range diff --git a/django/contrib/gis/gdal/libgdal.py b/django/contrib/gis/gdal/libgdal.py index 280ae2ef5b..4f8224c19f 100644 --- a/django/contrib/gis/gdal/libgdal.py +++ b/django/contrib/gis/gdal/libgdal.py @@ -3,7 +3,7 @@ from __future__ import unicode_literals import logging import os import re -from ctypes import c_char_p, c_int, CDLL, CFUNCTYPE +from ctypes import CDLL, CFUNCTYPE, c_char_p, c_int from ctypes.util import find_library from django.contrib.gis.gdal.error import GDALException diff --git a/django/contrib/gis/gdal/prototypes/ds.py b/django/contrib/gis/gdal/prototypes/ds.py index 69257a1140..2f79f7316e 100644 --- a/django/contrib/gis/gdal/prototypes/ds.py +++ b/django/contrib/gis/gdal/prototypes/ds.py @@ -3,11 +3,14 @@ related data structures. OGR_Dr_*, OGR_DS_*, OGR_L_*, OGR_F_*, OGR_Fld_* routines are relevant here. """ -from ctypes import c_char_p, c_double, c_int, c_long, c_void_p, POINTER +from ctypes import POINTER, c_char_p, c_double, c_int, c_long, c_void_p + from django.contrib.gis.gdal.envelope import OGREnvelope from django.contrib.gis.gdal.libgdal import lgdal -from django.contrib.gis.gdal.prototypes.generation import (const_string_output, - double_output, geom_output, int_output, srs_output, void_output, voidptr_output) +from django.contrib.gis.gdal.prototypes.generation import ( + const_string_output, double_output, geom_output, int_output, srs_output, + void_output, voidptr_output, +) c_int_p = POINTER(c_int) # shortcut type diff --git a/django/contrib/gis/gdal/prototypes/errcheck.py b/django/contrib/gis/gdal/prototypes/errcheck.py index d6c5ad17eb..edc40529ed 100644 --- a/django/contrib/gis/gdal/prototypes/errcheck.py +++ b/django/contrib/gis/gdal/prototypes/errcheck.py @@ -4,7 +4,9 @@ """ from ctypes import c_void_p, string_at -from django.contrib.gis.gdal.error import check_err, GDALException, SRSException +from django.contrib.gis.gdal.error import ( + GDALException, SRSException, check_err, +) from django.contrib.gis.gdal.libgdal import lgdal from django.utils import six diff --git a/django/contrib/gis/gdal/prototypes/generation.py b/django/contrib/gis/gdal/prototypes/generation.py index 79b7b47825..39bf621796 100644 --- a/django/contrib/gis/gdal/prototypes/generation.py +++ b/django/contrib/gis/gdal/prototypes/generation.py @@ -4,9 +4,11 @@ """ from ctypes import c_char_p, c_double, c_int, c_void_p from functools import partial + from django.contrib.gis.gdal.prototypes.errcheck import ( - check_arg_errcode, check_errcode, check_geom, check_geom_offset, - check_pointer, check_srs, check_str_arg, check_string, check_const_string) + check_arg_errcode, check_const_string, check_errcode, check_geom, + check_geom_offset, check_pointer, check_srs, check_str_arg, check_string, +) class gdal_char_p(c_char_p): diff --git a/django/contrib/gis/gdal/prototypes/geom.py b/django/contrib/gis/gdal/prototypes/geom.py index 22ff1ed833..6d6412c546 100644 --- a/django/contrib/gis/gdal/prototypes/geom.py +++ b/django/contrib/gis/gdal/prototypes/geom.py @@ -1,9 +1,12 @@ -from ctypes import c_char_p, c_double, c_int, c_void_p, POINTER +from ctypes import POINTER, c_char_p, c_double, c_int, c_void_p + from django.contrib.gis.gdal.envelope import OGREnvelope from django.contrib.gis.gdal.libgdal import lgdal from django.contrib.gis.gdal.prototypes.errcheck import check_envelope -from django.contrib.gis.gdal.prototypes.generation import (const_string_output, - double_output, geom_output, int_output, srs_output, string_output, void_output) +from django.contrib.gis.gdal.prototypes.generation import ( + const_string_output, double_output, geom_output, int_output, srs_output, + string_output, void_output, +) ### Generation routines specific to this module ### diff --git a/django/contrib/gis/gdal/prototypes/raster.py b/django/contrib/gis/gdal/prototypes/raster.py index db32ee1e0b..5e07c76955 100644 --- a/django/contrib/gis/gdal/prototypes/raster.py +++ b/django/contrib/gis/gdal/prototypes/raster.py @@ -2,12 +2,14 @@ This module houses the ctypes function prototypes for GDAL DataSource (raster) related data structures. """ -from ctypes import c_char_p, c_double, c_int, c_void_p, POINTER +from ctypes import POINTER, c_char_p, c_double, c_int, c_void_p from functools import partial from django.contrib.gis.gdal.libgdal import lgdal -from django.contrib.gis.gdal.prototypes.generation import (const_string_output, - double_output, int_output, void_output, voidptr_output) +from django.contrib.gis.gdal.prototypes.generation import ( + const_string_output, double_output, int_output, void_output, + voidptr_output, +) # For more detail about c function names and definitions see # http://gdal.org/gdal_8h.html diff --git a/django/contrib/gis/gdal/prototypes/srs.py b/django/contrib/gis/gdal/prototypes/srs.py index 71ec1ed603..7ab22024ed 100644 --- a/django/contrib/gis/gdal/prototypes/srs.py +++ b/django/contrib/gis/gdal/prototypes/srs.py @@ -1,7 +1,10 @@ -from ctypes import c_char_p, c_int, c_void_p, POINTER +from ctypes import POINTER, c_char_p, c_int, c_void_p + from django.contrib.gis.gdal.libgdal import lgdal, std_call -from django.contrib.gis.gdal.prototypes.generation import (const_string_output, - double_output, int_output, srs_output, string_output, void_output) +from django.contrib.gis.gdal.prototypes.generation import ( + const_string_output, double_output, int_output, srs_output, string_output, + void_output, +) ## Shortcut generation for routines with known parameters. diff --git a/django/contrib/gis/gdal/raster/source.py b/django/contrib/gis/gdal/raster/source.py index e89e70d2e8..bb72db49ee 100644 --- a/django/contrib/gis/gdal/raster/source.py +++ b/django/contrib/gis/gdal/raster/source.py @@ -1,5 +1,5 @@ -from ctypes import addressof, byref, c_double import os +from ctypes import addressof, byref, c_double from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.driver import Driver @@ -8,10 +8,11 @@ from django.contrib.gis.gdal.prototypes import raster as capi from django.contrib.gis.gdal.raster.band import GDALBand from django.contrib.gis.gdal.srs import SpatialReference, SRSException from django.utils import six -from django.utils.six.moves import range -from django.utils.encoding import (force_bytes, force_text, - python_2_unicode_compatible) +from django.utils.encoding import ( + force_bytes, force_text, python_2_unicode_compatible, +) from django.utils.functional import cached_property +from django.utils.six.moves import range class TransformPoint(list): diff --git a/django/contrib/gis/gdal/srs.py b/django/contrib/gis/gdal/srs.py index 8749d079b3..265ea000c2 100644 --- a/django/contrib/gis/gdal/srs.py +++ b/django/contrib/gis/gdal/srs.py @@ -28,16 +28,13 @@ """ from ctypes import byref, c_char_p, c_int -# Getting the error checking routine and exceptions from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.error import SRSException from django.contrib.gis.gdal.prototypes import srs as capi - from django.utils import six from django.utils.encoding import force_bytes, force_text -#### Spatial Reference class. #### class SpatialReference(GDALBase): """ A wrapper for the OGRSpatialReference object. According to the GDAL Web site, diff --git a/django/contrib/gis/gdal/tests/test_ds.py b/django/contrib/gis/gdal/tests/test_ds.py index 04b1c0f982..ef62c160cc 100644 --- a/django/contrib/gis/gdal/tests/test_ds.py +++ b/django/contrib/gis/gdal/tests/test_ds.py @@ -3,7 +3,9 @@ import unittest from unittest import skipUnless from django.contrib.gis.gdal import HAS_GDAL -from django.contrib.gis.geometry.test_data import get_ds_file, TestDS, TEST_DATA +from django.contrib.gis.geometry.test_data import ( + TEST_DATA, TestDS, get_ds_file, +) if HAS_GDAL: from django.contrib.gis.gdal import DataSource, Envelope, OGRGeometry, GDALException, OGRIndexError, GDAL_VERSION diff --git a/django/contrib/gis/gdal/tests/test_geom.py b/django/contrib/gis/gdal/tests/test_geom.py index 4f422c06f6..5696223554 100644 --- a/django/contrib/gis/gdal/tests/test_geom.py +++ b/django/contrib/gis/gdal/tests/test_geom.py @@ -1,16 +1,18 @@ import json -from binascii import b2a_hex -try: - from django.utils.six.moves import cPickle as pickle -except ImportError: - import pickle import unittest +from binascii import b2a_hex from unittest import skipUnless from django.contrib.gis.gdal import HAS_GDAL from django.contrib.gis.geometry.test_data import TestDataMixin from django.utils.six.moves import range +try: + from django.utils.six.moves import cPickle as pickle +except ImportError: + import pickle + + if HAS_GDAL: from django.contrib.gis.gdal import (OGRGeometry, OGRGeomType, GDALException, OGRIndexError, SpatialReference, CoordTransform, diff --git a/django/contrib/gis/geoip/base.py b/django/contrib/gis/geoip/base.py index 9409019d94..a2787af471 100644 --- a/django/contrib/gis/geoip/base.py +++ b/django/contrib/gis/geoip/base.py @@ -2,14 +2,14 @@ import os import re from ctypes import c_char_p -from django.core.validators import ipv4_re from django.contrib.gis.geoip.libgeoip import GEOIP_SETTINGS from django.contrib.gis.geoip.prototypes import ( - GeoIP_open, GeoIP_delete, GeoIP_database_info, - GeoIP_lib_version, GeoIP_record_by_addr, GeoIP_record_by_name, GeoIP_country_code_by_addr, GeoIP_country_code_by_name, - GeoIP_country_name_by_addr, GeoIP_country_name_by_name) - + GeoIP_country_name_by_addr, GeoIP_country_name_by_name, + GeoIP_database_info, GeoIP_delete, GeoIP_lib_version, GeoIP_open, + GeoIP_record_by_addr, GeoIP_record_by_name, +) +from django.core.validators import ipv4_re from django.utils import six from django.utils.encoding import force_bytes diff --git a/django/contrib/gis/geoip/libgeoip.py b/django/contrib/gis/geoip/libgeoip.py index cc4d92c7d0..a6023ff229 100644 --- a/django/contrib/gis/geoip/libgeoip.py +++ b/django/contrib/gis/geoip/libgeoip.py @@ -1,6 +1,7 @@ import os from ctypes import CDLL from ctypes.util import find_library + from django.conf import settings # Creating the settings dictionary with any settings, if needed. diff --git a/django/contrib/gis/geoip/prototypes.py b/django/contrib/gis/geoip/prototypes.py index 22c17f006f..6b47313cfe 100644 --- a/django/contrib/gis/geoip/prototypes.py +++ b/django/contrib/gis/geoip/prototypes.py @@ -1,5 +1,6 @@ -from ctypes import c_char_p, c_float, c_int, string_at, Structure, POINTER -from django.contrib.gis.geoip.libgeoip import lgeoip, free +from ctypes import POINTER, Structure, c_char_p, c_float, c_int, string_at + +from django.contrib.gis.geoip.libgeoip import free, lgeoip #### GeoIP C Structure definitions #### diff --git a/django/contrib/gis/geoip/tests.py b/django/contrib/gis/geoip/tests.py index 06558e0093..8d1309a671 100644 --- a/django/contrib/gis/geoip/tests.py +++ b/django/contrib/gis/geoip/tests.py @@ -6,9 +6,8 @@ import unittest from unittest import skipUnless from django.conf import settings -from django.contrib.gis.geos import HAS_GEOS from django.contrib.gis.geoip import HAS_GEOIP - +from django.contrib.gis.geos import HAS_GEOS from django.utils import six if HAS_GEOIP: diff --git a/django/contrib/gis/geometry/backend/geos.py b/django/contrib/gis/geometry/backend/geos.py index b4d48dbc98..02ca3dd29e 100644 --- a/django/contrib/gis/geometry/backend/geos.py +++ b/django/contrib/gis/geometry/backend/geos.py @@ -1,4 +1,5 @@ from django.contrib.gis.geos import ( - GEOSGeometry as Geometry, GEOSException as GeometryException) + GEOSException as GeometryException, GEOSGeometry as Geometry, +) __all__ = ['Geometry', 'GeometryException'] diff --git a/django/contrib/gis/geometry/test_data.py b/django/contrib/gis/geometry/test_data.py index d6a8bf8263..58d82dbdcc 100644 --- a/django/contrib/gis/geometry/test_data.py +++ b/django/contrib/gis/geometry/test_data.py @@ -10,7 +10,6 @@ from django.utils import six from django.utils._os import upath from django.utils.functional import cached_property - # Path where reference test data is located. TEST_DATA = os.path.join(os.path.dirname(upath(gis.__file__)), 'tests', 'data') diff --git a/django/contrib/gis/geos/collections.py b/django/contrib/gis/geos/collections.py index 83f57cbd18..84b872602d 100644 --- a/django/contrib/gis/geos/collections.py +++ b/django/contrib/gis/geos/collections.py @@ -2,13 +2,14 @@ This module houses the Geometry Collection objects: GeometryCollection, MultiPoint, MultiLineString, and MultiPolygon """ -from ctypes import c_int, c_uint, byref +from ctypes import byref, c_int, c_uint + +from django.contrib.gis.geos import prototypes as capi from django.contrib.gis.geos.geometry import GEOSGeometry from django.contrib.gis.geos.libgeos import get_pointer_arr -from django.contrib.gis.geos.linestring import LineString, LinearRing +from django.contrib.gis.geos.linestring import LinearRing, LineString from django.contrib.gis.geos.point import Point from django.contrib.gis.geos.polygon import Polygon -from django.contrib.gis.geos import prototypes as capi from django.utils.six.moves import range diff --git a/django/contrib/gis/geos/coordseq.py b/django/contrib/gis/geos/coordseq.py index c238d4cda5..8185ab43cc 100644 --- a/django/contrib/gis/geos/coordseq.py +++ b/django/contrib/gis/geos/coordseq.py @@ -3,11 +3,12 @@ by GEOSGeometry to house the actual coordinates of the Point, LineString, and LinearRing geometries. """ -from ctypes import c_double, c_uint, byref +from ctypes import byref, c_double, c_uint + +from django.contrib.gis.geos import prototypes as capi from django.contrib.gis.geos.base import GEOSBase, numpy from django.contrib.gis.geos.error import GEOSException, GEOSIndexError from django.contrib.gis.geos.libgeos import CS_PTR -from django.contrib.gis.geos import prototypes as capi from django.utils.six.moves import range diff --git a/django/contrib/gis/geos/factory.py b/django/contrib/gis/geos/factory.py index 87ee660020..eb06da2c00 100644 --- a/django/contrib/gis/geos/factory.py +++ b/django/contrib/gis/geos/factory.py @@ -1,5 +1,4 @@ -from django.contrib.gis.geos.geometry import GEOSGeometry, wkt_regex, hex_regex - +from django.contrib.gis.geos.geometry import GEOSGeometry, hex_regex, wkt_regex from django.utils import six diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py index c3ba634df1..5b478857ec 100644 --- a/django/contrib/gis/geos/geometry.py +++ b/django/contrib/gis/geos/geometry.py @@ -4,32 +4,19 @@ """ from __future__ import unicode_literals -# Python, ctypes and types dependencies. from ctypes import addressof, byref, c_double -# super-class for mutable list behavior -from django.contrib.gis.geos.mutable_list import ListMixin - from django.contrib.gis.gdal.error import SRSException - -# GEOS-related dependencies. +from django.contrib.gis.geometry.regex import hex_regex, json_regex, wkt_regex +from django.contrib.gis.geos import prototypes as capi from django.contrib.gis.geos.base import GEOSBase, gdal from django.contrib.gis.geos.coordseq import GEOSCoordSeq from django.contrib.gis.geos.error import GEOSException, GEOSIndexError from django.contrib.gis.geos.libgeos import GEOM_PTR - -# All other functions in this module come from the ctypes -# prototypes module -- which handles all interaction with -# the underlying GEOS library. -from django.contrib.gis.geos import prototypes as capi - -# These functions provide access to a thread-local instance -# of their corresponding GEOS I/O class. -from django.contrib.gis.geos.prototypes.io import wkt_r, wkt_w, wkb_r, wkb_w, ewkb_w - -# For recognizing geometry input. -from django.contrib.gis.geometry.regex import hex_regex, wkt_regex, json_regex - +from django.contrib.gis.geos.mutable_list import ListMixin +from django.contrib.gis.geos.prototypes.io import ( + ewkb_w, wkb_r, wkb_w, wkt_r, wkt_w, +) from django.utils import six from django.utils.encoding import force_bytes, force_text @@ -684,11 +671,12 @@ class GEOSGeometry(GEOSBase, ListMixin): # Class mapping dictionary. Has to be at the end to avoid import # conflicts with GEOSGeometry. -from django.contrib.gis.geos.linestring import LineString, LinearRing -from django.contrib.gis.geos.point import Point -from django.contrib.gis.geos.polygon import Polygon -from django.contrib.gis.geos.collections import GeometryCollection, MultiPoint, MultiLineString, MultiPolygon -from django.contrib.gis.geos.prepared import PreparedGeometry +from django.contrib.gis.geos.linestring import LineString, LinearRing # isort:skip +from django.contrib.gis.geos.point import Point # isort:skip +from django.contrib.gis.geos.polygon import Polygon # isort:skip +from django.contrib.gis.geos.collections import ( # isort:skip + GeometryCollection, MultiPoint, MultiLineString, MultiPolygon) +from django.contrib.gis.geos.prepared import PreparedGeometry # isort:skip GEOS_CLASSES = { 0: Point, 1: LineString, diff --git a/django/contrib/gis/geos/io.py b/django/contrib/gis/geos/io.py index f12be89830..daf67dd28c 100644 --- a/django/contrib/gis/geos/io.py +++ b/django/contrib/gis/geos/io.py @@ -4,7 +4,9 @@ objects. Specifically, this has Python implementations of WKB/WKT reader and writer classes. """ from django.contrib.gis.geos.geometry import GEOSGeometry -from django.contrib.gis.geos.prototypes.io import _WKTReader, _WKBReader, WKBWriter, WKTWriter +from django.contrib.gis.geos.prototypes.io import ( + WKBWriter, WKTWriter, _WKBReader, _WKTReader, +) __all__ = ['WKBWriter', 'WKTWriter', 'WKBReader', 'WKTReader'] diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py index 207fa780a4..fa5fa21a25 100644 --- a/django/contrib/gis/geos/libgeos.py +++ b/django/contrib/gis/geos/libgeos.py @@ -9,7 +9,7 @@ import logging import os import re -from ctypes import c_char_p, Structure, CDLL, CFUNCTYPE, POINTER +from ctypes import CDLL, CFUNCTYPE, POINTER, Structure, c_char_p from ctypes.util import find_library from django.contrib.gis.geos.error import GEOSException diff --git a/django/contrib/gis/geos/linestring.py b/django/contrib/gis/geos/linestring.py index 829ab48945..62802c1efd 100644 --- a/django/contrib/gis/geos/linestring.py +++ b/django/contrib/gis/geos/linestring.py @@ -1,9 +1,9 @@ +from django.contrib.gis.geos import prototypes as capi from django.contrib.gis.geos.base import numpy from django.contrib.gis.geos.coordseq import GEOSCoordSeq from django.contrib.gis.geos.error import GEOSException from django.contrib.gis.geos.geometry import GEOSGeometry from django.contrib.gis.geos.point import Point -from django.contrib.gis.geos import prototypes as capi from django.utils.six.moves import range diff --git a/django/contrib/gis/geos/mutable_list.py b/django/contrib/gis/geos/mutable_list.py index f01bc4275f..805351f252 100644 --- a/django/contrib/gis/geos/mutable_list.py +++ b/django/contrib/gis/geos/mutable_list.py @@ -8,8 +8,8 @@ See also http://www.aryehleib.com/MutableLists.html Author: Aryeh Leib Taurog. """ -from django.utils.functional import total_ordering from django.utils import six +from django.utils.functional import total_ordering from django.utils.six.moves import range diff --git a/django/contrib/gis/geos/point.py b/django/contrib/gis/geos/point.py index 2cc5c13683..0b58098fed 100644 --- a/django/contrib/gis/geos/point.py +++ b/django/contrib/gis/geos/point.py @@ -1,7 +1,8 @@ from ctypes import c_uint + +from django.contrib.gis.geos import prototypes as capi from django.contrib.gis.geos.error import GEOSException from django.contrib.gis.geos.geometry import GEOSGeometry -from django.contrib.gis.geos import prototypes as capi from django.utils import six from django.utils.six.moves import range diff --git a/django/contrib/gis/geos/polygon.py b/django/contrib/gis/geos/polygon.py index 38b533df8f..c8059348cd 100644 --- a/django/contrib/gis/geos/polygon.py +++ b/django/contrib/gis/geos/polygon.py @@ -1,8 +1,9 @@ -from ctypes import c_uint, byref -from 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 b115fc3447..3e5204e5fe 100644 --- a/django/contrib/gis/geos/prototypes/coordseq.py +++ b/django/contrib/gis/geos/prototypes/coordseq.py @@ -1,6 +1,9 @@ -from ctypes import c_double, c_int, c_uint, POINTER -from django.contrib.gis.geos.libgeos import GEOM_PTR, CS_PTR -from django.contrib.gis.geos.prototypes.errcheck import last_arg_byref, GEOSException +from ctypes import POINTER, c_double, c_int, c_uint + +from django.contrib.gis.geos.libgeos import CS_PTR, GEOM_PTR +from django.contrib.gis.geos.prototypes.errcheck import ( + GEOSException, last_arg_byref, +) from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc diff --git a/django/contrib/gis/geos/prototypes/errcheck.py b/django/contrib/gis/geos/prototypes/errcheck.py index 034cfe5899..dd037a5632 100644 --- a/django/contrib/gis/geos/prototypes/errcheck.py +++ b/django/contrib/gis/geos/prototypes/errcheck.py @@ -2,10 +2,10 @@ Error checking functions for GEOS ctypes prototype functions. """ from ctypes import c_void_p, string_at + from django.contrib.gis.geos.error import GEOSException from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc - # Getting the `free` routine used to free the memory allocated for # string pointers returned by GEOS. free = GEOSFunc('GEOSFree') diff --git a/django/contrib/gis/geos/prototypes/geom.py b/django/contrib/gis/geos/prototypes/geom.py index 021fe6e469..b8320471e9 100644 --- a/django/contrib/gis/geos/prototypes/geom.py +++ b/django/contrib/gis/geos/prototypes/geom.py @@ -1,7 +1,9 @@ -from ctypes import c_char_p, c_int, c_size_t, c_ubyte, POINTER +from ctypes import POINTER, c_char_p, c_int, c_size_t, c_ubyte + from django.contrib.gis.geos.libgeos import CS_PTR, GEOM_PTR from django.contrib.gis.geos.prototypes.errcheck import ( - check_geom, check_minus_one, check_sized_string, check_string, check_zero) + check_geom, check_minus_one, check_sized_string, check_string, check_zero, +) from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc # This is the return type used by binary output (WKB, HEX) routines. diff --git a/django/contrib/gis/geos/prototypes/io.py b/django/contrib/gis/geos/prototypes/io.py index 34bd34886a..55fd6d2f17 100644 --- a/django/contrib/gis/geos/prototypes/io.py +++ b/django/contrib/gis/geos/prototypes/io.py @@ -1,11 +1,13 @@ import threading -from ctypes import byref, c_char_p, c_int, c_char, c_size_t, Structure, POINTER +from ctypes import POINTER, Structure, byref, c_char, c_char_p, c_int, c_size_t + from django.contrib.gis.geos.base import GEOSBase from django.contrib.gis.geos.libgeos import GEOM_PTR -from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_string, check_sized_string +from django.contrib.gis.geos.prototypes.errcheck import ( + check_geom, check_sized_string, check_string, +) from django.contrib.gis.geos.prototypes.geom import c_uchar_p, geos_char_p from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc - from django.utils import six from django.utils.encoding import force_bytes diff --git a/django/contrib/gis/geos/prototypes/misc.py b/django/contrib/gis/geos/prototypes/misc.py index 0e62e916b0..9dba880f18 100644 --- a/django/contrib/gis/geos/prototypes/misc.py +++ b/django/contrib/gis/geos/prototypes/misc.py @@ -2,7 +2,8 @@ This module is for the miscellaneous GEOS routines, particularly the ones that return the area, distance, and length. """ -from ctypes import c_int, c_double, POINTER +from ctypes import POINTER, c_double, c_int + from django.contrib.gis.geos.libgeos import GEOM_PTR from django.contrib.gis.geos.prototypes.errcheck import check_dbl, check_string from django.contrib.gis.geos.prototypes.geom import geos_char_p diff --git a/django/contrib/gis/geos/prototypes/predicates.py b/django/contrib/gis/geos/prototypes/predicates.py index f3c30a5062..0146784d03 100644 --- a/django/contrib/gis/geos/prototypes/predicates.py +++ b/django/contrib/gis/geos/prototypes/predicates.py @@ -3,6 +3,7 @@ unary and binary predicate operations on geometries. """ from ctypes import c_char, c_char_p, c_double + from django.contrib.gis.geos.libgeos import GEOM_PTR from django.contrib.gis.geos.prototypes.errcheck import check_predicate from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc diff --git a/django/contrib/gis/geos/prototypes/prepared.py b/django/contrib/gis/geos/prototypes/prepared.py index ced56395b0..2c93e1eb2f 100644 --- a/django/contrib/gis/geos/prototypes/prepared.py +++ b/django/contrib/gis/geos/prototypes/prepared.py @@ -1,5 +1,8 @@ from ctypes import c_char -from django.contrib.gis.geos.libgeos import GEOM_PTR, PREPGEOM_PTR, geos_version_info + +from django.contrib.gis.geos.libgeos import ( + GEOM_PTR, PREPGEOM_PTR, geos_version_info, +) from django.contrib.gis.geos.prototypes.errcheck import check_predicate from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc diff --git a/django/contrib/gis/geos/prototypes/threadsafe.py b/django/contrib/gis/geos/prototypes/threadsafe.py index 61b13792bc..45c87d6004 100644 --- a/django/contrib/gis/geos/prototypes/threadsafe.py +++ b/django/contrib/gis/geos/prototypes/threadsafe.py @@ -1,5 +1,8 @@ import threading -from django.contrib.gis.geos.libgeos import lgeos, notice_h, error_h, CONTEXT_PTR + +from django.contrib.gis.geos.libgeos import ( + CONTEXT_PTR, error_h, lgeos, notice_h, +) class GEOSContextHandle(object): diff --git a/django/contrib/gis/geos/prototypes/topology.py b/django/contrib/gis/geos/prototypes/topology.py index 83d6706eaa..0e318409ee 100644 --- a/django/contrib/gis/geos/prototypes/topology.py +++ b/django/contrib/gis/geos/prototypes/topology.py @@ -11,8 +11,11 @@ __all__ = ['geos_boundary', 'geos_buffer', 'geos_cascaded_union', 'geos_interpolate_normalized'] from ctypes import c_double, c_int + from django.contrib.gis.geos.libgeos import GEOM_PTR -from django.contrib.gis.geos.prototypes.errcheck import check_geom, check_minus_one, check_string +from django.contrib.gis.geos.prototypes.errcheck import ( + check_geom, check_minus_one, check_string, +) from django.contrib.gis.geos.prototypes.geom import geos_char_p from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc diff --git a/django/contrib/gis/geos/tests/test_geos.py b/django/contrib/gis/geos/tests/test_geos.py index 48d4aabf13..4158faeaa7 100644 --- a/django/contrib/gis/geos/tests/test_geos.py +++ b/django/contrib/gis/geos/tests/test_geos.py @@ -4,16 +4,14 @@ import ctypes import json import random import unittest -from unittest import skipUnless from binascii import a2b_hex, b2a_hex from io import BytesIO +from unittest import skipUnless from django.contrib.gis.gdal import HAS_GDAL - from django.contrib.gis.geometry.test_data import TestDataMixin - -from django.utils.encoding import force_bytes from django.utils import six +from django.utils.encoding import force_bytes from django.utils.six.moves import range from .. import HAS_GEOS diff --git a/django/contrib/gis/geos/tests/test_io.py b/django/contrib/gis/geos/tests/test_io.py index 06ca76e33d..08ff6c13e8 100644 --- a/django/contrib/gis/geos/tests/test_io.py +++ b/django/contrib/gis/geos/tests/test_io.py @@ -6,7 +6,7 @@ from unittest import skipUnless from django.utils.six import memoryview -from ..import HAS_GEOS +from ..import HAS_GEOS # isort:skip if HAS_GEOS: from .. import GEOSGeometry, WKTReader, WKTWriter, WKBReader, WKBWriter diff --git a/django/contrib/gis/management/commands/inspectdb.py b/django/contrib/gis/management/commands/inspectdb.py index 502f816ea4..229be74276 100644 --- a/django/contrib/gis/management/commands/inspectdb.py +++ b/django/contrib/gis/management/commands/inspectdb.py @@ -1,4 +1,5 @@ -from django.core.management.commands.inspectdb import Command as InspectDBCommand +from django.core.management.commands.inspectdb import \ + Command as InspectDBCommand class Command(InspectDBCommand): diff --git a/django/contrib/gis/maps/google/gmap.py b/django/contrib/gis/maps/google/gmap.py index 845b39a806..d40c3b8218 100644 --- a/django/contrib/gis/maps/google/gmap.py +++ b/django/contrib/gis/maps/google/gmap.py @@ -1,13 +1,14 @@ from __future__ import unicode_literals from django.conf import settings +from django.contrib.gis.maps.google.overlays import ( + GMarker, GPolygon, GPolyline, +) from django.template.loader import render_to_string from django.utils.html import format_html from django.utils.safestring import mark_safe from django.utils.six.moves import range -from django.contrib.gis.maps.google.overlays import GPolygon, GPolyline, GMarker - class GoogleMapException(Exception): pass diff --git a/django/contrib/gis/maps/google/overlays.py b/django/contrib/gis/maps/google/overlays.py index d9ba31380a..f249e5d809 100644 --- a/django/contrib/gis/maps/google/overlays.py +++ b/django/contrib/gis/maps/google/overlays.py @@ -1,10 +1,12 @@ from __future__ import unicode_literals -from django.contrib.gis.geos import fromstr, Point, LineString, LinearRing, Polygon -from django.utils.functional import total_ordering -from django.utils.safestring import mark_safe +from django.contrib.gis.geos import ( + LinearRing, LineString, Point, Polygon, fromstr, +) from django.utils import six from django.utils.encoding import python_2_unicode_compatible +from django.utils.functional import total_ordering +from django.utils.safestring import mark_safe @python_2_unicode_compatible diff --git a/django/contrib/gis/maps/google/zoom.py b/django/contrib/gis/maps/google/zoom.py index a34748bb8e..d169fbd59b 100644 --- a/django/contrib/gis/maps/google/zoom.py +++ b/django/contrib/gis/maps/google/zoom.py @@ -1,9 +1,10 @@ from __future__ import unicode_literals -from django.contrib.gis.geos import GEOSGeometry, LinearRing, Polygon, Point +from math import atan, exp, log, pi, sin + +from django.contrib.gis.geos import GEOSGeometry, LinearRing, Point, Polygon from django.contrib.gis.maps.google.gmap import GoogleMapException from django.utils.six.moves import range -from math import pi, sin, log, exp, atan # Constants used for degree to radian conversion, and vice-versa. DTOR = pi / 180. diff --git a/django/contrib/gis/measure.py b/django/contrib/gis/measure.py index 90b316bb60..527512f71b 100644 --- a/django/contrib/gis/measure.py +++ b/django/contrib/gis/measure.py @@ -38,8 +38,8 @@ and Geoff Biggs' PhD work on dimensioned units for robotics. __all__ = ['A', 'Area', 'D', 'Distance'] from decimal import Decimal -from django.utils.functional import total_ordering from django.utils import six +from django.utils.functional import total_ordering NUMERIC_TYPES = six.integer_types + (float, Decimal) AREA_PREFIX = "sq_" diff --git a/django/contrib/gis/serializers/geojson.py b/django/contrib/gis/serializers/geojson.py index 573f85c045..eb0533bded 100644 --- a/django/contrib/gis/serializers/geojson.py +++ b/django/contrib/gis/serializers/geojson.py @@ -1,7 +1,9 @@ from __future__ import unicode_literals from django.contrib.gis.gdal import HAS_GDAL -from django.core.serializers.base import SerializerDoesNotExist, SerializationError +from django.core.serializers.base import ( + SerializationError, SerializerDoesNotExist, +) from django.core.serializers.json import Serializer as JSONSerializer if HAS_GDAL: diff --git a/django/contrib/gis/sitemaps/kml.py b/django/contrib/gis/sitemaps/kml.py index d052cf6350..4dcaa8f595 100644 --- a/django/contrib/gis/sitemaps/kml.py +++ b/django/contrib/gis/sitemaps/kml.py @@ -1,7 +1,7 @@ from django.apps import apps -from django.core import urlresolvers -from django.contrib.sitemaps import Sitemap from django.contrib.gis.db.models.fields import GeometryField +from django.contrib.sitemaps import Sitemap +from django.core import urlresolvers from django.db import models diff --git a/django/contrib/gis/sitemaps/views.py b/django/contrib/gis/sitemaps/views.py index a84621374b..dc5eb40441 100644 --- a/django/contrib/gis/sitemaps/views.py +++ b/django/contrib/gis/sitemaps/views.py @@ -1,11 +1,11 @@ from __future__ import unicode_literals from django.apps import apps -from django.http import Http404 from django.contrib.gis.db.models.fields import GeometryField from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz from django.core.exceptions import FieldDoesNotExist -from django.db import connections, DEFAULT_DB_ALIAS +from django.db import DEFAULT_DB_ALIAS, connections +from django.http import Http404 def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS): diff --git a/django/contrib/gis/tests/distapp/tests.py b/django/contrib/gis/tests/distapp/tests.py index 5f898e3dda..4c2ea60950 100644 --- a/django/contrib/gis/tests/distapp/tests.py +++ b/django/contrib/gis/tests/distapp/tests.py @@ -1,10 +1,12 @@ from __future__ import unicode_literals -from django.db import connection -from django.db.models import Q from django.contrib.gis.geos import HAS_GEOS from django.contrib.gis.measure import D # alias for Distance -from django.contrib.gis.tests.utils import oracle, postgis, spatialite, no_oracle +from django.contrib.gis.tests.utils import ( + no_oracle, oracle, postgis, spatialite, +) +from django.db import connection +from django.db.models import Q from django.test import TestCase, skipUnlessDBFeature if HAS_GEOS: diff --git a/django/contrib/gis/tests/geo3d/tests.py b/django/contrib/gis/tests/geo3d/tests.py index 9530cd9b55..022a8063ab 100644 --- a/django/contrib/gis/tests/geo3d/tests.py +++ b/django/contrib/gis/tests/geo3d/tests.py @@ -7,8 +7,8 @@ from unittest import skipUnless from django.contrib.gis.gdal import HAS_GDAL from django.contrib.gis.geos import HAS_GEOS from django.test import TestCase, ignore_warnings, skipUnlessDBFeature -from django.utils.deprecation import RemovedInDjango20Warning from django.utils._os import upath +from django.utils.deprecation import RemovedInDjango20Warning if HAS_GEOS: from django.contrib.gis.db.models import Union, Extent3D diff --git a/django/contrib/gis/tests/geoadmin/models.py b/django/contrib/gis/tests/geoadmin/models.py index 381a752570..cf8470e792 100644 --- a/django/contrib/gis/tests/geoadmin/models.py +++ b/django/contrib/gis/tests/geoadmin/models.py @@ -1,5 +1,5 @@ -from django.contrib.gis.db import models from django.contrib.gis import admin +from django.contrib.gis.db import models from django.utils.encoding import python_2_unicode_compatible diff --git a/django/contrib/gis/tests/geoapp/sitemaps.py b/django/contrib/gis/tests/geoapp/sitemaps.py index 16f1f0146e..1a3101290a 100644 --- a/django/contrib/gis/tests/geoapp/sitemaps.py +++ b/django/contrib/gis/tests/geoapp/sitemaps.py @@ -2,7 +2,6 @@ from django.contrib.gis.sitemaps import KMLSitemap, KMZSitemap from .models import City, Country - sitemaps = {'kml': KMLSitemap([City, Country]), 'kmz': KMZSitemap([City, Country]), } diff --git a/django/contrib/gis/tests/geoapp/test_feeds.py b/django/contrib/gis/tests/geoapp/test_feeds.py index 1b89823ecb..19a6f69b00 100644 --- a/django/contrib/gis/tests/geoapp/test_feeds.py +++ b/django/contrib/gis/tests/geoapp/test_feeds.py @@ -3,10 +3,10 @@ from __future__ import unicode_literals from xml.dom import minidom from django.conf import settings -from django.contrib.sites.models import Site from django.contrib.gis.geos import HAS_GEOS +from django.contrib.sites.models import Site from django.test import ( - TestCase, modify_settings, override_settings, skipUnlessDBFeature + TestCase, modify_settings, override_settings, skipUnlessDBFeature, ) if HAS_GEOS: diff --git a/django/contrib/gis/tests/geoapp/test_sitemaps.py b/django/contrib/gis/tests/geoapp/test_sitemaps.py index 4ef2bb9702..6a2d1f40b8 100644 --- a/django/contrib/gis/tests/geoapp/test_sitemaps.py +++ b/django/contrib/gis/tests/geoapp/test_sitemaps.py @@ -1,14 +1,15 @@ from __future__ import unicode_literals +import zipfile from io import BytesIO from xml.dom import minidom -import zipfile from django.conf import settings from django.contrib.gis.geos import HAS_GEOS from django.contrib.sites.models import Site from django.test import ( - TestCase, ignore_warnings, modify_settings, override_settings, skipUnlessDBFeature + TestCase, ignore_warnings, modify_settings, override_settings, + skipUnlessDBFeature, ) from django.utils.deprecation import RemovedInDjango20Warning diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py index 7c999a20d0..9b45492715 100644 --- a/django/contrib/gis/tests/geoapp/tests.py +++ b/django/contrib/gis/tests/geoapp/tests.py @@ -3,11 +3,13 @@ from __future__ import unicode_literals import re from tempfile import NamedTemporaryFile -from django.db import connection from django.contrib.gis import gdal from django.contrib.gis.geos import HAS_GEOS -from django.contrib.gis.tests.utils import no_oracle, oracle, postgis, spatialite +from django.contrib.gis.tests.utils import ( + no_oracle, oracle, postgis, spatialite, +) from django.core.management import call_command +from django.db import connection from django.test import TestCase, ignore_warnings, skipUnlessDBFeature from django.utils import six from django.utils.deprecation import RemovedInDjango20Warning diff --git a/django/contrib/gis/tests/geoapp/urls.py b/django/contrib/gis/tests/geoapp/urls.py index 238c64ad51..40a48053c7 100644 --- a/django/contrib/gis/tests/geoapp/urls.py +++ b/django/contrib/gis/tests/geoapp/urls.py @@ -2,13 +2,12 @@ from __future__ import unicode_literals from django.conf.urls import url from django.contrib.gis import views as gis_views -from django.contrib.sitemaps import views as sitemap_views from django.contrib.gis.sitemaps import views as gis_sitemap_views +from django.contrib.sitemaps import views as sitemap_views from .feeds import feed_dict from .sitemaps import sitemaps - urlpatterns = [ url(r'^feeds/(?P.*)/$', gis_views.feed, {'feed_dict': feed_dict}), ] diff --git a/django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py b/django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py index 212f702320..aceaaa301e 100644 --- a/django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py +++ b/django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py @@ -1,5 +1,5 @@ -from django.db import models, migrations import django.contrib.gis.db.models.fields +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/gis/tests/gis_migrations/test_commands.py b/django/contrib/gis/tests/gis_migrations/test_commands.py index bb0186fad5..076215465d 100644 --- a/django/contrib/gis/tests/gis_migrations/test_commands.py +++ b/django/contrib/gis/tests/gis_migrations/test_commands.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals from django.core.management import call_command from django.db import connection -from django.test import skipUnlessDBFeature, TransactionTestCase +from django.test import TransactionTestCase, skipUnlessDBFeature @skipUnlessDBFeature("gis_enabled") diff --git a/django/contrib/gis/tests/gis_migrations/test_operations.py b/django/contrib/gis/tests/gis_migrations/test_operations.py index 8052e7ab1d..9bfe55b0bf 100644 --- a/django/contrib/gis/tests/gis_migrations/test_operations.py +++ b/django/contrib/gis/tests/gis_migrations/test_operations.py @@ -4,7 +4,7 @@ from django.contrib.gis.tests.utils import mysql from django.db import connection, migrations, models from django.db.migrations.migration import Migration from django.db.migrations.state import ProjectState -from django.test import skipUnlessDBFeature, TransactionTestCase +from django.test import TransactionTestCase, skipUnlessDBFeature if connection.features.gis_enabled: from django.contrib.gis.db.models import fields diff --git a/django/contrib/gis/tests/inspectapp/tests.py b/django/contrib/gis/tests/inspectapp/tests.py index 82b2cfefd6..8e2f54c517 100644 --- a/django/contrib/gis/tests/inspectapp/tests.py +++ b/django/contrib/gis/tests/inspectapp/tests.py @@ -4,11 +4,11 @@ import os import re from unittest import skipUnless +from django.contrib.gis.gdal import HAS_GDAL +from django.contrib.gis.geometry.test_data import TEST_DATA from django.core.management import call_command from django.db import connection, connections from django.test import TestCase, skipUnlessDBFeature -from django.contrib.gis.gdal import HAS_GDAL -from django.contrib.gis.geometry.test_data import TEST_DATA from django.utils.six import StringIO if HAS_GDAL: diff --git a/django/contrib/gis/tests/layermap/tests.py b/django/contrib/gis/tests/layermap/tests.py index 45709e30ce..85f105f4a0 100644 --- a/django/contrib/gis/tests/layermap/tests.py +++ b/django/contrib/gis/tests/layermap/tests.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from copy import copy -from decimal import Decimal import os import unittest +from copy import copy +from decimal import Decimal from unittest import skipUnless +from django.conf import settings from django.contrib.gis.gdal import HAS_GDAL from django.db import connection -from django.conf import settings from django.test import TestCase, override_settings, skipUnlessDBFeature from django.utils._os import upath diff --git a/django/contrib/gis/tests/test_geoforms.py b/django/contrib/gis/tests/test_geoforms.py index fa72cd1fac..bcbb5f0804 100644 --- a/django/contrib/gis/tests/test_geoforms.py +++ b/django/contrib/gis/tests/test_geoforms.py @@ -1,7 +1,7 @@ from unittest import skipUnless -from django.forms import ValidationError from django.contrib.gis.gdal import HAS_GDAL +from django.forms import ValidationError from django.test import SimpleTestCase, skipUnlessDBFeature from django.utils import six from django.utils.html import escape diff --git a/django/contrib/gis/tests/test_measure.py b/django/contrib/gis/tests/test_measure.py index f6b89ce1ca..771c10fe9d 100644 --- a/django/contrib/gis/tests/test_measure.py +++ b/django/contrib/gis/tests/test_measure.py @@ -5,7 +5,7 @@ and conversions. Here are some tests. import unittest -from django.contrib.gis.measure import Distance, Area, D, A +from django.contrib.gis.measure import A, D, Area, Distance class DistanceTest(unittest.TestCase): diff --git a/django/contrib/gis/tests/test_spatialrefsys.py b/django/contrib/gis/tests/test_spatialrefsys.py index 7f43124e5d..1a4b151f2b 100644 --- a/django/contrib/gis/tests/test_spatialrefsys.py +++ b/django/contrib/gis/tests/test_spatialrefsys.py @@ -1,13 +1,13 @@ import unittest from django.contrib.gis.gdal import HAS_GDAL -from django.contrib.gis.tests.utils import (oracle, postgis, spatialite, - SpatialRefSys) +from django.contrib.gis.tests.utils import ( + SpatialRefSys, oracle, postgis, spatialite, +) from django.db import connection from django.test import skipUnlessDBFeature from django.utils import six - test_srs = ({ 'srid': 4326, 'auth_name': ('EPSG', True), diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py index 2ff23fc38b..30e773d69d 100644 --- a/django/contrib/gis/utils/layermapping.py +++ b/django/contrib/gis/utils/layermapping.py @@ -8,14 +8,17 @@ """ import sys from decimal import Decimal, InvalidOperation as DecimalInvalidOperation -from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist -from django.db import connections, router + from django.contrib.gis.db.models import GeometryField -from django.contrib.gis.gdal import (CoordTransform, DataSource, - GDALException, OGRGeometry, OGRGeomType, SpatialReference) +from django.contrib.gis.gdal import ( + CoordTransform, DataSource, GDALException, OGRGeometry, OGRGeomType, + SpatialReference, +) from django.contrib.gis.gdal.field import ( - OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime) -from django.db import models, transaction + OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime, +) +from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist +from django.db import connections, models, router, transaction from django.utils import six from django.utils.encoding import force_text diff --git a/django/contrib/gis/utils/ogrinspect.py b/django/contrib/gis/utils/ogrinspect.py index 16732556d4..9c9a4c7f8c 100644 --- a/django/contrib/gis/utils/ogrinspect.py +++ b/django/contrib/gis/utils/ogrinspect.py @@ -3,11 +3,12 @@ This module is for inspecting OGR data sources and generating either models for GeoDjango and/or mapping dictionaries for use with the `LayerMapping` utility. """ -from django.utils.six.moves import zip -# Requires GDAL to use. from django.contrib.gis.gdal import DataSource -from django.contrib.gis.gdal.field import OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime +from django.contrib.gis.gdal.field import ( + OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime, +) from django.utils import six +from django.utils.six.moves import zip def mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False): diff --git a/django/contrib/gis/utils/srs.py b/django/contrib/gis/utils/srs.py index 1460be2de9..59ba77c6dd 100644 --- a/django/contrib/gis/utils/srs.py +++ b/django/contrib/gis/utils/srs.py @@ -1,5 +1,5 @@ from django.contrib.gis.gdal import SpatialReference -from django.db import connections, DEFAULT_DB_ALIAS +from django.db import DEFAULT_DB_ALIAS, connections def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None, diff --git a/django/contrib/humanize/apps.py b/django/contrib/humanize/apps.py index 67b3012175..c518ee12df 100644 --- a/django/contrib/humanize/apps.py +++ b/django/contrib/humanize/apps.py @@ -1,5 +1,4 @@ from django.apps import AppConfig - from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py index 81c6d2a04c..bb9bc7b1ca 100644 --- a/django/contrib/humanize/templatetags/humanize.py +++ b/django/contrib/humanize/templatetags/humanize.py @@ -11,8 +11,8 @@ from django.template import defaultfilters from django.utils.encoding import force_text from django.utils.formats import number_format from django.utils.safestring import mark_safe -from django.utils.translation import pgettext, ungettext, ugettext as _ from django.utils.timezone import is_aware, utc +from django.utils.translation import pgettext, ugettext as _, ungettext register = template.Library() diff --git a/django/contrib/humanize/tests.py b/django/contrib/humanize/tests.py index a9882e479f..84528fd29d 100644 --- a/django/contrib/humanize/tests.py +++ b/django/contrib/humanize/tests.py @@ -1,21 +1,22 @@ from __future__ import unicode_literals + import datetime from decimal import Decimal from unittest import skipIf +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 1a9189383e..de48c8aa4d 100644 --- a/django/contrib/messages/apps.py +++ b/django/contrib/messages/apps.py @@ -1,5 +1,4 @@ from django.apps import AppConfig - from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/messages/storage/base.py b/django/contrib/messages/storage/base.py index 43dd3dbdd2..74f1ce7d9c 100644 --- a/django/contrib/messages/storage/base.py +++ b/django/contrib/messages/storage/base.py @@ -1,9 +1,8 @@ from __future__ import unicode_literals from django.conf import settings -from django.utils.encoding import force_text, python_2_unicode_compatible from django.contrib.messages import constants, utils - +from django.utils.encoding import force_text, python_2_unicode_compatible LEVEL_TAGS = utils.get_level_tags() diff --git a/django/contrib/messages/storage/cookie.py b/django/contrib/messages/storage/cookie.py index 71eee0cdfa..eb927411a7 100644 --- a/django/contrib/messages/storage/cookie.py +++ b/django/contrib/messages/storage/cookie.py @@ -3,9 +3,9 @@ import json from django.conf import settings from django.contrib.messages.storage.base import BaseStorage, Message from django.http import SimpleCookie -from django.utils.crypto import salted_hmac, constant_time_compare -from django.utils.safestring import SafeData, mark_safe from django.utils import six +from django.utils.crypto import constant_time_compare, salted_hmac +from django.utils.safestring import SafeData, mark_safe class MessageEncoder(json.JSONEncoder): diff --git a/django/contrib/messages/storage/session.py b/django/contrib/messages/storage/session.py index c3e293c22e..7903fb03c1 100644 --- a/django/contrib/messages/storage/session.py +++ b/django/contrib/messages/storage/session.py @@ -1,7 +1,9 @@ import json from django.contrib.messages.storage.base import BaseStorage -from django.contrib.messages.storage.cookie import MessageEncoder, MessageDecoder +from django.contrib.messages.storage.cookie import ( + MessageDecoder, MessageEncoder, +) from django.utils import six diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py index 139d32c067..d1f951789f 100644 --- a/django/contrib/messages/tests/base.py +++ b/django/contrib/messages/tests/base.py @@ -2,10 +2,10 @@ from unittest import skipUnless from django import http from django.apps import apps -from django.contrib.messages import constants, utils, get_level, set_level +from django.contrib.messages import constants, get_level, set_level, utils from django.contrib.messages.api import MessageFailure from django.contrib.messages.constants import DEFAULT_LEVELS -from django.contrib.messages.storage import default_storage, base +from django.contrib.messages.storage import base, default_storage from django.contrib.messages.storage.base import Message from django.core.urlresolvers import reverse from django.test import modify_settings, override_settings diff --git a/django/contrib/messages/tests/test_api.py b/django/contrib/messages/tests/test_api.py index 335a200450..f79db95866 100644 --- a/django/contrib/messages/tests/test_api.py +++ b/django/contrib/messages/tests/test_api.py @@ -1,6 +1,5 @@ -from django.test import TestCase, RequestFactory - from django.contrib import messages +from django.test import RequestFactory, TestCase class DummyStorage(object): diff --git a/django/contrib/messages/tests/test_cookie.py b/django/contrib/messages/tests/test_cookie.py index ba7b4dc08b..c986a174ca 100644 --- a/django/contrib/messages/tests/test_cookie.py +++ b/django/contrib/messages/tests/test_cookie.py @@ -1,10 +1,11 @@ import json from django.contrib.messages import constants -from django.contrib.messages.tests.base import BaseTests -from django.contrib.messages.storage.cookie import (CookieStorage, - MessageEncoder, MessageDecoder) from django.contrib.messages.storage.base import Message +from django.contrib.messages.storage.cookie import ( + CookieStorage, MessageDecoder, MessageEncoder, +) +from django.contrib.messages.tests.base import BaseTests from django.test import TestCase, override_settings from django.utils.safestring import SafeData, mark_safe diff --git a/django/contrib/messages/tests/test_fallback.py b/django/contrib/messages/tests/test_fallback.py index cd0b1888f3..0afbe75ae6 100644 --- a/django/contrib/messages/tests/test_fallback.py +++ b/django/contrib/messages/tests/test_fallback.py @@ -1,11 +1,14 @@ from django.contrib.messages import constants -from django.contrib.messages.storage.fallback import (FallbackStorage, - CookieStorage) +from django.contrib.messages.storage.fallback import ( + CookieStorage, FallbackStorage, +) from django.contrib.messages.tests.base import BaseTests -from django.contrib.messages.tests.test_cookie import (set_cookie_data, - stored_cookie_messages_count) -from django.contrib.messages.tests.test_session import (set_session_data, - stored_session_messages_count) +from django.contrib.messages.tests.test_cookie import ( + set_cookie_data, stored_cookie_messages_count, +) +from django.contrib.messages.tests.test_session import ( + set_session_data, stored_session_messages_count, +) from django.test import TestCase diff --git a/django/contrib/messages/tests/test_mixins.py b/django/contrib/messages/tests/test_mixins.py index 35bb86d057..bb0bb797d4 100644 --- a/django/contrib/messages/tests/test_mixins.py +++ b/django/contrib/messages/tests/test_mixins.py @@ -1,6 +1,6 @@ -from django.test import TestCase, override_settings from django.contrib.messages.tests.urls import ContactFormViewWithMsg from django.core.urlresolvers import reverse +from django.test import TestCase, override_settings @override_settings(ROOT_URLCONF='django.contrib.messages.tests.urls') diff --git a/django/contrib/messages/tests/test_session.py b/django/contrib/messages/tests/test_session.py index 940e1c02d0..cca659d3d8 100644 --- a/django/contrib/messages/tests/test_session.py +++ b/django/contrib/messages/tests/test_session.py @@ -1,9 +1,9 @@ from django.contrib.messages import constants -from django.contrib.messages.tests.base import BaseTests from django.contrib.messages.storage.base import Message from django.contrib.messages.storage.session import SessionStorage -from django.utils.safestring import SafeData, mark_safe +from django.contrib.messages.tests.base import BaseTests from django.test import TestCase +from django.utils.safestring import SafeData, mark_safe def set_session_data(storage, messages): diff --git a/django/contrib/messages/tests/urls.py b/django/contrib/messages/tests/urls.py index 43cc6063cb..d748690044 100644 --- a/django/contrib/messages/tests/urls.py +++ b/django/contrib/messages/tests/urls.py @@ -1,14 +1,15 @@ +from django import forms from django.conf.urls import url from django.contrib import messages +from django.contrib.messages.views import SuccessMessageMixin from django.core.urlresolvers import reverse -from django import forms -from django.http import HttpResponseRedirect, HttpResponse +from django.http import HttpResponse, HttpResponseRedirect from django.template import engines from django.template.response import TemplateResponse from django.views.decorators.cache import never_cache -from django.contrib.messages.views import SuccessMessageMixin from django.views.generic.edit import FormView + TEMPLATE = """{% if messages %}