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 efef0c9174..0cda55d8fa 100644 --- a/django/apps/registry.py +++ b/django/apps/registry.py @@ -1,13 +1,13 @@ -from collections import Counter, defaultdict, OrderedDict import os import sys import threading import warnings +from collections import Counter, OrderedDict, defaultdict from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured from django.utils import lru_cache -from django.utils.deprecation import RemovedInDjango19Warning from django.utils._os import upath +from django.utils.deprecation import RemovedInDjango19Warning from .config import AppConfig diff --git a/django/conf/project_template/project_name/settings.py b/django/conf/project_template/project_name/settings.py index a0a3056075..b3c629ec6e 100644 --- a/django/conf/project_template/project_name/settings.py +++ b/django/conf/project_template/project_name/settings.py @@ -12,6 +12,7 @@ https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/ # Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os + BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) diff --git a/django/conf/project_template/project_name/wsgi.py b/django/conf/project_template/project_name/wsgi.py index 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 39c27c1b25..7ea550ddd1 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -1,37 +1,42 @@ -from collections import OrderedDict import copy import operator -from functools import partial, reduce, update_wrapper import warnings +from collections import OrderedDict +from functools import partial, reduce, update_wrapper from django import forms from django.conf import settings from django.contrib import messages -from django.contrib.admin import widgets, helpers -from django.contrib.admin import validation -from django.contrib.admin.checks import (BaseModelAdminChecks, ModelAdminChecks, - InlineModelAdminChecks) +from django.contrib.admin import helpers, validation, widgets +from django.contrib.admin.checks import ( + BaseModelAdminChecks, InlineModelAdminChecks, ModelAdminChecks, +) from django.contrib.admin.exceptions import DisallowedModelAdminToField -from django.contrib.admin.utils import (quote, unquote, flatten_fieldsets, - get_deleted_objects, model_format_dict, NestedObjects, - lookup_needs_distinct) from django.contrib.admin.templatetags.admin_static import static from django.contrib.admin.templatetags.admin_urls import add_preserved_filters +from django.contrib.admin.utils import ( + NestedObjects, flatten_fieldsets, get_deleted_objects, + lookup_needs_distinct, model_format_dict, quote, unquote, +) from django.contrib.auth import get_permission_codename from django.core import checks -from django.core.exceptions import (PermissionDenied, ValidationError, - FieldDoesNotExist, FieldError, ImproperlyConfigured) +from django.core.exceptions import ( + FieldDoesNotExist, FieldError, ImproperlyConfigured, PermissionDenied, + ValidationError, +) from django.core.paginator import Paginator from django.core.urlresolvers import reverse -from django.db import models, transaction, router +from django.db import models, router, transaction from django.db.models.constants import LOOKUP_SEP from django.db.models.fields import BLANK_CHOICE_DASH from django.db.models.fields.related import ForeignObjectRel from django.db.models.sql.constants import QUERY_TERMS -from django.forms.formsets import all_valid, DELETION_FIELD_NAME -from django.forms.models import (modelform_factory, modelformset_factory, - inlineformset_factory, BaseInlineFormSet, modelform_defines_fields) -from django.forms.widgets import SelectMultiple, CheckboxSelectMultiple +from django.forms.formsets import DELETION_FIELD_NAME, all_valid +from django.forms.models import ( + BaseInlineFormSet, inlineformset_factory, modelform_defines_fields, + modelform_factory, modelformset_factory, +) +from django.forms.widgets import CheckboxSelectMultiple, SelectMultiple from django.http import Http404, HttpResponseRedirect from django.http.response import HttpResponseBase from django.shortcuts import get_object_or_404 @@ -42,14 +47,11 @@ from django.utils.deprecation import RemovedInDjango19Warning from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.html import escape, escapejs from django.utils.http import urlencode -from django.utils.text import capfirst, get_text_list -from django.utils.translation import string_concat -from django.utils.translation import ugettext as _ -from django.utils.translation import ungettext from django.utils.safestring import mark_safe +from django.utils.text import capfirst, get_text_list +from django.utils.translation import string_concat, ugettext as _, ungettext from django.views.decorators.csrf import csrf_protect - IS_POPUP_VAR = '_popup' TO_FIELD_VAR = '_to_field' diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py index bcd05ed800..af408806ae 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/util.py b/django/contrib/admin/util.py index 416b75e7b2..94f0dd2f4d 100644 --- a/django/contrib/admin/util.py +++ b/django/contrib/admin/util.py @@ -6,4 +6,4 @@ warnings.warn( "The django.contrib.admin.util module has been renamed. " "Use django.contrib.admin.utils instead.", RemovedInDjango19Warning) -from django.contrib.admin.utils import * # NOQA +from django.contrib.admin.utils import * # NOQA isort:skip diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py index 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/validation.py b/django/contrib/admin/validation.py index 67b97f776e..fab31663e9 100644 --- a/django/contrib/admin/validation.py +++ b/django/contrib/admin/validation.py @@ -1,7 +1,9 @@ +from django.contrib.admin.utils import NotRelationField, get_fields_from_path from django.core.exceptions import FieldDoesNotExist, ImproperlyConfigured from django.db import models -from django.forms.models import BaseModelForm, BaseModelFormSet, _get_foreign_key -from django.contrib.admin.utils import get_fields_from_path, NotRelationField +from django.forms.models import ( + BaseModelForm, BaseModelFormSet, _get_foreign_key, +) """ Does basic ModelAdmin option validation. Calls custom validation diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index 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 2df33c3c86..928236914a 100644 --- a/django/contrib/auth/admin.py +++ b/django/contrib/auth/admin.py @@ -1,19 +1,19 @@ -from django.db import transaction from django.conf import settings from django.conf.urls import url -from django.contrib import admin +from django.contrib import admin, messages from django.contrib.admin.options import IS_POPUP_VAR from django.contrib.auth import update_session_auth_hash -from django.contrib.auth.forms import (UserCreationForm, UserChangeForm, - AdminPasswordChangeForm) -from django.contrib.auth.models import User, Group -from django.contrib import messages +from django.contrib.auth.forms import ( + AdminPasswordChangeForm, UserChangeForm, UserCreationForm, +) +from django.contrib.auth.models import Group, User from django.core.exceptions import PermissionDenied -from django.http import HttpResponseRedirect, Http404 +from django.db import transaction +from django.http import Http404, HttpResponseRedirect from django.shortcuts import get_object_or_404 from django.template.response import TemplateResponse -from django.utils.html import escape from django.utils.decorators import method_decorator +from django.utils.html import escape from django.utils.translation import ugettext, ugettext_lazy as _ from django.views.decorators.csrf import csrf_protect from django.views.decorators.debug import sensitive_post_parameters diff --git a/django/contrib/auth/apps.py b/django/contrib/auth/apps.py index bbfcb7dbd1..109a34dff6 100644 --- a/django/contrib/auth/apps.py +++ b/django/contrib/auth/apps.py @@ -1,6 +1,6 @@ from django.apps import AppConfig -from django.core import checks from django.contrib.auth.checks import check_user_model +from django.core import checks from django.db.models.signals import post_migrate from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py index 00a772fd4f..9f08259038 100644 --- a/django/contrib/auth/backends.py +++ b/django/contrib/auth/backends.py @@ -1,4 +1,5 @@ from __future__ import unicode_literals + from django.contrib.auth import get_user_model from django.contrib.auth.models import Permission diff --git a/django/contrib/auth/decorators.py b/django/contrib/auth/decorators.py index 99e2983e63..9b2504b33c 100644 --- a/django/contrib/auth/decorators.py +++ b/django/contrib/auth/decorators.py @@ -1,10 +1,11 @@ from functools import wraps + from django.conf import settings from django.contrib.auth import REDIRECT_FIELD_NAME from django.core.exceptions import PermissionDenied +from django.shortcuts import resolve_url from django.utils.decorators import available_attrs from django.utils.six.moves.urllib.parse import urlparse -from django.shortcuts import resolve_url def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py index 3d19b2247e..cc3be5ba0b 100644 --- a/django/contrib/auth/forms.py +++ b/django/contrib/auth/forms.py @@ -3,6 +3,13 @@ from __future__ import unicode_literals from collections import OrderedDict from django import forms +from django.contrib.auth import authenticate, get_user_model +from django.contrib.auth.hashers import ( + UNUSABLE_PASSWORD_PREFIX, identify_hasher, +) +from django.contrib.auth.models import User +from django.contrib.auth.tokens import default_token_generator +from django.contrib.sites.shortcuts import get_current_site from django.core.mail import EmailMultiAlternatives from django.forms.utils import flatatt from django.template import loader @@ -13,12 +20,6 @@ from django.utils.safestring import mark_safe from django.utils.text import capfirst from django.utils.translation import ugettext, ugettext_lazy as _ -from django.contrib.auth import authenticate, get_user_model -from django.contrib.auth.models import User -from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX, identify_hasher -from django.contrib.auth.tokens import default_token_generator -from django.contrib.sites.shortcuts import get_current_site - class ReadOnlyPasswordHashWidget(forms.Widget): def render(self, name, value, attrs): diff --git a/django/contrib/auth/handlers/modwsgi.py b/django/contrib/auth/handlers/modwsgi.py index 8ada9750f1..6b91ed9c6e 100644 --- a/django/contrib/auth/handlers/modwsgi.py +++ b/django/contrib/auth/handlers/modwsgi.py @@ -1,5 +1,5 @@ -from django.contrib import auth from django import db +from django.contrib import auth from django.utils.encoding import force_bytes diff --git a/django/contrib/auth/hashers.py b/django/contrib/auth/hashers.py index 9a85ebbbad..f7f143b78f 100644 --- a/django/contrib/auth/hashers.py +++ b/django/contrib/auth/hashers.py @@ -2,22 +2,22 @@ from __future__ import unicode_literals import base64 import binascii -from collections import OrderedDict import hashlib import importlib +from collections import OrderedDict -from django.dispatch import receiver from django.conf import settings -from django.core.signals import setting_changed -from django.utils.encoding import force_bytes, force_str, force_text from django.core.exceptions import ImproperlyConfigured -from django.utils.crypto import ( - pbkdf2, constant_time_compare, get_random_string) +from django.core.signals import setting_changed +from django.dispatch import receiver from django.utils import lru_cache +from django.utils.crypto import ( + constant_time_compare, get_random_string, pbkdf2, +) +from django.utils.encoding import force_bytes, force_str, force_text from django.utils.module_loading import import_string from django.utils.translation import ugettext_noop as _ - UNUSABLE_PASSWORD_PREFIX = '!' # This will never be a valid encoded hash UNUSABLE_PASSWORD_SUFFIX_LENGTH = 40 # number of random chars to add after UNUSABLE_PASSWORD_PREFIX diff --git a/django/contrib/auth/migrations/0001_initial.py b/django/contrib/auth/migrations/0001_initial.py index 33c8e00153..a58f73ab1a 100644 --- a/django/contrib/auth/migrations/0001_initial.py +++ b/django/contrib/auth/migrations/0001_initial.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -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..ae14d1538c 100644 --- a/django/contrib/auth/tests/backend_alias.py +++ b/django/contrib/auth/tests/backend_alias.py @@ -1,2 +1,4 @@ # For testing that auth backends can be referenced using a convenience import -from django.contrib.auth.tests.test_auth_backends import ImportedModelBackend # NOQA +from .test_auth_backends import ImportedModelBackend + +__all__ = ['ImportedModelBackend'] diff --git a/django/contrib/auth/tests/custom_user.py b/django/contrib/auth/tests/custom_user.py index c856431bba..e7ce6162e9 100644 --- a/django/contrib/auth/tests/custom_user.py +++ b/django/contrib/auth/tests/custom_user.py @@ -1,13 +1,8 @@ -from django.db import models from django.contrib.auth.models import ( - BaseUserManager, - AbstractBaseUser, - AbstractUser, - UserManager, - PermissionsMixin, - Group, - Permission, + AbstractBaseUser, AbstractUser, BaseUserManager, Group, Permission, + PermissionsMixin, UserManager, ) +from django.db import models # The custom User uses email as the unique identifier, and requires diff --git a/django/contrib/auth/tests/settings.py b/django/contrib/auth/tests/settings.py index ce2aa7d152..6fd02261de 100644 --- a/django/contrib/auth/tests/settings.py +++ b/django/contrib/auth/tests/settings.py @@ -2,7 +2,6 @@ import os from django.utils._os import upath - AUTH_MIDDLEWARE_CLASSES = ( 'django.contrib.sessions.middleware.SessionMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', diff --git a/django/contrib/auth/tests/test_auth_backends.py b/django/contrib/auth/tests/test_auth_backends.py index d3b6c5de0c..8ccb6287e8 100644 --- a/django/contrib/auth/tests/test_auth_backends.py +++ b/django/contrib/auth/tests/test_auth_backends.py @@ -1,17 +1,20 @@ from __future__ import unicode_literals + from datetime import date from django.conf import settings +from django.contrib.auth import BACKEND_SESSION_KEY, authenticate, get_user from django.contrib.auth.backends import ModelBackend -from django.contrib.auth.models import User, Group, Permission, AnonymousUser +from django.contrib.auth.hashers import MD5PasswordHasher +from django.contrib.auth.models import AnonymousUser, Group, Permission, User +from django.contrib.auth.tests.custom_user import ( + CustomPermissionsUser, CustomUser, ExtensionUser, +) from django.contrib.auth.tests.utils import skipIfCustomUser -from django.contrib.auth.tests.custom_user import ExtensionUser, CustomPermissionsUser, CustomUser from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ImproperlyConfigured, PermissionDenied -from django.contrib.auth import authenticate, BACKEND_SESSION_KEY, get_user from django.http import HttpRequest from django.test import TestCase, override_settings -from django.contrib.auth.hashers import MD5PasswordHasher class CountingMD5PasswordHasher(MD5PasswordHasher): diff --git a/django/contrib/auth/tests/test_basic.py b/django/contrib/auth/tests/test_basic.py index fed94db82f..ca7db755e6 100644 --- a/django/contrib/auth/tests/test_basic.py +++ b/django/contrib/auth/tests/test_basic.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals from django.apps import apps from django.contrib.auth import get_user_model -from django.contrib.auth.models import User, AnonymousUser +from django.contrib.auth.models import AnonymousUser, User from django.contrib.auth.tests.custom_user import CustomUser from django.contrib.auth.tests.utils import skipIfCustomUser from django.core.exceptions import ImproperlyConfigured diff --git a/django/contrib/auth/tests/test_context_processors.py b/django/contrib/auth/tests/test_context_processors.py index f96eac9db7..bb3c1820f6 100644 --- a/django/contrib/auth/tests/test_context_processors.py +++ b/django/contrib/auth/tests/test_context_processors.py @@ -1,7 +1,7 @@ from django.contrib.auth import authenticate -from django.contrib.auth.models import User, Permission +from django.contrib.auth.context_processors import PermLookupDict, PermWrapper +from django.contrib.auth.models import Permission, User from django.contrib.contenttypes.models import ContentType -from django.contrib.auth.context_processors import PermWrapper, PermLookupDict from django.db.models import Q from django.test import TestCase, override_settings diff --git a/django/contrib/auth/tests/test_forms.py b/django/contrib/auth/tests/test_forms.py index 93ce9ad073..4628840400 100644 --- a/django/contrib/auth/tests/test_forms.py +++ b/django/contrib/auth/tests/test_forms.py @@ -3,16 +3,18 @@ from __future__ import unicode_literals import re from django import forms +from django.contrib.auth.forms import ( + AuthenticationForm, PasswordChangeForm, PasswordResetForm, + ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget, SetPasswordForm, + UserChangeForm, UserCreationForm, +) from django.contrib.auth.models import User -from django.contrib.auth.forms import (UserCreationForm, AuthenticationForm, - PasswordChangeForm, SetPasswordForm, UserChangeForm, PasswordResetForm, - ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget) from django.core import mail from django.core.mail import EmailMultiAlternatives -from django.forms.fields import Field, CharField +from django.forms.fields import CharField, Field from django.test import TestCase, override_settings -from django.utils.encoding import force_text from django.utils import translation +from django.utils.encoding import force_text from django.utils.text import capfirst from django.utils.translation import ugettext as _ diff --git a/django/contrib/auth/tests/test_handlers.py b/django/contrib/auth/tests/test_handlers.py index f4fa3030de..a6a4f9cd06 100644 --- a/django/contrib/auth/tests/test_handlers.py +++ b/django/contrib/auth/tests/test_handlers.py @@ -1,11 +1,12 @@ from __future__ import unicode_literals -from django.contrib.auth.handlers.modwsgi import check_password, groups_for_user -from django.contrib.auth.models import User, Group +from django.contrib.auth.handlers.modwsgi import ( + check_password, groups_for_user, +) +from django.contrib.auth.models import Group, User from django.contrib.auth.tests.custom_user import CustomUser from django.contrib.auth.tests.utils import skipIfCustomUser -from django.test import TransactionTestCase -from django.test import override_settings +from django.test import TransactionTestCase, override_settings # This must be a TransactionTestCase because the WSGI auth handler performs diff --git a/django/contrib/auth/tests/test_hashers.py b/django/contrib/auth/tests/test_hashers.py index 0c280ae158..de5d9233b3 100644 --- a/django/contrib/auth/tests/test_hashers.py +++ b/django/contrib/auth/tests/test_hashers.py @@ -4,14 +4,16 @@ from __future__ import unicode_literals from unittest import skipUnless from django.conf.global_settings import PASSWORD_HASHERS -from django.contrib.auth.hashers import (is_password_usable, BasePasswordHasher, - check_password, make_password, PBKDF2PasswordHasher, PBKDF2SHA1PasswordHasher, - get_hasher, identify_hasher, UNUSABLE_PASSWORD_PREFIX, UNUSABLE_PASSWORD_SUFFIX_LENGTH) +from django.contrib.auth.hashers import ( + UNUSABLE_PASSWORD_PREFIX, UNUSABLE_PASSWORD_SUFFIX_LENGTH, + BasePasswordHasher, PBKDF2PasswordHasher, PBKDF2SHA1PasswordHasher, + check_password, get_hasher, identify_hasher, is_password_usable, + make_password, +) from django.test import SimpleTestCase from django.test.utils import override_settings from django.utils import six - try: import crypt except ImportError: diff --git a/django/contrib/auth/tests/test_management.py b/django/contrib/auth/tests/test_management.py index 3d2aaceee9..6a395bbe7b 100644 --- a/django/contrib/auth/tests/test_management.py +++ b/django/contrib/auth/tests/test_management.py @@ -1,20 +1,23 @@ from __future__ import unicode_literals -from datetime import date import locale import sys +from datetime import date from django.apps import apps -from django.contrib.auth import models, management +from django.contrib.auth import management, models from django.contrib.auth.checks import check_user_model from django.contrib.auth.management import create_permissions -from django.contrib.auth.management.commands import changepassword, createsuperuser -from django.contrib.auth.models import User, Group -from django.contrib.auth.tests.custom_user import CustomUser, CustomUserWithFK, Email +from django.contrib.auth.management.commands import ( + changepassword, createsuperuser, +) +from django.contrib.auth.models import Group, User +from django.contrib.auth.tests.custom_user import ( + CustomUser, CustomUserWithFK, Email, +) from django.contrib.auth.tests.utils import skipIfCustomUser from django.contrib.contenttypes.models import ContentType -from django.core import checks -from django.core import exceptions +from django.core import checks, exceptions from django.core.management import call_command from django.core.management.base import CommandError from django.test import TestCase, override_settings, override_system_checks diff --git a/django/contrib/auth/tests/test_models.py b/django/contrib/auth/tests/test_models.py index b0a35a445a..ee51b15a98 100644 --- a/django/contrib/auth/tests/test_models.py +++ b/django/contrib/auth/tests/test_models.py @@ -1,5 +1,7 @@ from django.contrib.auth import get_user_model -from django.contrib.auth.models import AbstractUser, Group, Permission, User, UserManager +from django.contrib.auth.models import ( + AbstractUser, Group, Permission, User, UserManager, +) from django.contrib.auth.tests.utils import skipIfCustomUser from django.contrib.contenttypes.models import ContentType from django.core import mail diff --git a/django/contrib/auth/tests/test_signals.py b/django/contrib/auth/tests/test_signals.py index 04c5b89e0b..0f099c53be 100644 --- a/django/contrib/auth/tests/test_signals.py +++ b/django/contrib/auth/tests/test_signals.py @@ -1,9 +1,8 @@ from django.contrib.auth import signals from django.contrib.auth.models import User from django.contrib.auth.tests.utils import skipIfCustomUser -from django.test import TestCase +from django.test import TestCase, override_settings from django.test.client import RequestFactory -from django.test import override_settings @skipIfCustomUser diff --git a/django/contrib/auth/tests/test_templates.py b/django/contrib/auth/tests/test_templates.py index e2bb466d68..607db8764e 100644 --- a/django/contrib/auth/tests/test_templates.py +++ b/django/contrib/auth/tests/test_templates.py @@ -3,11 +3,10 @@ from django.contrib.auth.models import User from django.contrib.auth.tests.utils import skipIfCustomUser from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.contrib.auth.views import ( - password_reset, password_reset_done, password_reset_confirm, - password_reset_complete, password_change, password_change_done, + password_change, password_change_done, password_reset, + password_reset_complete, password_reset_confirm, password_reset_done, ) -from django.test import RequestFactory, TestCase -from django.test import override_settings +from django.test import RequestFactory, TestCase, override_settings from django.utils.encoding import force_bytes, force_text from django.utils.http import urlsafe_base64_encode diff --git a/django/contrib/auth/tests/test_tokens.py b/django/contrib/auth/tests/test_tokens.py index 583546ab3a..b9433bdcfa 100644 --- a/django/contrib/auth/tests/test_tokens.py +++ b/django/contrib/auth/tests/test_tokens.py @@ -1,11 +1,11 @@ -from datetime import date, timedelta import sys import unittest +from datetime import date, timedelta from django.conf import settings from django.contrib.auth.models import User -from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.contrib.auth.tests.utils import skipIfCustomUser +from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.test import TestCase diff --git a/django/contrib/auth/tests/test_views.py b/django/contrib/auth/tests/test_views.py index e5538517d0..76a97b5623 100644 --- a/django/contrib/auth/tests/test_views.py +++ b/django/contrib/auth/tests/test_views.py @@ -1,31 +1,32 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from importlib import import_module import itertools import re +from importlib import import_module from django.apps import apps from django.conf import settings -from django.contrib.sites.requests import RequestSite from django.contrib.admin.models import LogEntry -from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME -from django.contrib.auth.forms import (AuthenticationForm, PasswordChangeForm, - SetPasswordForm) +from django.contrib.auth import REDIRECT_FIELD_NAME, SESSION_KEY +from django.contrib.auth.forms import ( + AuthenticationForm, PasswordChangeForm, SetPasswordForm, +) from django.contrib.auth.models import User from django.contrib.auth.views import login as login_view, redirect_to_login +from django.contrib.sessions.middleware import SessionMiddleware +from django.contrib.sites.requests import RequestSite from django.core import mail from django.core.urlresolvers import NoReverseMatch, reverse, reverse_lazy -from django.http import QueryDict, HttpRequest +from django.http import HttpRequest, QueryDict +from django.middleware.csrf import CsrfViewMiddleware +from django.test import TestCase, ignore_warnings, override_settings +from django.test.utils import patch_logger from django.utils.deprecation import RemovedInDjango20Warning from django.utils.encoding import force_text from django.utils.http import urlquote -from django.utils.six.moves.urllib.parse import urlparse, ParseResult +from django.utils.six.moves.urllib.parse import ParseResult, urlparse from django.utils.translation import LANGUAGE_SESSION_KEY -from django.test import TestCase, ignore_warnings, override_settings -from django.test.utils import patch_logger -from django.middleware.csrf import CsrfViewMiddleware -from django.contrib.sessions.middleware import SessionMiddleware # Needed so model is installed when tests are run independently: from .custom_user import CustomUser # NOQA diff --git a/django/contrib/auth/tests/urls.py b/django/contrib/auth/tests/urls.py index 41e742a93b..6f83e0f420 100644 --- a/django/contrib/auth/tests/urls.py +++ b/django/contrib/auth/tests/urls.py @@ -1,13 +1,13 @@ -from django.conf.urls import url, include +from django.conf.urls import include, url from django.contrib import admin -from django.contrib.auth.forms import AuthenticationForm -from django.contrib.auth.urls import urlpatterns from django.contrib.auth import views from django.contrib.auth.decorators import login_required +from django.contrib.auth.forms import AuthenticationForm +from django.contrib.auth.urls import urlpatterns from django.contrib.messages.api import info -from django.http import HttpResponse, HttpRequest +from django.http import HttpRequest, HttpResponse from django.shortcuts import render -from django.template import Template, RequestContext +from django.template import RequestContext, Template from django.views.decorators.cache import never_cache diff --git a/django/contrib/auth/tests/urls_admin.py b/django/contrib/auth/tests/urls_admin.py index 49d6f38447..8d2fe3fd10 100644 --- a/django/contrib/auth/tests/urls_admin.py +++ b/django/contrib/auth/tests/urls_admin.py @@ -4,8 +4,8 @@ Test URLs for auth admins. from django.conf.urls import include, url from django.contrib import admin -from django.contrib.auth.admin import UserAdmin, GroupAdmin -from django.contrib.auth.models import User, Group +from django.contrib.auth.admin import GroupAdmin, UserAdmin +from django.contrib.auth.models import Group, User from django.contrib.auth.urls import urlpatterns # Create a silo'd admin site for just the user/group admins. diff --git a/django/contrib/auth/tokens.py b/django/contrib/auth/tokens.py index 89100daeb2..b925c21eff 100644 --- a/django/contrib/auth/tokens.py +++ b/django/contrib/auth/tokens.py @@ -1,8 +1,9 @@ from datetime import date + from django.conf import settings -from django.utils.http import int_to_base36, base36_to_int -from django.utils.crypto import constant_time_compare, salted_hmac from django.utils import six +from django.utils.crypto import constant_time_compare, salted_hmac +from django.utils.http import base36_to_int, int_to_base36 class PasswordResetTokenGenerator(object): diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py index 348fca8745..de76157bdc 100644 --- a/django/contrib/auth/views.py +++ b/django/contrib/auth/views.py @@ -1,25 +1,28 @@ import warnings from django.conf import settings +# Avoid shadowing the login() and logout() views below. +from django.contrib.auth import ( + REDIRECT_FIELD_NAME, get_user_model, login as auth_login, + logout as auth_logout, update_session_auth_hash, +) +from django.contrib.auth.decorators import login_required +from django.contrib.auth.forms import ( + AuthenticationForm, PasswordChangeForm, PasswordResetForm, SetPasswordForm, +) +from django.contrib.auth.tokens import default_token_generator +from django.contrib.sites.shortcuts import get_current_site from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, QueryDict +from django.shortcuts import resolve_url from django.template.response import TemplateResponse from django.utils.deprecation import RemovedInDjango20Warning from django.utils.http import is_safe_url, urlsafe_base64_decode -from django.utils.translation import ugettext as _ from django.utils.six.moves.urllib.parse import urlparse, urlunparse -from django.shortcuts import resolve_url -from django.views.decorators.debug import sensitive_post_parameters +from django.utils.translation import ugettext as _ from django.views.decorators.cache import never_cache from django.views.decorators.csrf import csrf_protect - -# Avoid shadowing the login() and logout() views below. -from django.contrib.auth import (REDIRECT_FIELD_NAME, login as auth_login, - logout as auth_logout, get_user_model, update_session_auth_hash) -from django.contrib.auth.decorators import login_required -from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm, SetPasswordForm, PasswordChangeForm -from django.contrib.auth.tokens import default_token_generator -from django.contrib.sites.shortcuts import get_current_site +from django.views.decorators.debug import sensitive_post_parameters @sensitive_post_parameters() 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 fba8e0c222..7bd9b79415 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/generic.py b/django/contrib/contenttypes/generic.py index 19622d33d8..92df783d02 100644 --- a/django/contrib/contenttypes/generic.py +++ b/django/contrib/contenttypes/generic.py @@ -10,12 +10,12 @@ warnings.warn( 'submodules of django.contrib.contenttypes.'), RemovedInDjango19Warning, stacklevel=2 ) -from django.contrib.contenttypes.admin import ( # NOQA - GenericInlineModelAdmin, GenericStackedInline, GenericTabularInline +from django.contrib.contenttypes.admin import ( # NOQA isort:skip + GenericInlineModelAdmin, GenericStackedInline, GenericTabularInline, ) -from django.contrib.contenttypes.fields import ( # NOQA - GenericForeignKey, GenericRelation +from django.contrib.contenttypes.fields import ( # NOQA isort:skip + GenericForeignKey, GenericRelation, ) -from django.contrib.contenttypes.forms import ( # NOQA - BaseGenericInlineFormSet, generic_inlineformset_factory +from django.contrib.contenttypes.forms import ( # NOQA isort:skip + BaseGenericInlineFormSet, generic_inlineformset_factory, ) diff --git a/django/contrib/contenttypes/migrations/0001_initial.py b/django/contrib/contenttypes/migrations/0001_initial.py index 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 5ce9b395f1..8e4dae3b37 100644 --- a/django/contrib/contenttypes/tests/tests.py +++ b/django/contrib/contenttypes/tests/tests.py @@ -9,7 +9,10 @@ from django.http import Http404, HttpRequest from django.test import TestCase, override_settings from django.utils import six -from .models import ConcreteModel, ProxyModel, FooWithoutUrl, FooWithUrl, FooWithBrokenAbsoluteUrl +from .models import ( + ConcreteModel, FooWithBrokenAbsoluteUrl, FooWithoutUrl, FooWithUrl, + ProxyModel, +) class ContentTypesTests(TestCase): diff --git a/django/contrib/flatpages/admin.py b/django/contrib/flatpages/admin.py index 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 7b35f621fd..e661b12c7a 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 f771adbafb..21d90da32e 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 62702d1ffe..9fb339ee26 100644 --- a/django/contrib/gis/db/backends/mysql/base.py +++ b/django/contrib/gis/db/backends/mysql/base.py @@ -1,4 +1,5 @@ -from django.db.backends.mysql.base import DatabaseWrapper as MySQLDatabaseWrapper +from django.db.backends.mysql.base import \ + DatabaseWrapper as MySQLDatabaseWrapper from .creation import MySQLCreation from .features import DatabaseFeatures diff --git a/django/contrib/gis/db/backends/mysql/features.py b/django/contrib/gis/db/backends/mysql/features.py index 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 9d7ab7debd..cfc88ea3e1 100644 --- a/django/contrib/gis/db/backends/oracle/base.py +++ b/django/contrib/gis/db/backends/oracle/base.py @@ -1,4 +1,5 @@ -from django.db.backends.oracle.base import DatabaseWrapper as OracleDatabaseWrapper +from django.db.backends.oracle.base import \ + DatabaseWrapper as OracleDatabaseWrapper from .creation import OracleCreation from .features import DatabaseFeatures diff --git a/django/contrib/gis/db/backends/oracle/features.py b/django/contrib/gis/db/backends/oracle/features.py index 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/backends/util.py b/django/contrib/gis/db/backends/util.py index 08f1ca8d80..64568eb5cb 100644 --- a/django/contrib/gis/db/backends/util.py +++ b/django/contrib/gis/db/backends/util.py @@ -7,4 +7,4 @@ warnings.warn( "Use django.contrib.gis.db.backends.utils instead.", RemovedInDjango19Warning, stacklevel=2) -from django.contrib.gis.db.backends.utils import * # NOQA +from django.contrib.gis.db.backends.utils import * # NOQA isort:skip diff --git a/django/contrib/gis/db/models/aggregates.py b/django/contrib/gis/db/models/aggregates.py index 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 acfb0915dd..df26b8b9f8 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 6e231a8607..f287c778da 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..ea64a716c3 100644 --- a/django/contrib/gis/forms/fields.py +++ b/django/contrib/gis/forms/fields.py @@ -1,11 +1,11 @@ from __future__ import unicode_literals from django import forms -from django.utils.translation import ugettext_lazy as _ - # While this couples the geographic forms to the GEOS library, # it decouples from database (by not importing SpatialBackend). from django.contrib.gis.geos import GEOSException, GEOSGeometry +from django.utils.translation import ugettext_lazy as _ + from .widgets import OpenLayersWidget diff --git a/django/contrib/gis/forms/widgets.py b/django/contrib/gis/forms/widgets.py index 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 7fa9d83e12..f5349f4480 100644 --- a/django/contrib/gis/gdal/datasource.py +++ b/django/contrib/gis/gdal/datasource.py @@ -41,12 +41,10 @@ from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.driver import Driver from django.contrib.gis.gdal.error import GDALException, OGRIndexError from django.contrib.gis.gdal.layer import Layer - # Getting the ctypes prototypes for the DataSource. from django.contrib.gis.gdal.prototypes import ds as capi - -from django.utils.encoding import force_bytes, force_text from django.utils import six +from django.utils.encoding import force_bytes, force_text from django.utils.six.moves import range diff --git a/django/contrib/gis/gdal/driver.py b/django/contrib/gis/gdal/driver.py index 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 b1a0b19fd0..7e9d5a6986 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 fb77480fa1..8da4256bf4 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 b984eea4ee..8c092145be 100644 --- a/django/contrib/gis/gdal/geometries.py +++ b/django/contrib/gis/gdal/geometries.py @@ -38,27 +38,23 @@ >>> print(gt1 == 3, gt1 == 'Polygon') # Equivalence works w/non-OGRGeomType objects True True """ -# Python library requisites. import sys from binascii import a2b_hex, b2a_hex -from ctypes import byref, string_at, c_char_p, c_double, c_ubyte, c_void_p +from ctypes import byref, c_char_p, c_double, c_ubyte, c_void_p, string_at -# Getting GDAL prerequisites from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.envelope import Envelope, OGREnvelope -from django.contrib.gis.gdal.error import GDALException, OGRIndexError, SRSException +from django.contrib.gis.gdal.error import ( + GDALException, OGRIndexError, SRSException, +) from django.contrib.gis.gdal.geomtype import OGRGeomType -from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform - -# Getting the ctypes prototype functions that interface w/the GDAL C library. from django.contrib.gis.gdal.prototypes import geom as capi, srs as srs_api - -# For recognizing geometry input. -from django.contrib.gis.geometry.regex import hex_regex, wkt_regex, json_regex - +from django.contrib.gis.gdal.srs import CoordTransform, SpatialReference +from django.contrib.gis.geometry.regex import hex_regex, json_regex, wkt_regex from django.utils import six from django.utils.six.moves import range + # For more information, see the OGR C API source code: # http://www.gdal.org/ogr/ogr__api_8h.html # diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py index 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 b5c7307767..82b0d8dd5d 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 fd9a9946a0..f2f62b727d 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 1b24df4bf3..c24e4b79a2 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 2940079b03..a721087654 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 15f4d5b893..2bcc5a021c 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 781c4ded89..08ec9df961 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 424853704d..96b5130a2c 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 9450277275..e946222fe7 100644 --- a/django/contrib/gis/gdal/srs.py +++ b/django/contrib/gis/gdal/srs.py @@ -32,7 +32,6 @@ from ctypes import byref, c_char_p, c_int from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.error import SRSException from django.contrib.gis.gdal.prototypes import srs as capi - from django.utils import six from django.utils.encoding import force_bytes, force_text diff --git a/django/contrib/gis/gdal/tests/test_ds.py b/django/contrib/gis/gdal/tests/test_ds.py index 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 d0651fcaf2..33b70b4df3 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 de0bfd18a7..0b160ffea3 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 751b4c4b05..257e0ffacd 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 82a2169ab0..0b787f9d53 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 d11c6fbde3..de3583e499 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 dd110c0236..a0e0ecabbd 100644 --- a/django/contrib/gis/geos/geometry.py +++ b/django/contrib/gis/geos/geometry.py @@ -7,29 +7,19 @@ from __future__ import unicode_literals # Python, ctypes and types dependencies. from ctypes import addressof, byref, c_double -# super-class for mutable list behavior -from django.contrib.gis.geos.mutable_list import ListMixin - from django.contrib.gis.gdal.error import SRSException - -# GEOS-related dependencies. +from django.contrib.gis.geometry.regex import hex_regex, json_regex, wkt_regex +from django.contrib.gis.geos import prototypes as capi from django.contrib.gis.geos.base import GEOSBase, gdal from django.contrib.gis.geos.coordseq import GEOSCoordSeq from django.contrib.gis.geos.error import GEOSException, GEOSIndexError from django.contrib.gis.geos.libgeos import GEOM_PTR - -# All other functions in this module come from the ctypes -# prototypes module -- which handles all interaction with -# the underlying GEOS library. -from django.contrib.gis.geos import prototypes as capi - +from django.contrib.gis.geos.mutable_list import ListMixin # These functions provide access to a thread-local instance # of their corresponding GEOS I/O class. -from django.contrib.gis.geos.prototypes.io import wkt_r, wkt_w, wkb_r, wkb_w, ewkb_w - -# For recognizing geometry input. -from django.contrib.gis.geometry.regex import hex_regex, wkt_regex, json_regex - +from django.contrib.gis.geos.prototypes.io import ( + ewkb_w, wkb_r, wkb_w, wkt_r, wkt_w, +) from django.utils import six from django.utils.encoding import force_bytes, force_text @@ -681,13 +671,15 @@ class GEOSGeometry(GEOSBase, ListMixin): "Clones this Geometry." return GEOSGeometry(capi.geom_clone(self.ptr), srid=self.srid) + # Class mapping dictionary. Has to be at the end to avoid import # conflicts with GEOSGeometry. -from django.contrib.gis.geos.linestring import LineString, LinearRing -from django.contrib.gis.geos.point import Point -from django.contrib.gis.geos.polygon import Polygon -from django.contrib.gis.geos.collections import GeometryCollection, MultiPoint, MultiLineString, MultiPolygon -from django.contrib.gis.geos.prepared import PreparedGeometry +from django.contrib.gis.geos.linestring import LineString, LinearRing # isort:skip +from django.contrib.gis.geos.point import Point # isort:skip +from django.contrib.gis.geos.polygon import Polygon # isort:skip +from django.contrib.gis.geos.collections import ( # isort:skip + GeometryCollection, MultiPoint, MultiLineString, MultiPolygon) +from django.contrib.gis.geos.prepared import PreparedGeometry # isort:skip GEOS_CLASSES = { 0: Point, 1: LineString, diff --git a/django/contrib/gis/geos/io.py b/django/contrib/gis/geos/io.py index 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 f218b17f6f..66c61f3a82 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 ec06cb19e8..7b2cc540ba 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 cea3710622..6b60465431 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 dadab29bbf..e53a4569bf 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 89dd0f06f6..fdf7515bed 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 d5aa3da318..1cdc4ccdcc 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 0a624ccec7..b97440ab01 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 5416625c67..da2452c169 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 8083d93ee0..168d472311 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 b256fd3d0b..0a8b388618 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 0bd1fabf9f..6ef979422c 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 06daa12cca..5729256d9d 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 794ed6d75e..7c9c1e829e 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 d12ed53298..ae882da29c 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 830fe72e62..23a7437231 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 410024e324..c9badc7522 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..1bc2caab4b 100644 --- a/django/contrib/gis/utils/ogrinspect.py +++ b/django/contrib/gis/utils/ogrinspect.py @@ -3,11 +3,13 @@ This module is for inspecting OGR data sources and generating either models for GeoDjango and/or mapping dictionaries for use with the `LayerMapping` utility. """ -from django.utils.six.moves import zip # Requires GDAL to use. from django.contrib.gis.gdal import DataSource -from django.contrib.gis.gdal.field import OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime +from django.contrib.gis.gdal.field import ( + OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime, +) from django.utils import six +from django.utils.six.moves import zip def mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False): diff --git a/django/contrib/gis/utils/srs.py b/django/contrib/gis/utils/srs.py index 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 %}