diff --git a/django/apps/config.py b/django/apps/config.py index fd0e2fe78c4..76b3014d9d0 100644 --- a/django/apps/config.py +++ b/django/apps/config.py @@ -1,10 +1,9 @@ -from importlib import import_module import os +from importlib import import_module from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured -from django.utils.module_loading import module_has_submodule from django.utils._os import upath - +from django.utils.module_loading import module_has_submodule MODELS_MODULE_NAME = 'models' diff --git a/django/apps/registry.py b/django/apps/registry.py index 9ddd56462a7..c64106cd6f5 100644 --- a/django/apps/registry.py +++ b/django/apps/registry.py @@ -1,7 +1,7 @@ -from collections import Counter, defaultdict, OrderedDict import sys import threading import warnings +from collections import Counter, OrderedDict, defaultdict from django.core.exceptions import AppRegistryNotReady, ImproperlyConfigured from django.utils import lru_cache diff --git a/django/conf/project_template/project_name/settings.py b/django/conf/project_template/project_name/settings.py index 9d4b38d171e..c0db27cbdc3 100644 --- a/django/conf/project_template/project_name/settings.py +++ b/django/conf/project_template/project_name/settings.py @@ -10,8 +10,9 @@ For the full list of settings and their values, see https://docs.djangoproject.com/en/{{ docs_version }}/ref/settings/ """ -# Build paths inside the project like this: os.path.join(BASE_DIR, ...) import os + +# Build paths inside the project like this: os.path.join(BASE_DIR, ...) BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__))) diff --git a/django/conf/project_template/project_name/wsgi.py b/django/conf/project_template/project_name/wsgi.py index 94d60c8cf9f..0d68b956459 100644 --- a/django/conf/project_template/project_name/wsgi.py +++ b/django/conf/project_template/project_name/wsgi.py @@ -8,7 +8,9 @@ https://docs.djangoproject.com/en/{{ docs_version }}/howto/deployment/wsgi/ """ import os -os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings") from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "{{ project_name }}.settings") + application = get_wsgi_application() diff --git a/django/contrib/admin/actions.py b/django/contrib/admin/actions.py index 2dafd3ea3a2..3478145b30b 100644 --- a/django/contrib/admin/actions.py +++ b/django/contrib/admin/actions.py @@ -2,14 +2,14 @@ Built-in, globally-available admin actions. """ -from django.core.exceptions import PermissionDenied from django.contrib import messages from django.contrib.admin import helpers from django.contrib.admin.utils import get_deleted_objects, model_ngettext +from django.core.exceptions import PermissionDenied from django.db import router from django.template.response import TemplateResponse from django.utils.encoding import force_text -from django.utils.translation import ugettext_lazy, ugettext as _ +from django.utils.translation import ugettext as _, ugettext_lazy def delete_selected(modeladmin, request, queryset): diff --git a/django/contrib/admin/apps.py b/django/contrib/admin/apps.py index b052746ff4e..c965cdbc893 100644 --- a/django/contrib/admin/apps.py +++ b/django/contrib/admin/apps.py @@ -1,6 +1,6 @@ from django.apps import AppConfig -from django.core import checks from django.contrib.admin.checks import check_admin_app +from django.core import checks from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/admin/checks.py b/django/contrib/admin/checks.py index f90793daec2..d8f7fe57e43 100644 --- a/django/contrib/admin/checks.py +++ b/django/contrib/admin/checks.py @@ -3,11 +3,15 @@ from __future__ import unicode_literals from itertools import chain -from django.contrib.admin.utils import get_fields_from_path, NotRelationField, flatten +from django.contrib.admin.utils import ( + NotRelationField, flatten, get_fields_from_path, +) from django.core import checks from django.core.exceptions import FieldDoesNotExist from django.db import models -from django.forms.models import BaseModelForm, _get_foreign_key, BaseModelFormSet +from django.forms.models import ( + BaseModelForm, BaseModelFormSet, _get_foreign_key, +) def check_admin_app(**kwargs): diff --git a/django/contrib/admin/filters.py b/django/contrib/admin/filters.py index 0c0eb339ce9..863da768181 100644 --- a/django/contrib/admin/filters.py +++ b/django/contrib/admin/filters.py @@ -7,15 +7,17 @@ certain test -- e.g. being a DateField or ForeignKey. """ import datetime +from django.contrib.admin.options import IncorrectLookupParameters +from django.contrib.admin.utils import ( + get_limit_choices_to_from_path, get_model_from_relation, + prepare_lookup_value, reverse_field_path, +) +from django.core.exceptions import ImproperlyConfigured, ValidationError from django.db import models from django.db.models.fields.related import ForeignObjectRel, ManyToManyField -from django.core.exceptions import ImproperlyConfigured, ValidationError -from django.utils.encoding import smart_text, force_text -from django.utils.translation import ugettext_lazy as _ from django.utils import timezone -from django.contrib.admin.utils import (get_model_from_relation, - reverse_field_path, get_limit_choices_to_from_path, prepare_lookup_value) -from django.contrib.admin.options import IncorrectLookupParameters +from django.utils.encoding import force_text, smart_text +from django.utils.translation import ugettext_lazy as _ class ListFilter(object): diff --git a/django/contrib/admin/forms.py b/django/contrib/admin/forms.py index ede6f257ad2..2e482b9c15d 100644 --- a/django/contrib/admin/forms.py +++ b/django/contrib/admin/forms.py @@ -1,7 +1,6 @@ from __future__ import unicode_literals from django import forms - from django.contrib.auth.forms import AuthenticationForm, PasswordChangeForm from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/admin/helpers.py b/django/contrib/admin/helpers.py index bd41063e43a..07ea9a48139 100644 --- a/django/contrib/admin/helpers.py +++ b/django/contrib/admin/helpers.py @@ -3,22 +3,23 @@ from __future__ import unicode_literals import warnings from django import forms -from django.contrib.admin.utils import (flatten_fieldsets, lookup_field, - display_for_field, label_for_field, help_text_for_field) +from django.conf import settings from django.contrib.admin.templatetags.admin_static import static +from django.contrib.admin.utils import ( + display_for_field, flatten_fieldsets, help_text_for_field, label_for_field, + lookup_field, +) from django.core.exceptions import ObjectDoesNotExist from django.db.models.fields.related import ManyToManyRel from django.forms.utils import flatatt from django.template.defaultfilters import capfirst, linebreaksbr +from django.utils import six from django.utils.deprecation import RemovedInDjango20Warning from django.utils.encoding import force_text, smart_text from django.utils.functional import cached_property from django.utils.html import conditional_escape, format_html from django.utils.safestring import mark_safe -from django.utils import six from django.utils.translation import ugettext_lazy as _ -from django.conf import settings - ACTION_CHECKBOX_NAME = '_selected_action' diff --git a/django/contrib/admin/migrations/0001_initial.py b/django/contrib/admin/migrations/0001_initial.py index b9872dcc443..088d36becd6 100644 --- a/django/contrib/admin/migrations/0001_initial.py +++ b/django/contrib/admin/migrations/0001_initial.py @@ -1,9 +1,9 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations -from django.conf import settings import django.contrib.admin.models +from django.conf import settings +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/admin/models.py b/django/contrib/admin/models.py index 9ecb367e058..4e1d2aed04f 100644 --- a/django/contrib/admin/models.py +++ b/django/contrib/admin/models.py @@ -1,13 +1,12 @@ from __future__ import unicode_literals -from django.db import models from django.conf import settings -from django.contrib.contenttypes.models import ContentType from django.contrib.admin.utils import quote -from django.core.urlresolvers import reverse, NoReverseMatch +from django.contrib.contenttypes.models import ContentType +from django.core.urlresolvers import NoReverseMatch, reverse +from django.db import models +from django.utils.encoding import python_2_unicode_compatible, smart_text from django.utils.translation import ugettext, ugettext_lazy as _ -from django.utils.encoding import smart_text -from django.utils.encoding import python_2_unicode_compatible ADDITION = 1 CHANGE = 2 diff --git a/django/contrib/admin/options.py b/django/contrib/admin/options.py index 1419e865890..f0fd4c1a906 100644 --- a/django/contrib/admin/options.py +++ b/django/contrib/admin/options.py @@ -1,34 +1,39 @@ -from collections import OrderedDict import copy import operator +from collections import OrderedDict from functools import partial, reduce, update_wrapper from django import forms from django.conf import settings from django.contrib import messages -from django.contrib.admin import widgets, helpers -from django.contrib.admin.checks import (BaseModelAdminChecks, ModelAdminChecks, - InlineModelAdminChecks) +from django.contrib.admin import helpers, widgets +from django.contrib.admin.checks import ( + BaseModelAdminChecks, InlineModelAdminChecks, ModelAdminChecks, +) from django.contrib.admin.exceptions import DisallowedModelAdminToField -from django.contrib.admin.utils import (quote, unquote, flatten_fieldsets, - get_deleted_objects, model_format_dict, NestedObjects, - lookup_needs_distinct) from django.contrib.admin.templatetags.admin_static import static from django.contrib.admin.templatetags.admin_urls import add_preserved_filters +from django.contrib.admin.utils import ( + NestedObjects, flatten_fieldsets, get_deleted_objects, + lookup_needs_distinct, model_format_dict, quote, unquote, +) from django.contrib.auth import get_permission_codename -from django.core.exceptions import (PermissionDenied, ValidationError, - FieldDoesNotExist, FieldError) +from django.core.exceptions import ( + FieldDoesNotExist, FieldError, PermissionDenied, ValidationError, +) from django.core.paginator import Paginator from django.core.urlresolvers import reverse -from django.db import models, transaction, router +from django.db import models, router, transaction from django.db.models.constants import LOOKUP_SEP from django.db.models.fields import BLANK_CHOICE_DASH from django.db.models.fields.related import ForeignObjectRel from django.db.models.sql.constants import QUERY_TERMS -from django.forms.formsets import all_valid, DELETION_FIELD_NAME -from django.forms.models import (modelform_factory, modelformset_factory, - inlineformset_factory, BaseInlineFormSet, modelform_defines_fields) -from django.forms.widgets import SelectMultiple, CheckboxSelectMultiple +from django.forms.formsets import DELETION_FIELD_NAME, all_valid +from django.forms.models import ( + BaseInlineFormSet, inlineformset_factory, modelform_defines_fields, + modelform_factory, modelformset_factory, +) +from django.forms.widgets import CheckboxSelectMultiple, SelectMultiple from django.http import Http404, HttpResponseRedirect from django.http.response import HttpResponseBase from django.shortcuts import get_object_or_404 @@ -38,14 +43,11 @@ from django.utils.decorators import method_decorator from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.html import escape, escapejs from django.utils.http import urlencode -from django.utils.text import capfirst, get_text_list -from django.utils.translation import string_concat -from django.utils.translation import ugettext as _ -from django.utils.translation import ungettext from django.utils.safestring import mark_safe +from django.utils.text import capfirst, get_text_list +from django.utils.translation import string_concat, ugettext as _, ungettext from django.views.decorators.csrf import csrf_protect - IS_POPUP_VAR = '_popup' TO_FIELD_VAR = '_to_field' diff --git a/django/contrib/admin/sites.py b/django/contrib/admin/sites.py index 8389a3fe099..4b5ee57746f 100644 --- a/django/contrib/admin/sites.py +++ b/django/contrib/admin/sites.py @@ -1,19 +1,20 @@ from functools import update_wrapper -from django.http import Http404, HttpResponseRedirect + +from django.apps import apps +from django.conf import settings from django.contrib.admin import ModelAdmin, actions from django.contrib.auth import REDIRECT_FIELD_NAME -from django.views.decorators.csrf import csrf_protect -from django.db.models.base import ModelBase -from django.apps import apps from django.core.exceptions import ImproperlyConfigured, PermissionDenied -from django.core.urlresolvers import reverse, NoReverseMatch +from django.core.urlresolvers import NoReverseMatch, reverse +from django.db.models.base import ModelBase +from django.http import Http404, HttpResponseRedirect from django.template.engine import Engine from django.template.response import TemplateResponse from django.utils import six from django.utils.text import capfirst -from django.utils.translation import ugettext_lazy, ugettext as _ +from django.utils.translation import ugettext as _, ugettext_lazy from django.views.decorators.cache import never_cache -from django.conf import settings +from django.views.decorators.csrf import csrf_protect system_check_errors = [] diff --git a/django/contrib/admin/templatetags/admin_list.py b/django/contrib/admin/templatetags/admin_list.py index 6f7c530aa72..55fba4f90ce 100644 --- a/django/contrib/admin/templatetags/admin_list.py +++ b/django/contrib/admin/templatetags/admin_list.py @@ -2,24 +2,25 @@ from __future__ import unicode_literals import datetime -from django.contrib.admin.templatetags.admin_urls import add_preserved_filters -from django.contrib.admin.utils import (lookup_field, display_for_field, - display_for_value, label_for_field) -from django.contrib.admin.views.main import (ALL_VAR, EMPTY_CHANGELIST_VALUE, - ORDER_VAR, PAGE_VAR, SEARCH_VAR) from django.contrib.admin.templatetags.admin_static import static +from django.contrib.admin.templatetags.admin_urls import add_preserved_filters +from django.contrib.admin.utils import ( + display_for_field, display_for_value, label_for_field, lookup_field, +) +from django.contrib.admin.views.main import ( + ALL_VAR, EMPTY_CHANGELIST_VALUE, ORDER_VAR, PAGE_VAR, SEARCH_VAR, +) from django.core.exceptions import ObjectDoesNotExist from django.core.urlresolvers import NoReverseMatch from django.db import models +from django.template import Library +from django.template.loader import get_template from django.utils import formats +from django.utils.encoding import force_text from django.utils.html import escapejs, format_html from django.utils.safestring import mark_safe from django.utils.text import capfirst from django.utils.translation import ugettext as _ -from django.utils.encoding import force_text -from django.template import Library -from django.template.loader import get_template - register = Library() diff --git a/django/contrib/admin/utils.py b/django/contrib/admin/utils.py index 95cbe634b2e..f704ef3af73 100644 --- a/django/contrib/admin/utils.py +++ b/django/contrib/admin/utils.py @@ -6,7 +6,7 @@ from collections import defaultdict from django.contrib.auth import get_permission_codename from django.core.exceptions import FieldDoesNotExist -from django.core.urlresolvers import reverse, NoReverseMatch +from django.core.urlresolvers import NoReverseMatch, reverse from django.db import models from django.db.models.constants import LOOKUP_SEP from django.db.models.deletion import Collector diff --git a/django/contrib/admin/views/main.py b/django/contrib/admin/views/main.py index 07457a87fc5..fa91ceae3ad 100644 --- a/django/contrib/admin/views/main.py +++ b/django/contrib/admin/views/main.py @@ -1,22 +1,26 @@ -from collections import OrderedDict import sys - -from django.core.exceptions import FieldDoesNotExist, SuspiciousOperation, ImproperlyConfigured -from django.core.paginator import InvalidPage -from django.core.urlresolvers import reverse -from django.db import models -from django.utils import six -from django.utils.encoding import force_text -from django.utils.translation import ugettext, ugettext_lazy -from django.utils.http import urlencode +from collections import OrderedDict from django.contrib.admin import FieldListFilter from django.contrib.admin.exceptions import ( DisallowedModelAdminLookup, DisallowedModelAdminToField, ) -from django.contrib.admin.options import IncorrectLookupParameters, IS_POPUP_VAR, TO_FIELD_VAR -from django.contrib.admin.utils import (quote, get_fields_from_path, - lookup_needs_distinct, prepare_lookup_value) +from django.contrib.admin.options import ( + IS_POPUP_VAR, TO_FIELD_VAR, IncorrectLookupParameters, +) +from django.contrib.admin.utils import ( + get_fields_from_path, lookup_needs_distinct, prepare_lookup_value, quote, +) +from django.core.exceptions import ( + FieldDoesNotExist, ImproperlyConfigured, SuspiciousOperation, +) +from django.core.paginator import InvalidPage +from django.core.urlresolvers import reverse +from django.db import models +from django.utils import six +from django.utils.encoding import force_text +from django.utils.http import urlencode +from django.utils.translation import ugettext, ugettext_lazy # Changelist settings ALL_VAR = 'all' diff --git a/django/contrib/admin/widgets.py b/django/contrib/admin/widgets.py index 10ac364f742..19b4187b524 100644 --- a/django/contrib/admin/widgets.py +++ b/django/contrib/admin/widgets.py @@ -9,15 +9,17 @@ from django import forms from django.contrib.admin.templatetags.admin_static import static from django.core.urlresolvers import reverse from django.db.models.deletion import CASCADE -from django.forms.widgets import Media, RadioFieldRenderer from django.forms.utils import flatatt +from django.forms.widgets import Media, RadioFieldRenderer from django.template.loader import render_to_string -from django.utils.html import escape, format_html, format_html_join, smart_urlquote +from django.utils import six +from django.utils.encoding import force_text +from django.utils.html import ( + escape, format_html, format_html_join, smart_urlquote, +) +from django.utils.safestring import mark_safe from django.utils.text import Truncator from django.utils.translation import ugettext as _ -from django.utils.safestring import mark_safe -from django.utils.encoding import force_text -from django.utils import six class FilteredSelectMultiple(forms.SelectMultiple): diff --git a/django/contrib/admindocs/apps.py b/django/contrib/admindocs/apps.py index 7994f618cd4..28ddbfb92a6 100644 --- a/django/contrib/admindocs/apps.py +++ b/django/contrib/admindocs/apps.py @@ -1,5 +1,4 @@ from django.apps import AppConfig - from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/admindocs/middleware.py b/django/contrib/admindocs/middleware.py index 330b76423b6..2e4cede0b90 100644 --- a/django/contrib/admindocs/middleware.py +++ b/django/contrib/admindocs/middleware.py @@ -1,5 +1,5 @@ -from django.conf import settings from django import http +from django.conf import settings class XViewMiddleware(object): diff --git a/django/contrib/admindocs/utils.py b/django/contrib/admindocs/utils.py index 779a8a446b7..f366025f891 100644 --- a/django/contrib/admindocs/utils.py +++ b/django/contrib/admindocs/utils.py @@ -1,12 +1,13 @@ "Misc. utility functions/classes for admin documentation generator." import re -from email.parser import HeaderParser from email.errors import HeaderParseError +from email.parser import HeaderParser -from django.utils.safestring import mark_safe from django.core.urlresolvers import reverse from django.utils.encoding import force_bytes +from django.utils.safestring import mark_safe + try: import docutils.core import docutils.nodes diff --git a/django/contrib/admindocs/views.py b/django/contrib/admindocs/views.py index 4ce64c3a530..91ca143508a 100644 --- a/django/contrib/admindocs/views.py +++ b/django/contrib/admindocs/views.py @@ -1,23 +1,25 @@ -from importlib import import_module import inspect import os import re +from importlib import import_module from django.apps import apps from django.conf import settings from django.contrib import admin from django.contrib.admin.views.decorators import staff_member_required -from django.db import models -from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist -from django.http import Http404 -from django.core import urlresolvers from django.contrib.admindocs import utils -from django.template.base import (builtins, get_library, - get_templatetags_modules, InvalidTemplateLibrary, libraries) +from django.core import urlresolvers +from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist +from django.db import models +from django.http import Http404 +from django.template.base import ( + InvalidTemplateLibrary, builtins, get_library, get_templatetags_modules, + libraries, +) from django.template.engine import Engine -from django.utils.decorators import method_decorator -from django.utils._os import upath from django.utils import six +from django.utils._os import upath +from django.utils.decorators import method_decorator from django.utils.translation import ugettext as _ from django.views.generic import TemplateView diff --git a/django/contrib/auth/admin.py b/django/contrib/auth/admin.py index 90394c8f093..b791609031d 100644 --- a/django/contrib/auth/admin.py +++ b/django/contrib/auth/admin.py @@ -1,19 +1,19 @@ -from django.db import transaction from django.conf import settings from django.conf.urls import url -from django.contrib import admin +from django.contrib import admin, messages from django.contrib.admin.options import IS_POPUP_VAR from django.contrib.auth import update_session_auth_hash -from django.contrib.auth.forms import (UserCreationForm, UserChangeForm, - AdminPasswordChangeForm) -from django.contrib.auth.models import User, Group -from django.contrib import messages +from django.contrib.auth.forms import ( + AdminPasswordChangeForm, UserChangeForm, UserCreationForm, +) +from django.contrib.auth.models import Group, User from django.core.exceptions import PermissionDenied -from django.http import HttpResponseRedirect, Http404 +from django.db import transaction +from django.http import Http404, HttpResponseRedirect from django.shortcuts import get_object_or_404 from django.template.response import TemplateResponse -from django.utils.html import escape from django.utils.decorators import method_decorator +from django.utils.html import escape from django.utils.translation import ugettext, ugettext_lazy as _ from django.views.decorators.csrf import csrf_protect from django.views.decorators.debug import sensitive_post_parameters diff --git a/django/contrib/auth/apps.py b/django/contrib/auth/apps.py index bbfcb7dbd1e..109a34dff63 100644 --- a/django/contrib/auth/apps.py +++ b/django/contrib/auth/apps.py @@ -1,6 +1,6 @@ from django.apps import AppConfig -from django.core import checks from django.contrib.auth.checks import check_user_model +from django.core import checks from django.db.models.signals import post_migrate from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/auth/backends.py b/django/contrib/auth/backends.py index 00a772fd4f8..9f082590389 100644 --- a/django/contrib/auth/backends.py +++ b/django/contrib/auth/backends.py @@ -1,4 +1,5 @@ from __future__ import unicode_literals + from django.contrib.auth import get_user_model from django.contrib.auth.models import Permission diff --git a/django/contrib/auth/decorators.py b/django/contrib/auth/decorators.py index 99e2983e630..9b2504b33cb 100644 --- a/django/contrib/auth/decorators.py +++ b/django/contrib/auth/decorators.py @@ -1,10 +1,11 @@ from functools import wraps + from django.conf import settings from django.contrib.auth import REDIRECT_FIELD_NAME from django.core.exceptions import PermissionDenied +from django.shortcuts import resolve_url from django.utils.decorators import available_attrs from django.utils.six.moves.urllib.parse import urlparse -from django.shortcuts import resolve_url def user_passes_test(test_func, login_url=None, redirect_field_name=REDIRECT_FIELD_NAME): diff --git a/django/contrib/auth/forms.py b/django/contrib/auth/forms.py index 3d19b2247e2..cc3be5ba0be 100644 --- a/django/contrib/auth/forms.py +++ b/django/contrib/auth/forms.py @@ -3,6 +3,13 @@ from __future__ import unicode_literals from collections import OrderedDict from django import forms +from django.contrib.auth import authenticate, get_user_model +from django.contrib.auth.hashers import ( + UNUSABLE_PASSWORD_PREFIX, identify_hasher, +) +from django.contrib.auth.models import User +from django.contrib.auth.tokens import default_token_generator +from django.contrib.sites.shortcuts import get_current_site from django.core.mail import EmailMultiAlternatives from django.forms.utils import flatatt from django.template import loader @@ -13,12 +20,6 @@ from django.utils.safestring import mark_safe from django.utils.text import capfirst from django.utils.translation import ugettext, ugettext_lazy as _ -from django.contrib.auth import authenticate, get_user_model -from django.contrib.auth.models import User -from django.contrib.auth.hashers import UNUSABLE_PASSWORD_PREFIX, identify_hasher -from django.contrib.auth.tokens import default_token_generator -from django.contrib.sites.shortcuts import get_current_site - class ReadOnlyPasswordHashWidget(forms.Widget): def render(self, name, value, attrs): diff --git a/django/contrib/auth/handlers/modwsgi.py b/django/contrib/auth/handlers/modwsgi.py index 8ada9750f19..6b91ed9c6ea 100644 --- a/django/contrib/auth/handlers/modwsgi.py +++ b/django/contrib/auth/handlers/modwsgi.py @@ -1,5 +1,5 @@ -from django.contrib import auth from django import db +from django.contrib import auth from django.utils.encoding import force_bytes diff --git a/django/contrib/auth/hashers.py b/django/contrib/auth/hashers.py index 44ebf89c36a..59676f6562b 100644 --- a/django/contrib/auth/hashers.py +++ b/django/contrib/auth/hashers.py @@ -2,22 +2,22 @@ from __future__ import unicode_literals import base64 import binascii -from collections import OrderedDict import hashlib import importlib +from collections import OrderedDict -from django.dispatch import receiver from django.conf import settings -from django.core.signals import setting_changed -from django.utils.encoding import force_bytes, force_str, force_text from django.core.exceptions import ImproperlyConfigured -from django.utils.crypto import ( - pbkdf2, constant_time_compare, get_random_string) +from django.core.signals import setting_changed +from django.dispatch import receiver from django.utils import lru_cache +from django.utils.crypto import ( + constant_time_compare, get_random_string, pbkdf2, +) +from django.utils.encoding import force_bytes, force_str, force_text from django.utils.module_loading import import_string from django.utils.translation import ugettext_noop as _ - UNUSABLE_PASSWORD_PREFIX = '!' # This will never be a valid encoded hash UNUSABLE_PASSWORD_SUFFIX_LENGTH = 40 # number of random chars to add after UNUSABLE_PASSWORD_PREFIX diff --git a/django/contrib/auth/migrations/0001_initial.py b/django/contrib/auth/migrations/0001_initial.py index 33c8e001530..a58f73ab1ae 100644 --- a/django/contrib/auth/migrations/0001_initial.py +++ b/django/contrib/auth/migrations/0001_initial.py @@ -1,10 +1,10 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.core import validators -from django.db import models, migrations -from django.utils import timezone import django.contrib.auth.models +from django.core import validators +from django.db import migrations, models +from django.utils import timezone class Migration(migrations.Migration): diff --git a/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py b/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py index 8e82223237a..8b58e7814b1 100644 --- a/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py +++ b/django/contrib/auth/migrations/0002_alter_permission_name_max_length.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/auth/migrations/0003_alter_user_email_max_length.py b/django/contrib/auth/migrations/0003_alter_user_email_max_length.py index a9b8058089b..0a082f2656a 100644 --- a/django/contrib/auth/migrations/0003_alter_user_email_max_length.py +++ b/django/contrib/auth/migrations/0003_alter_user_email_max_length.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/auth/migrations/0004_alter_user_username_opts.py b/django/contrib/auth/migrations/0004_alter_user_username_opts.py index 80a156e0019..0f7bfdf3a7e 100644 --- a/django/contrib/auth/migrations/0004_alter_user_username_opts.py +++ b/django/contrib/auth/migrations/0004_alter_user_username_opts.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations import django.core.validators +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/auth/migrations/0005_alter_user_last_login_null.py b/django/contrib/auth/migrations/0005_alter_user_last_login_null.py index 128a4e49628..b8b9289787a 100644 --- a/django/contrib/auth/migrations/0005_alter_user_last_login_null.py +++ b/django/contrib/auth/migrations/0005_alter_user_last_login_null.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index 89b3054b70a..4dc49c2d0c1 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -1,21 +1,20 @@ from __future__ import unicode_literals -from django.core.exceptions import PermissionDenied -from django.core.mail import send_mail -from django.core import validators -from django.db import models -from django.db.models.manager import EmptyManager -from django.utils.crypto import get_random_string, salted_hmac -from django.utils import six -from django.utils.translation import ugettext_lazy as _ -from django.utils import timezone - from django.contrib import auth from django.contrib.auth.hashers import ( - check_password, make_password, is_password_usable) + check_password, is_password_usable, make_password, +) from django.contrib.auth.signals import user_logged_in from django.contrib.contenttypes.models import ContentType +from django.core import validators +from django.core.exceptions import PermissionDenied +from django.core.mail import send_mail +from django.db import models +from django.db.models.manager import EmptyManager +from django.utils import six, timezone +from django.utils.crypto import get_random_string, salted_hmac from django.utils.encoding import python_2_unicode_compatible +from django.utils.translation import ugettext_lazy as _ def update_last_login(sender, user, **kwargs): diff --git a/django/contrib/auth/tests/backend_alias.py b/django/contrib/auth/tests/backend_alias.py index 1f31f7a16af..7314bac4ee0 100644 --- a/django/contrib/auth/tests/backend_alias.py +++ b/django/contrib/auth/tests/backend_alias.py @@ -1,2 +1,4 @@ # For testing that auth backends can be referenced using a convenience import -from django.contrib.auth.tests.test_auth_backends import ImportedModelBackend # NOQA +from django.contrib.auth.tests.test_auth_backends import ImportedModelBackend + +__all__ = ['ImportedModelBackend'] diff --git a/django/contrib/auth/tests/custom_user.py b/django/contrib/auth/tests/custom_user.py index c856431bba4..e7ce6162e93 100644 --- a/django/contrib/auth/tests/custom_user.py +++ b/django/contrib/auth/tests/custom_user.py @@ -1,13 +1,8 @@ -from django.db import models from django.contrib.auth.models import ( - BaseUserManager, - AbstractBaseUser, - AbstractUser, - UserManager, - PermissionsMixin, - Group, - Permission, + AbstractBaseUser, AbstractUser, BaseUserManager, Group, Permission, + PermissionsMixin, UserManager, ) +from django.db import models # The custom User uses email as the unique identifier, and requires diff --git a/django/contrib/auth/tests/settings.py b/django/contrib/auth/tests/settings.py index b3e1eff1564..7da6144d4be 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 383fae759ea..2abdc4d7973 100644 --- a/django/contrib/auth/tests/test_auth_backends.py +++ b/django/contrib/auth/tests/test_auth_backends.py @@ -1,16 +1,19 @@ from __future__ import unicode_literals + from datetime import date +from django.contrib.auth import BACKEND_SESSION_KEY, authenticate, get_user from django.contrib.auth.backends import ModelBackend -from django.contrib.auth.models import User, Group, Permission, AnonymousUser +from django.contrib.auth.hashers import MD5PasswordHasher +from django.contrib.auth.models import AnonymousUser, Group, Permission, User +from django.contrib.auth.tests.custom_user import ( + CustomPermissionsUser, CustomUser, ExtensionUser, +) from django.contrib.auth.tests.utils import skipIfCustomUser -from django.contrib.auth.tests.custom_user import ExtensionUser, CustomPermissionsUser, CustomUser from django.contrib.contenttypes.models import ContentType from django.core.exceptions import ImproperlyConfigured, PermissionDenied -from django.contrib.auth import authenticate, BACKEND_SESSION_KEY, get_user from django.http import HttpRequest from django.test import TestCase, modify_settings, override_settings -from django.contrib.auth.hashers import MD5PasswordHasher class CountingMD5PasswordHasher(MD5PasswordHasher): diff --git a/django/contrib/auth/tests/test_basic.py b/django/contrib/auth/tests/test_basic.py index fed94db82fe..ca7db755e6f 100644 --- a/django/contrib/auth/tests/test_basic.py +++ b/django/contrib/auth/tests/test_basic.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals from django.apps import apps from django.contrib.auth import get_user_model -from django.contrib.auth.models import User, AnonymousUser +from django.contrib.auth.models import AnonymousUser, User from django.contrib.auth.tests.custom_user import CustomUser from django.contrib.auth.tests.utils import skipIfCustomUser from django.core.exceptions import ImproperlyConfigured diff --git a/django/contrib/auth/tests/test_context_processors.py b/django/contrib/auth/tests/test_context_processors.py index 2f7e5ab4b27..3e1c19e91d2 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 601c0868d7b..6437ef6b2e1 100644 --- a/django/contrib/auth/tests/test_forms.py +++ b/django/contrib/auth/tests/test_forms.py @@ -3,16 +3,18 @@ from __future__ import unicode_literals import re from django import forms +from django.contrib.auth.forms import ( + AuthenticationForm, PasswordChangeForm, PasswordResetForm, + ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget, SetPasswordForm, + UserChangeForm, UserCreationForm, +) from django.contrib.auth.models import User -from django.contrib.auth.forms import (UserCreationForm, AuthenticationForm, - PasswordChangeForm, SetPasswordForm, UserChangeForm, PasswordResetForm, - ReadOnlyPasswordHashField, ReadOnlyPasswordHashWidget) from django.core import mail from django.core.mail import EmailMultiAlternatives -from django.forms.fields import Field, CharField +from django.forms.fields import CharField, Field from django.test import TestCase, override_settings -from django.utils.encoding import force_text from django.utils import translation +from django.utils.encoding import force_text from django.utils.text import capfirst from django.utils.translation import ugettext as _ diff --git a/django/contrib/auth/tests/test_handlers.py b/django/contrib/auth/tests/test_handlers.py index f4fa3030de9..a6a4f9cd068 100644 --- a/django/contrib/auth/tests/test_handlers.py +++ b/django/contrib/auth/tests/test_handlers.py @@ -1,11 +1,12 @@ from __future__ import unicode_literals -from django.contrib.auth.handlers.modwsgi import check_password, groups_for_user -from django.contrib.auth.models import User, Group +from django.contrib.auth.handlers.modwsgi import ( + check_password, groups_for_user, +) +from django.contrib.auth.models import Group, User from django.contrib.auth.tests.custom_user import CustomUser from django.contrib.auth.tests.utils import skipIfCustomUser -from django.test import TransactionTestCase -from django.test import override_settings +from django.test import TransactionTestCase, override_settings # This must be a TransactionTestCase because the WSGI auth handler performs diff --git a/django/contrib/auth/tests/test_hashers.py b/django/contrib/auth/tests/test_hashers.py index 740ba462a2e..52253d6efba 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 24e43173920..1a210a19153 100644 --- a/django/contrib/auth/tests/test_management.py +++ b/django/contrib/auth/tests/test_management.py @@ -1,23 +1,28 @@ from __future__ import unicode_literals -from datetime import date import locale import sys +from datetime import date from django.apps import apps -from django.contrib.auth import models, management +from django.contrib.auth import management, models from django.contrib.auth.checks import check_user_model from django.contrib.auth.management import create_permissions -from django.contrib.auth.management.commands import changepassword, createsuperuser -from django.contrib.auth.models import User, Group -from django.contrib.auth.tests.custom_user import CustomUser, CustomUserWithFK, Email +from django.contrib.auth.management.commands import ( + changepassword, createsuperuser, +) +from django.contrib.auth.models import Group, User +from django.contrib.auth.tests.custom_user import ( + CustomUser, CustomUserWithFK, Email, +) from django.contrib.auth.tests.utils import skipIfCustomUser from django.contrib.contenttypes.models import ContentType -from django.core import checks -from django.core import exceptions +from django.core import checks, exceptions from django.core.management import call_command from django.core.management.base import CommandError -from django.test import TestCase, override_settings, override_system_checks, skipUnlessDBFeature +from django.test import ( + TestCase, override_settings, override_system_checks, skipUnlessDBFeature, +) from django.utils import six from django.utils.encoding import force_str diff --git a/django/contrib/auth/tests/test_models.py b/django/contrib/auth/tests/test_models.py index b0a35a445a9..ee51b15a984 100644 --- a/django/contrib/auth/tests/test_models.py +++ b/django/contrib/auth/tests/test_models.py @@ -1,5 +1,7 @@ from django.contrib.auth import get_user_model -from django.contrib.auth.models import AbstractUser, Group, Permission, User, UserManager +from django.contrib.auth.models import ( + AbstractUser, Group, Permission, User, UserManager, +) from django.contrib.auth.tests.utils import skipIfCustomUser from django.contrib.contenttypes.models import ContentType from django.core import mail diff --git a/django/contrib/auth/tests/test_signals.py b/django/contrib/auth/tests/test_signals.py index e3c89f23664..909c28a36da 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 409a1705f30..ab3aea42dbe 100644 --- a/django/contrib/auth/tests/test_templates.py +++ b/django/contrib/auth/tests/test_templates.py @@ -3,11 +3,10 @@ from django.contrib.auth.models import User from django.contrib.auth.tests.utils import skipIfCustomUser from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.contrib.auth.views import ( - password_reset, password_reset_done, password_reset_confirm, - password_reset_complete, password_change, password_change_done, + password_change, password_change_done, password_reset, + password_reset_complete, password_reset_confirm, password_reset_done, ) -from django.test import RequestFactory, TestCase -from django.test import override_settings +from django.test import RequestFactory, TestCase, override_settings from django.utils.encoding import force_bytes, force_text from django.utils.http import urlsafe_base64_encode diff --git a/django/contrib/auth/tests/test_tokens.py b/django/contrib/auth/tests/test_tokens.py index 583546ab3aa..b9433bdcfab 100644 --- a/django/contrib/auth/tests/test_tokens.py +++ b/django/contrib/auth/tests/test_tokens.py @@ -1,11 +1,11 @@ -from datetime import date, timedelta import sys import unittest +from datetime import date, timedelta from django.conf import settings from django.contrib.auth.models import User -from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.contrib.auth.tests.utils import skipIfCustomUser +from django.contrib.auth.tokens import PasswordResetTokenGenerator from django.test import TestCase diff --git a/django/contrib/auth/tests/test_views.py b/django/contrib/auth/tests/test_views.py index fd01909c2b7..c065d30dbe6 100644 --- a/django/contrib/auth/tests/test_views.py +++ b/django/contrib/auth/tests/test_views.py @@ -1,33 +1,34 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from importlib import import_module import itertools import re +from importlib import import_module from django.apps import apps from django.conf import settings -from django.contrib.sites.requests import RequestSite from django.contrib.admin.models import LogEntry -from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME -from django.contrib.auth.forms import (AuthenticationForm, PasswordChangeForm, - SetPasswordForm) +from django.contrib.auth import REDIRECT_FIELD_NAME, SESSION_KEY +from django.contrib.auth.forms import ( + AuthenticationForm, PasswordChangeForm, SetPasswordForm, +) from django.contrib.auth.models import User from django.contrib.auth.views import login as login_view, redirect_to_login +from django.contrib.sessions.middleware import SessionMiddleware +from django.contrib.sites.requests import RequestSite from django.core import mail from django.core.urlresolvers import NoReverseMatch, reverse, reverse_lazy -from django.http import QueryDict, HttpRequest -from django.utils.deprecation import RemovedInDjango20Warning -from django.utils.encoding import force_text -from django.utils.http import urlquote -from django.utils.six.moves.urllib.parse import urlparse, ParseResult -from django.utils.translation import LANGUAGE_SESSION_KEY +from django.http import HttpRequest, QueryDict +from django.middleware.csrf import CsrfViewMiddleware from django.test import ( TestCase, ignore_warnings, modify_settings, override_settings, ) from django.test.utils import patch_logger -from django.middleware.csrf import CsrfViewMiddleware -from django.contrib.sessions.middleware import SessionMiddleware +from django.utils.deprecation import RemovedInDjango20Warning +from django.utils.encoding import force_text +from django.utils.http import urlquote +from django.utils.six.moves.urllib.parse import ParseResult, urlparse +from django.utils.translation import LANGUAGE_SESSION_KEY # Needed so model is installed when tests are run independently: from .custom_user import CustomUser # NOQA diff --git a/django/contrib/auth/tests/urls.py b/django/contrib/auth/tests/urls.py index 41e742a93b0..6f83e0f4207 100644 --- a/django/contrib/auth/tests/urls.py +++ b/django/contrib/auth/tests/urls.py @@ -1,13 +1,13 @@ -from django.conf.urls import url, include +from django.conf.urls import include, url from django.contrib import admin -from django.contrib.auth.forms import AuthenticationForm -from django.contrib.auth.urls import urlpatterns from django.contrib.auth import views from django.contrib.auth.decorators import login_required +from django.contrib.auth.forms import AuthenticationForm +from django.contrib.auth.urls import urlpatterns from django.contrib.messages.api import info -from django.http import HttpResponse, HttpRequest +from django.http import HttpRequest, HttpResponse from django.shortcuts import render -from django.template import Template, RequestContext +from django.template import RequestContext, Template from django.views.decorators.cache import never_cache diff --git a/django/contrib/auth/tests/urls_admin.py b/django/contrib/auth/tests/urls_admin.py index 49d6f38447a..8d2fe3fd106 100644 --- a/django/contrib/auth/tests/urls_admin.py +++ b/django/contrib/auth/tests/urls_admin.py @@ -4,8 +4,8 @@ Test URLs for auth admins. from django.conf.urls import include, url from django.contrib import admin -from django.contrib.auth.admin import UserAdmin, GroupAdmin -from django.contrib.auth.models import User, Group +from django.contrib.auth.admin import GroupAdmin, UserAdmin +from django.contrib.auth.models import Group, User from django.contrib.auth.urls import urlpatterns # Create a silo'd admin site for just the user/group admins. diff --git a/django/contrib/auth/tokens.py b/django/contrib/auth/tokens.py index 89100daeb2f..b925c21effa 100644 --- a/django/contrib/auth/tokens.py +++ b/django/contrib/auth/tokens.py @@ -1,8 +1,9 @@ from datetime import date + from django.conf import settings -from django.utils.http import int_to_base36, base36_to_int -from django.utils.crypto import constant_time_compare, salted_hmac from django.utils import six +from django.utils.crypto import constant_time_compare, salted_hmac +from django.utils.http import base36_to_int, int_to_base36 class PasswordResetTokenGenerator(object): diff --git a/django/contrib/auth/views.py b/django/contrib/auth/views.py index 348fca87456..deedb7f232a 100644 --- a/django/contrib/auth/views.py +++ b/django/contrib/auth/views.py @@ -1,25 +1,31 @@ import warnings from django.conf import settings +# Avoid shadowing the login() and logout() views below. +from django.contrib.auth import ( + REDIRECT_FIELD_NAME, get_user_model, login as auth_login, + logout as auth_logout, update_session_auth_hash, +) +from django.contrib.auth.decorators import login_required +from django.contrib.auth.forms import ( + AuthenticationForm, PasswordChangeForm, PasswordResetForm, SetPasswordForm, +) +from django.contrib.auth.tokens import default_token_generator +from django.contrib.sites.shortcuts import get_current_site from django.core.urlresolvers import reverse from django.http import HttpResponseRedirect, QueryDict +from django.shortcuts import resolve_url from django.template.response import TemplateResponse from django.utils.deprecation import RemovedInDjango20Warning from django.utils.http import is_safe_url, urlsafe_base64_decode -from django.utils.translation import ugettext as _ from django.utils.six.moves.urllib.parse import urlparse, urlunparse -from django.shortcuts import resolve_url -from django.views.decorators.debug import sensitive_post_parameters +from django.utils.translation import ugettext as _ from django.views.decorators.cache import never_cache from django.views.decorators.csrf import csrf_protect +from django.views.decorators.debug import sensitive_post_parameters + # Avoid shadowing the login() and logout() views below. -from django.contrib.auth import (REDIRECT_FIELD_NAME, login as auth_login, - logout as auth_logout, get_user_model, update_session_auth_hash) -from django.contrib.auth.decorators import login_required -from django.contrib.auth.forms import AuthenticationForm, PasswordResetForm, SetPasswordForm, PasswordChangeForm -from django.contrib.auth.tokens import default_token_generator -from django.contrib.sites.shortcuts import get_current_site @sensitive_post_parameters() diff --git a/django/contrib/contenttypes/admin.py b/django/contrib/contenttypes/admin.py index 3db9d2d612c..85bf3227e3f 100644 --- a/django/contrib/contenttypes/admin.py +++ b/django/contrib/contenttypes/admin.py @@ -6,7 +6,7 @@ from django.contrib.admin.checks import InlineModelAdminChecks from django.contrib.admin.options import InlineModelAdmin, flatten_fieldsets from django.contrib.contenttypes.fields import GenericForeignKey from django.contrib.contenttypes.forms import ( - BaseGenericInlineFormSet, generic_inlineformset_factory + BaseGenericInlineFormSet, generic_inlineformset_factory, ) from django.core import checks from django.core.exceptions import FieldDoesNotExist diff --git a/django/contrib/contenttypes/checks.py b/django/contrib/contenttypes/checks.py index 890859505a0..1b3df21353d 100644 --- a/django/contrib/contenttypes/checks.py +++ b/django/contrib/contenttypes/checks.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.utils import six from django.apps import apps +from django.utils import six def check_generic_foreign_keys(**kwargs): diff --git a/django/contrib/contenttypes/fields.py b/django/contrib/contenttypes/fields.py index b20d38768d2..c11d6284c0c 100644 --- a/django/contrib/contenttypes/fields.py +++ b/django/contrib/contenttypes/fields.py @@ -2,16 +2,15 @@ from __future__ import unicode_literals from collections import defaultdict +from django.contrib.contenttypes.models import ContentType from django.core import checks from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist -from django.db import connection -from django.db import models, router, transaction, DEFAULT_DB_ALIAS -from django.db.models import signals, DO_NOTHING +from django.db import DEFAULT_DB_ALIAS, connection, models, router, transaction +from django.db.models import DO_NOTHING, signals from django.db.models.base import ModelBase from django.db.models.fields.related import ForeignObject, ForeignObjectRel from django.db.models.query_utils import PathInfo -from django.contrib.contenttypes.models import ContentType -from django.utils.encoding import smart_text, python_2_unicode_compatible +from django.utils.encoding import python_2_unicode_compatible, smart_text @python_2_unicode_compatible diff --git a/django/contrib/contenttypes/forms.py b/django/contrib/contenttypes/forms.py index 693628d3deb..e590c3db05f 100644 --- a/django/contrib/contenttypes/forms.py +++ b/django/contrib/contenttypes/forms.py @@ -1,9 +1,9 @@ from __future__ import unicode_literals +from django.contrib.contenttypes.models import ContentType from django.db import models from django.forms import ModelForm, modelformset_factory from django.forms.models import BaseModelFormSet -from django.contrib.contenttypes.models import ContentType class BaseGenericInlineFormSet(BaseModelFormSet): diff --git a/django/contrib/contenttypes/migrations/0001_initial.py b/django/contrib/contenttypes/migrations/0001_initial.py index 09519f1d75a..68190b2a2b3 100644 --- a/django/contrib/contenttypes/migrations/0001_initial.py +++ b/django/contrib/contenttypes/migrations/0001_initial.py @@ -1,8 +1,8 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations import django.contrib.contenttypes.models +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py b/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py index 1b91437dbc5..b2e18846b9a 100644 --- a/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py +++ b/django/contrib/contenttypes/migrations/0002_remove_content_type_name.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations, models def add_legacy_name(apps, schema_editor): diff --git a/django/contrib/contenttypes/models.py b/django/contrib/contenttypes/models.py index 684380c8324..5205ec80f9d 100644 --- a/django/contrib/contenttypes/models.py +++ b/django/contrib/contenttypes/models.py @@ -5,9 +5,9 @@ import warnings from django.apps import apps from django.db import models from django.db.utils import OperationalError, ProgrammingError -from django.utils.translation import ugettext_lazy as _ from django.utils.deprecation import RemovedInDjango20Warning from django.utils.encoding import force_text, python_2_unicode_compatible +from django.utils.translation import ugettext_lazy as _ class ContentTypeManager(models.Manager): diff --git a/django/contrib/contenttypes/tests/tests.py b/django/contrib/contenttypes/tests/tests.py index f41732b6b5d..aed559c5fda 100644 --- a/django/contrib/contenttypes/tests/tests.py +++ b/django/contrib/contenttypes/tests/tests.py @@ -6,11 +6,14 @@ from django.contrib.contenttypes.models import ContentType from django.contrib.contenttypes.views import shortcut from django.contrib.sites.shortcuts import get_current_site from django.core.management import call_command -from django.http import HttpRequest, Http404 +from django.http import Http404, HttpRequest from django.test import TestCase, override_settings, skipUnlessDBFeature from django.utils import six -from .models import ConcreteModel, ProxyModel, FooWithoutUrl, FooWithUrl, FooWithBrokenAbsoluteUrl +from .models import ( + ConcreteModel, FooWithBrokenAbsoluteUrl, FooWithoutUrl, FooWithUrl, + ProxyModel, +) class ContentTypesTests(TestCase): diff --git a/django/contrib/flatpages/admin.py b/django/contrib/flatpages/admin.py index 5711a9466e0..06ed824c45d 100644 --- a/django/contrib/flatpages/admin.py +++ b/django/contrib/flatpages/admin.py @@ -1,7 +1,7 @@ from django.contrib import admin +from django.contrib.flatpages.forms import FlatpageForm from django.contrib.flatpages.models import FlatPage from django.utils.translation import ugettext_lazy as _ -from django.contrib.flatpages.forms import FlatpageForm class FlatPageAdmin(admin.ModelAdmin): diff --git a/django/contrib/flatpages/apps.py b/django/contrib/flatpages/apps.py index c35bebf721a..ac966c81f5b 100644 --- a/django/contrib/flatpages/apps.py +++ b/django/contrib/flatpages/apps.py @@ -1,5 +1,4 @@ from django.apps import AppConfig - from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/flatpages/middleware.py b/django/contrib/flatpages/middleware.py index 9fe595d0cf9..32d881ffa4a 100644 --- a/django/contrib/flatpages/middleware.py +++ b/django/contrib/flatpages/middleware.py @@ -1,6 +1,6 @@ +from django.conf import settings from django.contrib.flatpages.views import flatpage from django.http import Http404 -from django.conf import settings class FlatpageFallbackMiddleware(object): diff --git a/django/contrib/flatpages/migrations/0001_initial.py b/django/contrib/flatpages/migrations/0001_initial.py index 5f583a1051c..fe0a3f33740 100644 --- a/django/contrib/flatpages/migrations/0001_initial.py +++ b/django/contrib/flatpages/migrations/0001_initial.py @@ -1,7 +1,7 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from django.db import models, migrations +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/flatpages/models.py b/django/contrib/flatpages/models.py index 1bddb0b8d22..eac4edd122e 100644 --- a/django/contrib/flatpages/models.py +++ b/django/contrib/flatpages/models.py @@ -1,10 +1,10 @@ from __future__ import unicode_literals -from django.db import models from django.contrib.sites.models import Site from django.core.urlresolvers import get_script_prefix -from django.utils.translation import ugettext_lazy as _ +from django.db import models from django.utils.encoding import iri_to_uri, python_2_unicode_compatible +from django.utils.translation import ugettext_lazy as _ @python_2_unicode_compatible diff --git a/django/contrib/flatpages/templatetags/flatpages.py b/django/contrib/flatpages/templatetags/flatpages.py index d7ced97d179..db82c4aa2c1 100644 --- a/django/contrib/flatpages/templatetags/flatpages.py +++ b/django/contrib/flatpages/templatetags/flatpages.py @@ -3,7 +3,6 @@ from django.conf import settings from django.contrib.flatpages.models import FlatPage from django.contrib.sites.shortcuts import get_current_site - register = template.Library() diff --git a/django/contrib/flatpages/tests/settings.py b/django/contrib/flatpages/tests/settings.py index b10ebe564c5..ad888f9d95e 100644 --- a/django/contrib/flatpages/tests/settings.py +++ b/django/contrib/flatpages/tests/settings.py @@ -1,6 +1,5 @@ import os - FLATPAGES_TEMPLATES = [{ 'BACKEND': 'django.template.backends.django.DjangoTemplates', 'DIRS': [os.path.join(os.path.dirname(__file__), 'templates')], diff --git a/django/contrib/flatpages/tests/test_csrf.py b/django/contrib/flatpages/tests/test_csrf.py index b9d7f323272..f8616b39139 100644 --- a/django/contrib/flatpages/tests/test_csrf.py +++ b/django/contrib/flatpages/tests/test_csrf.py @@ -1,7 +1,6 @@ from django.contrib.auth.models import User from django.contrib.auth.tests.utils import skipIfCustomUser -from django.test import TestCase, Client -from django.test import override_settings +from django.test import Client, TestCase, override_settings from .settings import FLATPAGES_TEMPLATES diff --git a/django/contrib/flatpages/tests/test_models.py b/django/contrib/flatpages/tests/test_models.py index f091f3e0eaa..c48dc38637f 100644 --- a/django/contrib/flatpages/tests/test_models.py +++ b/django/contrib/flatpages/tests/test_models.py @@ -2,8 +2,8 @@ from __future__ import unicode_literals -from django.core.urlresolvers import set_script_prefix, clear_script_prefix from django.contrib.flatpages.models import FlatPage +from django.core.urlresolvers import clear_script_prefix, set_script_prefix from django.test import TestCase diff --git a/django/contrib/flatpages/tests/test_templatetags.py b/django/contrib/flatpages/tests/test_templatetags.py index a4a65ce8405..209332b79c4 100644 --- a/django/contrib/flatpages/tests/test_templatetags.py +++ b/django/contrib/flatpages/tests/test_templatetags.py @@ -1,6 +1,6 @@ from django.contrib.auth.models import AnonymousUser, User from django.contrib.auth.tests.utils import skipIfCustomUser -from django.template import Template, Context, TemplateSyntaxError +from django.template import Context, Template, TemplateSyntaxError from django.test import TestCase, override_settings from .settings import FLATPAGES_TEMPLATES diff --git a/django/contrib/gis/admin/options.py b/django/contrib/gis/admin/options.py index 8ca0d92c295..f9412336e35 100644 --- a/django/contrib/gis/admin/options.py +++ b/django/contrib/gis/admin/options.py @@ -1,7 +1,7 @@ from django.contrib.admin import ModelAdmin from django.contrib.gis.admin.widgets import OpenLayersWidget -from django.contrib.gis.gdal import HAS_GDAL, OGRGeomType from django.contrib.gis.db import models +from django.contrib.gis.gdal import HAS_GDAL, OGRGeomType class GeoModelAdmin(ModelAdmin): diff --git a/django/contrib/gis/admin/widgets.py b/django/contrib/gis/admin/widgets.py index c85e7a61259..52b624a112e 100644 --- a/django/contrib/gis/admin/widgets.py +++ b/django/contrib/gis/admin/widgets.py @@ -1,12 +1,10 @@ import logging +from django.contrib.gis.gdal import GDALException +from django.contrib.gis.geos import GEOSException, GEOSGeometry from django.forms.widgets import Textarea from django.template import loader -from django.utils import six -from django.utils import translation - -from django.contrib.gis.gdal import GDALException -from django.contrib.gis.geos import GEOSGeometry, GEOSException +from django.utils import six, translation # Creating a template context that contains Django settings # values needed by admin map templates. diff --git a/django/contrib/gis/apps.py b/django/contrib/gis/apps.py index 6ca51e9b422..919272b064c 100644 --- a/django/contrib/gis/apps.py +++ b/django/contrib/gis/apps.py @@ -1,6 +1,5 @@ from django.apps import AppConfig from django.core import serializers - from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/gis/db/backends/mysql/base.py b/django/contrib/gis/db/backends/mysql/base.py index afeed42203f..d252b38804f 100644 --- a/django/contrib/gis/db/backends/mysql/base.py +++ b/django/contrib/gis/db/backends/mysql/base.py @@ -1,4 +1,5 @@ -from django.db.backends.mysql.base import DatabaseWrapper as MySQLDatabaseWrapper +from django.db.backends.mysql.base import \ + DatabaseWrapper as MySQLDatabaseWrapper from .features import DatabaseFeatures from .introspection import MySQLIntrospection diff --git a/django/contrib/gis/db/backends/mysql/features.py b/django/contrib/gis/db/backends/mysql/features.py index 02c611b2923..a547ec967a5 100644 --- a/django/contrib/gis/db/backends/mysql/features.py +++ b/django/contrib/gis/db/backends/mysql/features.py @@ -1,5 +1,6 @@ from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures -from django.db.backends.mysql.features import DatabaseFeatures as MySQLDatabaseFeatures +from django.db.backends.mysql.features import \ + DatabaseFeatures as MySQLDatabaseFeatures class DatabaseFeatures(BaseSpatialFeatures, MySQLDatabaseFeatures): diff --git a/django/contrib/gis/db/backends/mysql/operations.py b/django/contrib/gis/db/backends/mysql/operations.py index 9d0d2a99280..130c103ac27 100644 --- a/django/contrib/gis/db/backends/mysql/operations.py +++ b/django/contrib/gis/db/backends/mysql/operations.py @@ -1,5 +1,6 @@ from django.contrib.gis.db.backends.base.adapter import WKTAdapter -from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations +from django.contrib.gis.db.backends.base.operations import \ + BaseSpatialOperations from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.db.models import aggregates from django.db.backends.mysql.operations import DatabaseOperations diff --git a/django/contrib/gis/db/backends/mysql/schema.py b/django/contrib/gis/db/backends/mysql/schema.py index 4d708686bae..e60f3d2fcc0 100644 --- a/django/contrib/gis/db/backends/mysql/schema.py +++ b/django/contrib/gis/db/backends/mysql/schema.py @@ -1,8 +1,8 @@ import logging from django.contrib.gis.db.models.fields import GeometryField -from django.db.utils import OperationalError from django.db.backends.mysql.schema import DatabaseSchemaEditor +from django.db.utils import OperationalError logger = logging.getLogger('django.contrib.gis') diff --git a/django/contrib/gis/db/backends/oracle/adapter.py b/django/contrib/gis/db/backends/oracle/adapter.py index e26603e531f..60961af817f 100644 --- a/django/contrib/gis/db/backends/oracle/adapter.py +++ b/django/contrib/gis/db/backends/oracle/adapter.py @@ -1,4 +1,5 @@ from cx_Oracle import CLOB + from django.contrib.gis.db.backends.base.adapter import WKTAdapter diff --git a/django/contrib/gis/db/backends/oracle/base.py b/django/contrib/gis/db/backends/oracle/base.py index d20ac2a9e75..167b61d01bb 100644 --- a/django/contrib/gis/db/backends/oracle/base.py +++ b/django/contrib/gis/db/backends/oracle/base.py @@ -1,4 +1,5 @@ -from django.db.backends.oracle.base import DatabaseWrapper as OracleDatabaseWrapper +from django.db.backends.oracle.base import \ + DatabaseWrapper as OracleDatabaseWrapper from .features import DatabaseFeatures from .introspection import OracleIntrospection diff --git a/django/contrib/gis/db/backends/oracle/features.py b/django/contrib/gis/db/backends/oracle/features.py index ef56ec627dd..df0aedcf325 100644 --- a/django/contrib/gis/db/backends/oracle/features.py +++ b/django/contrib/gis/db/backends/oracle/features.py @@ -1,5 +1,6 @@ from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures -from django.db.backends.oracle.features import DatabaseFeatures as OracleDatabaseFeatures +from django.db.backends.oracle.features import \ + DatabaseFeatures as OracleDatabaseFeatures class DatabaseFeatures(BaseSpatialFeatures, OracleDatabaseFeatures): diff --git a/django/contrib/gis/db/backends/oracle/introspection.py b/django/contrib/gis/db/backends/oracle/introspection.py index 53a449bb5a1..764ce7d2431 100644 --- a/django/contrib/gis/db/backends/oracle/introspection.py +++ b/django/contrib/gis/db/backends/oracle/introspection.py @@ -1,5 +1,7 @@ -import cx_Oracle import sys + +import cx_Oracle + from django.db.backends.oracle.introspection import DatabaseIntrospection from django.utils import six diff --git a/django/contrib/gis/db/backends/oracle/operations.py b/django/contrib/gis/db/backends/oracle/operations.py index 277126a77ee..9d405056322 100644 --- a/django/contrib/gis/db/backends/oracle/operations.py +++ b/django/contrib/gis/db/backends/oracle/operations.py @@ -9,7 +9,8 @@ """ import re -from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations +from django.contrib.gis.db.backends.base.operations import \ + BaseSpatialOperations from django.contrib.gis.db.backends.oracle.adapter import OracleSpatialAdapter from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.db.models import aggregates @@ -19,7 +20,6 @@ from django.db.backends.oracle.base import Database from django.db.backends.oracle.operations import DatabaseOperations from django.utils import six - DEFAULT_TOLERANCE = '0.05' diff --git a/django/contrib/gis/db/backends/postgis/base.py b/django/contrib/gis/db/backends/postgis/base.py index 083f76d0a8c..8d17b16c122 100644 --- a/django/contrib/gis/db/backends/postgis/base.py +++ b/django/contrib/gis/db/backends/postgis/base.py @@ -1,8 +1,7 @@ from django.conf import settings from django.db.backends.base.base import NO_DB_ALIAS -from django.db.backends.postgresql_psycopg2.base import ( - DatabaseWrapper as Psycopg2DatabaseWrapper, -) +from django.db.backends.postgresql_psycopg2.base import \ + DatabaseWrapper as Psycopg2DatabaseWrapper from django.utils.functional import cached_property from .creation import PostGISCreation diff --git a/django/contrib/gis/db/backends/postgis/features.py b/django/contrib/gis/db/backends/postgis/features.py index dfa225c6e7a..1cc15bde38d 100644 --- a/django/contrib/gis/db/backends/postgis/features.py +++ b/django/contrib/gis/db/backends/postgis/features.py @@ -1,7 +1,6 @@ from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures -from django.db.backends.postgresql_psycopg2.features import ( - DatabaseFeatures as Psycopg2DatabaseFeatures, -) +from django.db.backends.postgresql_psycopg2.features import \ + DatabaseFeatures as Psycopg2DatabaseFeatures class DatabaseFeatures(BaseSpatialFeatures, Psycopg2DatabaseFeatures): diff --git a/django/contrib/gis/db/backends/postgis/introspection.py b/django/contrib/gis/db/backends/postgis/introspection.py index 631844a0302..5e08b2f9ce1 100644 --- a/django/contrib/gis/db/backends/postgis/introspection.py +++ b/django/contrib/gis/db/backends/postgis/introspection.py @@ -1,5 +1,6 @@ -from django.db.backends.postgresql_psycopg2.introspection import DatabaseIntrospection from django.contrib.gis.gdal import OGRGeomType +from django.db.backends.postgresql_psycopg2.introspection import \ + DatabaseIntrospection class GeoIntrospectionError(Exception): diff --git a/django/contrib/gis/db/backends/postgis/models.py b/django/contrib/gis/db/backends/postgis/models.py index a438ffcc20a..83b254cb39f 100644 --- a/django/contrib/gis/db/backends/postgis/models.py +++ b/django/contrib/gis/db/backends/postgis/models.py @@ -1,8 +1,8 @@ """ The GeometryColumns and SpatialRefSys models for the PostGIS backend. """ -from django.db import models from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin +from django.db import models from django.utils.encoding import python_2_unicode_compatible diff --git a/django/contrib/gis/db/backends/postgis/operations.py b/django/contrib/gis/db/backends/postgis/operations.py index 2255897f2f2..e0af0c1ecb2 100644 --- a/django/contrib/gis/db/backends/postgis/operations.py +++ b/django/contrib/gis/db/backends/postgis/operations.py @@ -1,13 +1,15 @@ import re from django.conf import settings -from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations +from django.contrib.gis.db.backends.base.operations import \ + BaseSpatialOperations from django.contrib.gis.db.backends.postgis.adapter import PostGISAdapter from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.geometry.backend import Geometry from django.contrib.gis.measure import Distance from django.core.exceptions import ImproperlyConfigured -from django.db.backends.postgresql_psycopg2.operations import DatabaseOperations +from django.db.backends.postgresql_psycopg2.operations import \ + DatabaseOperations from django.db.utils import ProgrammingError from django.utils.functional import cached_property diff --git a/django/contrib/gis/db/backends/spatialite/adapter.py b/django/contrib/gis/db/backends/spatialite/adapter.py index 70ad9000467..c1184f4685f 100644 --- a/django/contrib/gis/db/backends/spatialite/adapter.py +++ b/django/contrib/gis/db/backends/spatialite/adapter.py @@ -1,5 +1,5 @@ -from django.db.backends.sqlite3.base import Database from django.contrib.gis.db.backends.base.adapter import WKTAdapter +from django.db.backends.sqlite3.base import Database class SpatiaLiteAdapter(WKTAdapter): diff --git a/django/contrib/gis/db/backends/spatialite/features.py b/django/contrib/gis/db/backends/spatialite/features.py index 4ab382e00bb..613087b51ec 100644 --- a/django/contrib/gis/db/backends/spatialite/features.py +++ b/django/contrib/gis/db/backends/spatialite/features.py @@ -1,5 +1,6 @@ from django.contrib.gis.db.backends.base.features import BaseSpatialFeatures -from django.db.backends.sqlite3.features import DatabaseFeatures as SQLiteDatabaseFeatures +from django.db.backends.sqlite3.features import \ + DatabaseFeatures as SQLiteDatabaseFeatures from django.utils.functional import cached_property diff --git a/django/contrib/gis/db/backends/spatialite/introspection.py b/django/contrib/gis/db/backends/spatialite/introspection.py index b81a2e4089d..c1ed7629b9b 100644 --- a/django/contrib/gis/db/backends/spatialite/introspection.py +++ b/django/contrib/gis/db/backends/spatialite/introspection.py @@ -1,5 +1,7 @@ from django.contrib.gis.gdal import OGRGeomType -from django.db.backends.sqlite3.introspection import DatabaseIntrospection, FlexibleFieldLookupDict +from django.db.backends.sqlite3.introspection import ( + DatabaseIntrospection, FlexibleFieldLookupDict, +) from django.utils import six diff --git a/django/contrib/gis/db/backends/spatialite/models.py b/django/contrib/gis/db/backends/spatialite/models.py index a1f0f2d44b6..d1b58b75826 100644 --- a/django/contrib/gis/db/backends/spatialite/models.py +++ b/django/contrib/gis/db/backends/spatialite/models.py @@ -1,10 +1,10 @@ """ The GeometryColumns and SpatialRefSys models for the SpatiaLite backend. """ -from django.db import connection, models -from django.db.backends.signals import connection_created from django.contrib.gis.db.backends.base.models import SpatialRefSysMixin from django.contrib.gis.db.backends.spatialite.base import DatabaseWrapper +from django.db import connection, models +from django.db.backends.signals import connection_created from django.utils.encoding import python_2_unicode_compatible diff --git a/django/contrib/gis/db/backends/spatialite/operations.py b/django/contrib/gis/db/backends/spatialite/operations.py index c4700e7aef6..73adb02b052 100644 --- a/django/contrib/gis/db/backends/spatialite/operations.py +++ b/django/contrib/gis/db/backends/spatialite/operations.py @@ -1,9 +1,10 @@ import re import sys -from django.contrib.gis.db.backends.base.operations import BaseSpatialOperations -from django.contrib.gis.db.backends.utils import SpatialOperator +from django.contrib.gis.db.backends.base.operations import \ + BaseSpatialOperations from django.contrib.gis.db.backends.spatialite.adapter import SpatiaLiteAdapter +from django.contrib.gis.db.backends.utils import SpatialOperator from django.contrib.gis.db.models import aggregates from django.contrib.gis.geometry.backend import Geometry from django.contrib.gis.measure import Distance diff --git a/django/contrib/gis/db/backends/spatialite/schema.py b/django/contrib/gis/db/backends/spatialite/schema.py index e067bfc03b1..bdf2b937402 100644 --- a/django/contrib/gis/db/backends/spatialite/schema.py +++ b/django/contrib/gis/db/backends/spatialite/schema.py @@ -1,5 +1,5 @@ -from django.db.utils import DatabaseError from django.db.backends.sqlite3.schema import DatabaseSchemaEditor +from django.db.utils import DatabaseError class SpatialiteSchemaEditor(DatabaseSchemaEditor): diff --git a/django/contrib/gis/db/models/aggregates.py b/django/contrib/gis/db/models/aggregates.py index 42198d9287c..60954951e67 100644 --- a/django/contrib/gis/db/models/aggregates.py +++ b/django/contrib/gis/db/models/aggregates.py @@ -1,5 +1,5 @@ -from django.db.models.aggregates import Aggregate from django.contrib.gis.db.models.fields import ExtentField +from django.db.models.aggregates import Aggregate __all__ = ['Collect', 'Extent', 'Extent3D', 'MakeLine', 'Union'] diff --git a/django/contrib/gis/db/models/fields.py b/django/contrib/gis/db/models/fields.py index 5e70697a2b8..af6d3da9722 100644 --- a/django/contrib/gis/db/models/fields.py +++ b/django/contrib/gis/db/models/fields.py @@ -1,11 +1,11 @@ -from django.db.models.fields import Field -from django.db.models.expressions import ExpressionNode -from django.utils.translation import ugettext_lazy as _ from django.contrib.gis import forms from django.contrib.gis.db.models.lookups import gis_lookups from django.contrib.gis.db.models.proxy import GeometryProxy from django.contrib.gis.geometry.backend import Geometry, GeometryException +from django.db.models.expressions import ExpressionNode +from django.db.models.fields import Field from django.utils import six +from django.utils.translation import ugettext_lazy as _ # Local cache of the spatial_ref_sys table, which holds SRID data for each # spatial database alias. This cache exists so that the database isn't queried diff --git a/django/contrib/gis/db/models/lookups.py b/django/contrib/gis/db/models/lookups.py index eb64eff6c7e..b739e468cef 100644 --- a/django/contrib/gis/db/models/lookups.py +++ b/django/contrib/gis/db/models/lookups.py @@ -1,10 +1,11 @@ from __future__ import unicode_literals + import re from django.core.exceptions import FieldDoesNotExist from django.db.models.constants import LOOKUP_SEP +from django.db.models.expressions import Col, ExpressionNode from django.db.models.lookups import Lookup -from django.db.models.expressions import ExpressionNode, Col from django.utils import six gis_lookups = {} diff --git a/django/contrib/gis/db/models/manager.py b/django/contrib/gis/db/models/manager.py index 609bdf36379..22d009a972e 100644 --- a/django/contrib/gis/db/models/manager.py +++ b/django/contrib/gis/db/models/manager.py @@ -1,5 +1,5 @@ -from django.db.models.manager import Manager from django.contrib.gis.db.models.query import GeoQuerySet +from django.db.models.manager import Manager class GeoManager(Manager.from_queryset(GeoQuerySet)): diff --git a/django/contrib/gis/db/models/query.py b/django/contrib/gis/db/models/query.py index c36381ecaa9..998acff79cc 100644 --- a/django/contrib/gis/db/models/query.py +++ b/django/contrib/gis/db/models/query.py @@ -1,13 +1,8 @@ import warnings -from django.db import connections -from django.db.models.expressions import RawSQL -from django.db.models.fields import Field -from django.db.models.query import QuerySet - from django.contrib.gis.db.models import aggregates from django.contrib.gis.db.models.fields import ( - get_srid_info, LineStringField, GeometryField, PointField, + GeometryField, LineStringField, PointField, get_srid_info, ) from django.contrib.gis.db.models.lookups import GISLookup from django.contrib.gis.db.models.sql import ( @@ -15,7 +10,10 @@ from django.contrib.gis.db.models.sql import ( ) from django.contrib.gis.geometry.backend import Geometry from django.contrib.gis.measure import Area, Distance - +from django.db import connections +from django.db.models.expressions import RawSQL +from django.db.models.fields import Field +from django.db.models.query import QuerySet from django.utils import six from django.utils.deprecation import RemovedInDjango20Warning diff --git a/django/contrib/gis/db/models/sql/aggregates.py b/django/contrib/gis/db/models/sql/aggregates.py index fe0e396f2f3..b83bafda707 100644 --- a/django/contrib/gis/db/models/sql/aggregates.py +++ b/django/contrib/gis/db/models/sql/aggregates.py @@ -1,7 +1,6 @@ from django.db.models.sql import aggregates from django.db.models.sql.aggregates import * # NOQA - __all__ = ['Collect', 'Extent', 'Extent3D', 'MakeLine', 'Union'] + aggregates.__all__ diff --git a/django/contrib/gis/forms/fields.py b/django/contrib/gis/forms/fields.py index af481b8be75..4ae56de88bf 100644 --- a/django/contrib/gis/forms/fields.py +++ b/django/contrib/gis/forms/fields.py @@ -1,11 +1,9 @@ from __future__ import unicode_literals from django import forms +from django.contrib.gis.geos import GEOSException, GEOSGeometry from django.utils.translation import ugettext_lazy as _ -# While this couples the geographic forms to the GEOS library, -# it decouples from database (by not importing SpatialBackend). -from django.contrib.gis.geos import GEOSException, GEOSGeometry from .widgets import OpenLayersWidget diff --git a/django/contrib/gis/forms/widgets.py b/django/contrib/gis/forms/widgets.py index 26cc0565b0f..37c9be8fbc5 100644 --- a/django/contrib/gis/forms/widgets.py +++ b/django/contrib/gis/forms/widgets.py @@ -4,11 +4,10 @@ import logging from django.conf import settings from django.contrib.gis import gdal -from django.contrib.gis.geos import GEOSGeometry, GEOSException +from django.contrib.gis.geos import GEOSException, GEOSGeometry from django.forms.widgets import Widget from django.template import loader -from django.utils import six -from django.utils import translation +from django.utils import six, translation logger = logging.getLogger('django.contrib.gis') diff --git a/django/contrib/gis/gdal/datasource.py b/django/contrib/gis/gdal/datasource.py index ec9ab8c2a40..d574839cf45 100644 --- a/django/contrib/gis/gdal/datasource.py +++ b/django/contrib/gis/gdal/datasource.py @@ -33,20 +33,15 @@ # OFTReal returns floats, all else returns string. val = field.value """ -# ctypes prerequisites. from ctypes import byref -# The GDAL C library, OGR exceptions, and the Layer object. from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.driver import Driver from django.contrib.gis.gdal.error import GDALException, OGRIndexError from django.contrib.gis.gdal.layer import Layer - -# Getting the ctypes prototypes for the DataSource. from django.contrib.gis.gdal.prototypes import ds as capi - -from django.utils.encoding import force_bytes, force_text from django.utils import six +from django.utils.encoding import force_bytes, force_text from django.utils.six.moves import range diff --git a/django/contrib/gis/gdal/driver.py b/django/contrib/gis/gdal/driver.py index 7628e360b9e..51d0c9fe33d 100644 --- a/django/contrib/gis/gdal/driver.py +++ b/django/contrib/gis/gdal/driver.py @@ -1,8 +1,8 @@ from ctypes import c_void_p + from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.error import GDALException from django.contrib.gis.gdal.prototypes import ds as vcapi, raster as rcapi - from django.utils import six from django.utils.encoding import force_bytes, force_text diff --git a/django/contrib/gis/gdal/envelope.py b/django/contrib/gis/gdal/envelope.py index 59d48b7bff1..ae9ba434e7c 100644 --- a/django/contrib/gis/gdal/envelope.py +++ b/django/contrib/gis/gdal/envelope.py @@ -11,6 +11,7 @@ Lower left (min_x, min_y) o----------+ """ from ctypes import Structure, c_double + from django.contrib.gis.gdal.error import GDALException diff --git a/django/contrib/gis/gdal/feature.py b/django/contrib/gis/gdal/feature.py index da86c702446..ce46ae52099 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 487c29ea420..599ee60bf3a 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 d00aa1a7857..e9abfbf4397 100644 --- a/django/contrib/gis/gdal/geometries.py +++ b/django/contrib/gis/gdal/geometries.py @@ -38,33 +38,27 @@ >>> print(gt1 == 3, gt1 == 'Polygon') # Equivalence works w/non-OGRGeomType objects True True """ -# Python library requisites. import sys from binascii import a2b_hex, b2a_hex -from ctypes import byref, string_at, c_char_p, c_double, c_ubyte, c_void_p +from ctypes import byref, c_char_p, c_double, c_ubyte, c_void_p, string_at -# Getting GDAL prerequisites from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.envelope import Envelope, OGREnvelope -from django.contrib.gis.gdal.error import GDALException, OGRIndexError, SRSException +from django.contrib.gis.gdal.error import ( + GDALException, OGRIndexError, SRSException, +) from django.contrib.gis.gdal.geomtype import OGRGeomType -from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform - -# Getting the ctypes prototype functions that interface w/the GDAL C library. from django.contrib.gis.gdal.prototypes import geom as capi, srs as srs_api - -# For recognizing geometry input. -from django.contrib.gis.geometry.regex import hex_regex, wkt_regex, json_regex - +from django.contrib.gis.gdal.srs import CoordTransform, SpatialReference +from django.contrib.gis.geometry.regex import hex_regex, json_regex, wkt_regex from django.utils import six from django.utils.six.moves import range + # For more information, see the OGR C API source code: # http://www.gdal.org/ogr/ogr__api_8h.html # # The OGR_G_* routines are relevant here. - - class OGRGeometry(GDALBase): "Generally encapsulates an OGR geometry." diff --git a/django/contrib/gis/gdal/geomtype.py b/django/contrib/gis/gdal/geomtype.py index 9a06bad7899..abb184e2f93 100644 --- a/django/contrib/gis/gdal/geomtype.py +++ b/django/contrib/gis/gdal/geomtype.py @@ -1,5 +1,4 @@ from django.contrib.gis.gdal.error import GDALException - from django.utils import six diff --git a/django/contrib/gis/gdal/layer.py b/django/contrib/gis/gdal/layer.py index e2627a2da97..640d2ad938d 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 280ae2ef5b7..4f8224c19f8 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 69257a11405..2f79f7316eb 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 d6c5ad17ebc..edc40529ed5 100644 --- a/django/contrib/gis/gdal/prototypes/errcheck.py +++ b/django/contrib/gis/gdal/prototypes/errcheck.py @@ -4,7 +4,9 @@ """ from ctypes import c_void_p, string_at -from django.contrib.gis.gdal.error import check_err, GDALException, SRSException +from django.contrib.gis.gdal.error import ( + GDALException, SRSException, check_err, +) from django.contrib.gis.gdal.libgdal import lgdal from django.utils import six diff --git a/django/contrib/gis/gdal/prototypes/generation.py b/django/contrib/gis/gdal/prototypes/generation.py index 79b7b47825e..39bf621796d 100644 --- a/django/contrib/gis/gdal/prototypes/generation.py +++ b/django/contrib/gis/gdal/prototypes/generation.py @@ -4,9 +4,11 @@ """ from ctypes import c_char_p, c_double, c_int, c_void_p from functools import partial + from django.contrib.gis.gdal.prototypes.errcheck import ( - check_arg_errcode, check_errcode, check_geom, check_geom_offset, - check_pointer, check_srs, check_str_arg, check_string, check_const_string) + check_arg_errcode, check_const_string, check_errcode, check_geom, + check_geom_offset, check_pointer, check_srs, check_str_arg, check_string, +) class gdal_char_p(c_char_p): diff --git a/django/contrib/gis/gdal/prototypes/geom.py b/django/contrib/gis/gdal/prototypes/geom.py index 22ff1ed833e..6d6412c5469 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 db32ee1e0b0..5e07c76955e 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 71ec1ed603b..7ab22024ed3 100644 --- a/django/contrib/gis/gdal/prototypes/srs.py +++ b/django/contrib/gis/gdal/prototypes/srs.py @@ -1,7 +1,10 @@ -from ctypes import c_char_p, c_int, c_void_p, POINTER +from ctypes import POINTER, c_char_p, c_int, c_void_p + from django.contrib.gis.gdal.libgdal import lgdal, std_call -from django.contrib.gis.gdal.prototypes.generation import (const_string_output, - double_output, int_output, srs_output, string_output, void_output) +from django.contrib.gis.gdal.prototypes.generation import ( + const_string_output, double_output, int_output, srs_output, string_output, + void_output, +) ## Shortcut generation for routines with known parameters. diff --git a/django/contrib/gis/gdal/raster/source.py b/django/contrib/gis/gdal/raster/source.py index e89e70d2e89..bb72db49ee1 100644 --- a/django/contrib/gis/gdal/raster/source.py +++ b/django/contrib/gis/gdal/raster/source.py @@ -1,5 +1,5 @@ -from ctypes import addressof, byref, c_double import os +from ctypes import addressof, byref, c_double from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.driver import Driver @@ -8,10 +8,11 @@ from django.contrib.gis.gdal.prototypes import raster as capi from django.contrib.gis.gdal.raster.band import GDALBand from django.contrib.gis.gdal.srs import SpatialReference, SRSException from django.utils import six -from django.utils.six.moves import range -from django.utils.encoding import (force_bytes, force_text, - python_2_unicode_compatible) +from django.utils.encoding import ( + force_bytes, force_text, python_2_unicode_compatible, +) from django.utils.functional import cached_property +from django.utils.six.moves import range class TransformPoint(list): diff --git a/django/contrib/gis/gdal/srs.py b/django/contrib/gis/gdal/srs.py index 8749d079b3b..265ea000c2e 100644 --- a/django/contrib/gis/gdal/srs.py +++ b/django/contrib/gis/gdal/srs.py @@ -28,16 +28,13 @@ """ from ctypes import byref, c_char_p, c_int -# Getting the error checking routine and exceptions from django.contrib.gis.gdal.base import GDALBase from django.contrib.gis.gdal.error import SRSException from django.contrib.gis.gdal.prototypes import srs as capi - from django.utils import six from django.utils.encoding import force_bytes, force_text -#### Spatial Reference class. #### class SpatialReference(GDALBase): """ A wrapper for the OGRSpatialReference object. According to the GDAL Web site, diff --git a/django/contrib/gis/gdal/tests/test_ds.py b/django/contrib/gis/gdal/tests/test_ds.py index 04b1c0f982a..ef62c160cc0 100644 --- a/django/contrib/gis/gdal/tests/test_ds.py +++ b/django/contrib/gis/gdal/tests/test_ds.py @@ -3,7 +3,9 @@ import unittest from unittest import skipUnless from django.contrib.gis.gdal import HAS_GDAL -from django.contrib.gis.geometry.test_data import get_ds_file, TestDS, TEST_DATA +from django.contrib.gis.geometry.test_data import ( + TEST_DATA, TestDS, get_ds_file, +) if HAS_GDAL: from django.contrib.gis.gdal import DataSource, Envelope, OGRGeometry, GDALException, OGRIndexError, GDAL_VERSION diff --git a/django/contrib/gis/gdal/tests/test_geom.py b/django/contrib/gis/gdal/tests/test_geom.py index 4f422c06f63..56962235546 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 9409019d940..a2787af471f 100644 --- a/django/contrib/gis/geoip/base.py +++ b/django/contrib/gis/geoip/base.py @@ -2,14 +2,14 @@ import os import re from ctypes import c_char_p -from django.core.validators import ipv4_re from django.contrib.gis.geoip.libgeoip import GEOIP_SETTINGS from django.contrib.gis.geoip.prototypes import ( - GeoIP_open, GeoIP_delete, GeoIP_database_info, - GeoIP_lib_version, GeoIP_record_by_addr, GeoIP_record_by_name, GeoIP_country_code_by_addr, GeoIP_country_code_by_name, - GeoIP_country_name_by_addr, GeoIP_country_name_by_name) - + GeoIP_country_name_by_addr, GeoIP_country_name_by_name, + GeoIP_database_info, GeoIP_delete, GeoIP_lib_version, GeoIP_open, + GeoIP_record_by_addr, GeoIP_record_by_name, +) +from django.core.validators import ipv4_re from django.utils import six from django.utils.encoding import force_bytes diff --git a/django/contrib/gis/geoip/libgeoip.py b/django/contrib/gis/geoip/libgeoip.py index cc4d92c7d02..a6023ff2293 100644 --- a/django/contrib/gis/geoip/libgeoip.py +++ b/django/contrib/gis/geoip/libgeoip.py @@ -1,6 +1,7 @@ import os from ctypes import CDLL from ctypes.util import find_library + from django.conf import settings # Creating the settings dictionary with any settings, if needed. diff --git a/django/contrib/gis/geoip/prototypes.py b/django/contrib/gis/geoip/prototypes.py index 22c17f006fd..6b47313cfee 100644 --- a/django/contrib/gis/geoip/prototypes.py +++ b/django/contrib/gis/geoip/prototypes.py @@ -1,5 +1,6 @@ -from ctypes import c_char_p, c_float, c_int, string_at, Structure, POINTER -from django.contrib.gis.geoip.libgeoip import lgeoip, free +from ctypes import POINTER, Structure, c_char_p, c_float, c_int, string_at + +from django.contrib.gis.geoip.libgeoip import free, lgeoip #### GeoIP C Structure definitions #### diff --git a/django/contrib/gis/geoip/tests.py b/django/contrib/gis/geoip/tests.py index 06558e00939..8d1309a671e 100644 --- a/django/contrib/gis/geoip/tests.py +++ b/django/contrib/gis/geoip/tests.py @@ -6,9 +6,8 @@ import unittest from unittest import skipUnless from django.conf import settings -from django.contrib.gis.geos import HAS_GEOS from django.contrib.gis.geoip import HAS_GEOIP - +from django.contrib.gis.geos import HAS_GEOS from django.utils import six if HAS_GEOIP: diff --git a/django/contrib/gis/geometry/backend/geos.py b/django/contrib/gis/geometry/backend/geos.py index b4d48dbc98e..02ca3dd29e9 100644 --- a/django/contrib/gis/geometry/backend/geos.py +++ b/django/contrib/gis/geometry/backend/geos.py @@ -1,4 +1,5 @@ from django.contrib.gis.geos import ( - GEOSGeometry as Geometry, GEOSException as GeometryException) + GEOSException as GeometryException, GEOSGeometry as Geometry, +) __all__ = ['Geometry', 'GeometryException'] diff --git a/django/contrib/gis/geometry/test_data.py b/django/contrib/gis/geometry/test_data.py index d6a8bf8263b..58d82dbdcc4 100644 --- a/django/contrib/gis/geometry/test_data.py +++ b/django/contrib/gis/geometry/test_data.py @@ -10,7 +10,6 @@ from django.utils import six from django.utils._os import upath from django.utils.functional import cached_property - # Path where reference test data is located. TEST_DATA = os.path.join(os.path.dirname(upath(gis.__file__)), 'tests', 'data') diff --git a/django/contrib/gis/geos/collections.py b/django/contrib/gis/geos/collections.py index 83f57cbd18f..84b872602d6 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 c238d4cda51..8185ab43cc4 100644 --- a/django/contrib/gis/geos/coordseq.py +++ b/django/contrib/gis/geos/coordseq.py @@ -3,11 +3,12 @@ by GEOSGeometry to house the actual coordinates of the Point, LineString, and LinearRing geometries. """ -from ctypes import c_double, c_uint, byref +from ctypes import byref, c_double, c_uint + +from django.contrib.gis.geos import prototypes as capi from django.contrib.gis.geos.base import GEOSBase, numpy from django.contrib.gis.geos.error import GEOSException, GEOSIndexError from django.contrib.gis.geos.libgeos import CS_PTR -from django.contrib.gis.geos import prototypes as capi from django.utils.six.moves import range diff --git a/django/contrib/gis/geos/factory.py b/django/contrib/gis/geos/factory.py index 87ee660020d..eb06da2c00d 100644 --- a/django/contrib/gis/geos/factory.py +++ b/django/contrib/gis/geos/factory.py @@ -1,5 +1,4 @@ -from django.contrib.gis.geos.geometry import GEOSGeometry, wkt_regex, hex_regex - +from django.contrib.gis.geos.geometry import GEOSGeometry, hex_regex, wkt_regex from django.utils import six diff --git a/django/contrib/gis/geos/geometry.py b/django/contrib/gis/geos/geometry.py index c3ba634df10..5b478857ec5 100644 --- a/django/contrib/gis/geos/geometry.py +++ b/django/contrib/gis/geos/geometry.py @@ -4,32 +4,19 @@ """ from __future__ import unicode_literals -# Python, ctypes and types dependencies. from ctypes import addressof, byref, c_double -# super-class for mutable list behavior -from django.contrib.gis.geos.mutable_list import ListMixin - from django.contrib.gis.gdal.error import SRSException - -# GEOS-related dependencies. +from django.contrib.gis.geometry.regex import hex_regex, json_regex, wkt_regex +from django.contrib.gis.geos import prototypes as capi from django.contrib.gis.geos.base import GEOSBase, gdal from django.contrib.gis.geos.coordseq import GEOSCoordSeq from django.contrib.gis.geos.error import GEOSException, GEOSIndexError from django.contrib.gis.geos.libgeos import GEOM_PTR - -# All other functions in this module come from the ctypes -# prototypes module -- which handles all interaction with -# the underlying GEOS library. -from django.contrib.gis.geos import prototypes as capi - -# These functions provide access to a thread-local instance -# of their corresponding GEOS I/O class. -from django.contrib.gis.geos.prototypes.io import wkt_r, wkt_w, wkb_r, wkb_w, ewkb_w - -# For recognizing geometry input. -from django.contrib.gis.geometry.regex import hex_regex, wkt_regex, json_regex - +from django.contrib.gis.geos.mutable_list import ListMixin +from django.contrib.gis.geos.prototypes.io import ( + ewkb_w, wkb_r, wkb_w, wkt_r, wkt_w, +) from django.utils import six from django.utils.encoding import force_bytes, force_text @@ -684,11 +671,12 @@ class GEOSGeometry(GEOSBase, ListMixin): # Class mapping dictionary. Has to be at the end to avoid import # conflicts with GEOSGeometry. -from django.contrib.gis.geos.linestring import LineString, LinearRing -from django.contrib.gis.geos.point import Point -from django.contrib.gis.geos.polygon import Polygon -from django.contrib.gis.geos.collections import GeometryCollection, MultiPoint, MultiLineString, MultiPolygon -from django.contrib.gis.geos.prepared import PreparedGeometry +from django.contrib.gis.geos.linestring import LineString, LinearRing # isort:skip +from django.contrib.gis.geos.point import Point # isort:skip +from django.contrib.gis.geos.polygon import Polygon # isort:skip +from django.contrib.gis.geos.collections import ( # isort:skip + GeometryCollection, MultiPoint, MultiLineString, MultiPolygon) +from django.contrib.gis.geos.prepared import PreparedGeometry # isort:skip GEOS_CLASSES = { 0: Point, 1: LineString, diff --git a/django/contrib/gis/geos/io.py b/django/contrib/gis/geos/io.py index f12be89830e..daf67dd28c2 100644 --- a/django/contrib/gis/geos/io.py +++ b/django/contrib/gis/geos/io.py @@ -4,7 +4,9 @@ objects. Specifically, this has Python implementations of WKB/WKT reader and writer classes. """ from django.contrib.gis.geos.geometry import GEOSGeometry -from django.contrib.gis.geos.prototypes.io import _WKTReader, _WKBReader, WKBWriter, WKTWriter +from django.contrib.gis.geos.prototypes.io import ( + WKBWriter, WKTWriter, _WKBReader, _WKTReader, +) __all__ = ['WKBWriter', 'WKTWriter', 'WKBReader', 'WKTReader'] diff --git a/django/contrib/gis/geos/libgeos.py b/django/contrib/gis/geos/libgeos.py index 207fa780a4d..fa5fa21a256 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 829ab48945e..62802c1efd9 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 f01bc4275f6..805351f252c 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 2cc5c13683b..0b58098fed7 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 38b533df8f4..c8059348cd6 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 b115fc34473..3e5204e5fe0 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 034cfe58992..dd037a56321 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 021fe6e469b..b8320471e92 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 34bd34886ac..55fd6d2f177 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 0e62e916b04..9dba880f187 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 f3c30a50623..0146784d034 100644 --- a/django/contrib/gis/geos/prototypes/predicates.py +++ b/django/contrib/gis/geos/prototypes/predicates.py @@ -3,6 +3,7 @@ unary and binary predicate operations on geometries. """ from ctypes import c_char, c_char_p, c_double + from django.contrib.gis.geos.libgeos import GEOM_PTR from django.contrib.gis.geos.prototypes.errcheck import check_predicate from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc diff --git a/django/contrib/gis/geos/prototypes/prepared.py b/django/contrib/gis/geos/prototypes/prepared.py index ced56395b0c..2c93e1eb2f9 100644 --- a/django/contrib/gis/geos/prototypes/prepared.py +++ b/django/contrib/gis/geos/prototypes/prepared.py @@ -1,5 +1,8 @@ from ctypes import c_char -from django.contrib.gis.geos.libgeos import GEOM_PTR, PREPGEOM_PTR, geos_version_info + +from django.contrib.gis.geos.libgeos import ( + GEOM_PTR, PREPGEOM_PTR, geos_version_info, +) from django.contrib.gis.geos.prototypes.errcheck import check_predicate from django.contrib.gis.geos.prototypes.threadsafe import GEOSFunc diff --git a/django/contrib/gis/geos/prototypes/threadsafe.py b/django/contrib/gis/geos/prototypes/threadsafe.py index 61b13792bc7..45c87d60045 100644 --- a/django/contrib/gis/geos/prototypes/threadsafe.py +++ b/django/contrib/gis/geos/prototypes/threadsafe.py @@ -1,5 +1,8 @@ import threading -from django.contrib.gis.geos.libgeos import lgeos, notice_h, error_h, CONTEXT_PTR + +from django.contrib.gis.geos.libgeos import ( + CONTEXT_PTR, error_h, lgeos, notice_h, +) class GEOSContextHandle(object): diff --git a/django/contrib/gis/geos/prototypes/topology.py b/django/contrib/gis/geos/prototypes/topology.py index 83d6706eaa5..0e318409ee5 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 48d4aabf136..4158faeaa78 100644 --- a/django/contrib/gis/geos/tests/test_geos.py +++ b/django/contrib/gis/geos/tests/test_geos.py @@ -4,16 +4,14 @@ import ctypes import json import random import unittest -from unittest import skipUnless from binascii import a2b_hex, b2a_hex from io import BytesIO +from unittest import skipUnless from django.contrib.gis.gdal import HAS_GDAL - from django.contrib.gis.geometry.test_data import TestDataMixin - -from django.utils.encoding import force_bytes from django.utils import six +from django.utils.encoding import force_bytes from django.utils.six.moves import range from .. import HAS_GEOS diff --git a/django/contrib/gis/geos/tests/test_io.py b/django/contrib/gis/geos/tests/test_io.py index 06ca76e33d6..08ff6c13e88 100644 --- a/django/contrib/gis/geos/tests/test_io.py +++ b/django/contrib/gis/geos/tests/test_io.py @@ -6,7 +6,7 @@ from unittest import skipUnless from django.utils.six import memoryview -from ..import HAS_GEOS +from ..import HAS_GEOS # isort:skip if HAS_GEOS: from .. import GEOSGeometry, WKTReader, WKTWriter, WKBReader, WKBWriter diff --git a/django/contrib/gis/management/commands/inspectdb.py b/django/contrib/gis/management/commands/inspectdb.py index 502f816ea40..229be74276a 100644 --- a/django/contrib/gis/management/commands/inspectdb.py +++ b/django/contrib/gis/management/commands/inspectdb.py @@ -1,4 +1,5 @@ -from django.core.management.commands.inspectdb import Command as InspectDBCommand +from django.core.management.commands.inspectdb import \ + Command as InspectDBCommand class Command(InspectDBCommand): diff --git a/django/contrib/gis/maps/google/gmap.py b/django/contrib/gis/maps/google/gmap.py index 845b39a806e..d40c3b8218e 100644 --- a/django/contrib/gis/maps/google/gmap.py +++ b/django/contrib/gis/maps/google/gmap.py @@ -1,13 +1,14 @@ from __future__ import unicode_literals from django.conf import settings +from django.contrib.gis.maps.google.overlays import ( + GMarker, GPolygon, GPolyline, +) from django.template.loader import render_to_string from django.utils.html import format_html from django.utils.safestring import mark_safe from django.utils.six.moves import range -from django.contrib.gis.maps.google.overlays import GPolygon, GPolyline, GMarker - class GoogleMapException(Exception): pass diff --git a/django/contrib/gis/maps/google/overlays.py b/django/contrib/gis/maps/google/overlays.py index d9ba31380a2..f249e5d809f 100644 --- a/django/contrib/gis/maps/google/overlays.py +++ b/django/contrib/gis/maps/google/overlays.py @@ -1,10 +1,12 @@ from __future__ import unicode_literals -from django.contrib.gis.geos import fromstr, Point, LineString, LinearRing, Polygon -from django.utils.functional import total_ordering -from django.utils.safestring import mark_safe +from django.contrib.gis.geos import ( + LinearRing, LineString, Point, Polygon, fromstr, +) from django.utils import six from django.utils.encoding import python_2_unicode_compatible +from django.utils.functional import total_ordering +from django.utils.safestring import mark_safe @python_2_unicode_compatible diff --git a/django/contrib/gis/maps/google/zoom.py b/django/contrib/gis/maps/google/zoom.py index a34748bb8e3..d169fbd59b5 100644 --- a/django/contrib/gis/maps/google/zoom.py +++ b/django/contrib/gis/maps/google/zoom.py @@ -1,9 +1,10 @@ from __future__ import unicode_literals -from django.contrib.gis.geos import GEOSGeometry, LinearRing, Polygon, Point +from math import atan, exp, log, pi, sin + +from django.contrib.gis.geos import GEOSGeometry, LinearRing, Point, Polygon from django.contrib.gis.maps.google.gmap import GoogleMapException from django.utils.six.moves import range -from math import pi, sin, log, exp, atan # Constants used for degree to radian conversion, and vice-versa. DTOR = pi / 180. diff --git a/django/contrib/gis/measure.py b/django/contrib/gis/measure.py index 90b316bb603..527512f71bf 100644 --- a/django/contrib/gis/measure.py +++ b/django/contrib/gis/measure.py @@ -38,8 +38,8 @@ and Geoff Biggs' PhD work on dimensioned units for robotics. __all__ = ['A', 'Area', 'D', 'Distance'] from decimal import Decimal -from django.utils.functional import total_ordering from django.utils import six +from django.utils.functional import total_ordering NUMERIC_TYPES = six.integer_types + (float, Decimal) AREA_PREFIX = "sq_" diff --git a/django/contrib/gis/serializers/geojson.py b/django/contrib/gis/serializers/geojson.py index 573f85c045e..eb0533bdeda 100644 --- a/django/contrib/gis/serializers/geojson.py +++ b/django/contrib/gis/serializers/geojson.py @@ -1,7 +1,9 @@ from __future__ import unicode_literals from django.contrib.gis.gdal import HAS_GDAL -from django.core.serializers.base import SerializerDoesNotExist, SerializationError +from django.core.serializers.base import ( + SerializationError, SerializerDoesNotExist, +) from django.core.serializers.json import Serializer as JSONSerializer if HAS_GDAL: diff --git a/django/contrib/gis/sitemaps/kml.py b/django/contrib/gis/sitemaps/kml.py index d052cf63506..4dcaa8f5950 100644 --- a/django/contrib/gis/sitemaps/kml.py +++ b/django/contrib/gis/sitemaps/kml.py @@ -1,7 +1,7 @@ from django.apps import apps -from django.core import urlresolvers -from django.contrib.sitemaps import Sitemap from django.contrib.gis.db.models.fields import GeometryField +from django.contrib.sitemaps import Sitemap +from django.core import urlresolvers from django.db import models diff --git a/django/contrib/gis/sitemaps/views.py b/django/contrib/gis/sitemaps/views.py index a84621374be..dc5eb40441d 100644 --- a/django/contrib/gis/sitemaps/views.py +++ b/django/contrib/gis/sitemaps/views.py @@ -1,11 +1,11 @@ from __future__ import unicode_literals from django.apps import apps -from django.http import Http404 from django.contrib.gis.db.models.fields import GeometryField from django.contrib.gis.shortcuts import render_to_kml, render_to_kmz from django.core.exceptions import FieldDoesNotExist -from django.db import connections, DEFAULT_DB_ALIAS +from django.db import DEFAULT_DB_ALIAS, connections +from django.http import Http404 def kml(request, label, model, field_name=None, compress=False, using=DEFAULT_DB_ALIAS): diff --git a/django/contrib/gis/tests/distapp/tests.py b/django/contrib/gis/tests/distapp/tests.py index 5f898e3ddab..4c2ea609503 100644 --- a/django/contrib/gis/tests/distapp/tests.py +++ b/django/contrib/gis/tests/distapp/tests.py @@ -1,10 +1,12 @@ from __future__ import unicode_literals -from django.db import connection -from django.db.models import Q from django.contrib.gis.geos import HAS_GEOS from django.contrib.gis.measure import D # alias for Distance -from django.contrib.gis.tests.utils import oracle, postgis, spatialite, no_oracle +from django.contrib.gis.tests.utils import ( + no_oracle, oracle, postgis, spatialite, +) +from django.db import connection +from django.db.models import Q from django.test import TestCase, skipUnlessDBFeature if HAS_GEOS: diff --git a/django/contrib/gis/tests/geo3d/tests.py b/django/contrib/gis/tests/geo3d/tests.py index 9530cd9b550..022a8063ab5 100644 --- a/django/contrib/gis/tests/geo3d/tests.py +++ b/django/contrib/gis/tests/geo3d/tests.py @@ -7,8 +7,8 @@ from unittest import skipUnless from django.contrib.gis.gdal import HAS_GDAL from django.contrib.gis.geos import HAS_GEOS from django.test import TestCase, ignore_warnings, skipUnlessDBFeature -from django.utils.deprecation import RemovedInDjango20Warning from django.utils._os import upath +from django.utils.deprecation import RemovedInDjango20Warning if HAS_GEOS: from django.contrib.gis.db.models import Union, Extent3D diff --git a/django/contrib/gis/tests/geoadmin/models.py b/django/contrib/gis/tests/geoadmin/models.py index 381a752570c..cf8470e792c 100644 --- a/django/contrib/gis/tests/geoadmin/models.py +++ b/django/contrib/gis/tests/geoadmin/models.py @@ -1,5 +1,5 @@ -from django.contrib.gis.db import models from django.contrib.gis import admin +from django.contrib.gis.db import models from django.utils.encoding import python_2_unicode_compatible diff --git a/django/contrib/gis/tests/geoapp/sitemaps.py b/django/contrib/gis/tests/geoapp/sitemaps.py index 16f1f0146e8..1a3101290ae 100644 --- a/django/contrib/gis/tests/geoapp/sitemaps.py +++ b/django/contrib/gis/tests/geoapp/sitemaps.py @@ -2,7 +2,6 @@ from django.contrib.gis.sitemaps import KMLSitemap, KMZSitemap from .models import City, Country - sitemaps = {'kml': KMLSitemap([City, Country]), 'kmz': KMZSitemap([City, Country]), } diff --git a/django/contrib/gis/tests/geoapp/test_feeds.py b/django/contrib/gis/tests/geoapp/test_feeds.py index 1b89823ecba..19a6f69b008 100644 --- a/django/contrib/gis/tests/geoapp/test_feeds.py +++ b/django/contrib/gis/tests/geoapp/test_feeds.py @@ -3,10 +3,10 @@ from __future__ import unicode_literals from xml.dom import minidom from django.conf import settings -from django.contrib.sites.models import Site from django.contrib.gis.geos import HAS_GEOS +from django.contrib.sites.models import Site from django.test import ( - TestCase, modify_settings, override_settings, skipUnlessDBFeature + TestCase, modify_settings, override_settings, skipUnlessDBFeature, ) if HAS_GEOS: diff --git a/django/contrib/gis/tests/geoapp/test_sitemaps.py b/django/contrib/gis/tests/geoapp/test_sitemaps.py index 4ef2bb97023..6a2d1f40b83 100644 --- a/django/contrib/gis/tests/geoapp/test_sitemaps.py +++ b/django/contrib/gis/tests/geoapp/test_sitemaps.py @@ -1,14 +1,15 @@ from __future__ import unicode_literals +import zipfile from io import BytesIO from xml.dom import minidom -import zipfile from django.conf import settings from django.contrib.gis.geos import HAS_GEOS from django.contrib.sites.models import Site from django.test import ( - TestCase, ignore_warnings, modify_settings, override_settings, skipUnlessDBFeature + TestCase, ignore_warnings, modify_settings, override_settings, + skipUnlessDBFeature, ) from django.utils.deprecation import RemovedInDjango20Warning diff --git a/django/contrib/gis/tests/geoapp/tests.py b/django/contrib/gis/tests/geoapp/tests.py index 7c999a20d0a..9b454927153 100644 --- a/django/contrib/gis/tests/geoapp/tests.py +++ b/django/contrib/gis/tests/geoapp/tests.py @@ -3,11 +3,13 @@ from __future__ import unicode_literals import re from tempfile import NamedTemporaryFile -from django.db import connection from django.contrib.gis import gdal from django.contrib.gis.geos import HAS_GEOS -from django.contrib.gis.tests.utils import no_oracle, oracle, postgis, spatialite +from django.contrib.gis.tests.utils import ( + no_oracle, oracle, postgis, spatialite, +) from django.core.management import call_command +from django.db import connection from django.test import TestCase, ignore_warnings, skipUnlessDBFeature from django.utils import six from django.utils.deprecation import RemovedInDjango20Warning diff --git a/django/contrib/gis/tests/geoapp/urls.py b/django/contrib/gis/tests/geoapp/urls.py index 238c64ad51c..40a48053c72 100644 --- a/django/contrib/gis/tests/geoapp/urls.py +++ b/django/contrib/gis/tests/geoapp/urls.py @@ -2,13 +2,12 @@ from __future__ import unicode_literals from django.conf.urls import url from django.contrib.gis import views as gis_views -from django.contrib.sitemaps import views as sitemap_views from django.contrib.gis.sitemaps import views as gis_sitemap_views +from django.contrib.sitemaps import views as sitemap_views from .feeds import feed_dict from .sitemaps import sitemaps - urlpatterns = [ url(r'^feeds/(?P.*)/$', gis_views.feed, {'feed_dict': feed_dict}), ] diff --git a/django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py b/django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py index 212f7023209..aceaaa301e0 100644 --- a/django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py +++ b/django/contrib/gis/tests/gis_migrations/migrations/0001_initial.py @@ -1,5 +1,5 @@ -from django.db import models, migrations import django.contrib.gis.db.models.fields +from django.db import migrations, models class Migration(migrations.Migration): diff --git a/django/contrib/gis/tests/gis_migrations/test_commands.py b/django/contrib/gis/tests/gis_migrations/test_commands.py index bb0186fad53..076215465dd 100644 --- a/django/contrib/gis/tests/gis_migrations/test_commands.py +++ b/django/contrib/gis/tests/gis_migrations/test_commands.py @@ -2,7 +2,7 @@ from __future__ import unicode_literals from django.core.management import call_command from django.db import connection -from django.test import skipUnlessDBFeature, TransactionTestCase +from django.test import TransactionTestCase, skipUnlessDBFeature @skipUnlessDBFeature("gis_enabled") diff --git a/django/contrib/gis/tests/gis_migrations/test_operations.py b/django/contrib/gis/tests/gis_migrations/test_operations.py index 8052e7ab1df..9bfe55b0bf3 100644 --- a/django/contrib/gis/tests/gis_migrations/test_operations.py +++ b/django/contrib/gis/tests/gis_migrations/test_operations.py @@ -4,7 +4,7 @@ from django.contrib.gis.tests.utils import mysql from django.db import connection, migrations, models from django.db.migrations.migration import Migration from django.db.migrations.state import ProjectState -from django.test import skipUnlessDBFeature, TransactionTestCase +from django.test import TransactionTestCase, skipUnlessDBFeature if connection.features.gis_enabled: from django.contrib.gis.db.models import fields diff --git a/django/contrib/gis/tests/inspectapp/tests.py b/django/contrib/gis/tests/inspectapp/tests.py index 82b2cfefd6a..8e2f54c5178 100644 --- a/django/contrib/gis/tests/inspectapp/tests.py +++ b/django/contrib/gis/tests/inspectapp/tests.py @@ -4,11 +4,11 @@ import os import re from unittest import skipUnless +from django.contrib.gis.gdal import HAS_GDAL +from django.contrib.gis.geometry.test_data import TEST_DATA from django.core.management import call_command from django.db import connection, connections from django.test import TestCase, skipUnlessDBFeature -from django.contrib.gis.gdal import HAS_GDAL -from django.contrib.gis.geometry.test_data import TEST_DATA from django.utils.six import StringIO if HAS_GDAL: diff --git a/django/contrib/gis/tests/layermap/tests.py b/django/contrib/gis/tests/layermap/tests.py index 45709e30ce1..85f105f4a0b 100644 --- a/django/contrib/gis/tests/layermap/tests.py +++ b/django/contrib/gis/tests/layermap/tests.py @@ -1,15 +1,15 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -from copy import copy -from decimal import Decimal import os import unittest +from copy import copy +from decimal import Decimal from unittest import skipUnless +from django.conf import settings from django.contrib.gis.gdal import HAS_GDAL from django.db import connection -from django.conf import settings from django.test import TestCase, override_settings, skipUnlessDBFeature from django.utils._os import upath diff --git a/django/contrib/gis/tests/test_geoforms.py b/django/contrib/gis/tests/test_geoforms.py index fa72cd1facc..bcbb5f08045 100644 --- a/django/contrib/gis/tests/test_geoforms.py +++ b/django/contrib/gis/tests/test_geoforms.py @@ -1,7 +1,7 @@ from unittest import skipUnless -from django.forms import ValidationError from django.contrib.gis.gdal import HAS_GDAL +from django.forms import ValidationError from django.test import SimpleTestCase, skipUnlessDBFeature from django.utils import six from django.utils.html import escape diff --git a/django/contrib/gis/tests/test_measure.py b/django/contrib/gis/tests/test_measure.py index f6b89ce1ca7..771c10fe9df 100644 --- a/django/contrib/gis/tests/test_measure.py +++ b/django/contrib/gis/tests/test_measure.py @@ -5,7 +5,7 @@ and conversions. Here are some tests. import unittest -from django.contrib.gis.measure import Distance, Area, D, A +from django.contrib.gis.measure import A, D, Area, Distance class DistanceTest(unittest.TestCase): diff --git a/django/contrib/gis/tests/test_spatialrefsys.py b/django/contrib/gis/tests/test_spatialrefsys.py index 7f43124e5d0..1a4b151f2b4 100644 --- a/django/contrib/gis/tests/test_spatialrefsys.py +++ b/django/contrib/gis/tests/test_spatialrefsys.py @@ -1,13 +1,13 @@ import unittest from django.contrib.gis.gdal import HAS_GDAL -from django.contrib.gis.tests.utils import (oracle, postgis, spatialite, - SpatialRefSys) +from django.contrib.gis.tests.utils import ( + SpatialRefSys, oracle, postgis, spatialite, +) from django.db import connection from django.test import skipUnlessDBFeature from django.utils import six - test_srs = ({ 'srid': 4326, 'auth_name': ('EPSG', True), diff --git a/django/contrib/gis/utils/layermapping.py b/django/contrib/gis/utils/layermapping.py index 2ff23fc38be..30e773d69df 100644 --- a/django/contrib/gis/utils/layermapping.py +++ b/django/contrib/gis/utils/layermapping.py @@ -8,14 +8,17 @@ """ import sys from decimal import Decimal, InvalidOperation as DecimalInvalidOperation -from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist -from django.db import connections, router + from django.contrib.gis.db.models import GeometryField -from django.contrib.gis.gdal import (CoordTransform, DataSource, - GDALException, OGRGeometry, OGRGeomType, SpatialReference) +from django.contrib.gis.gdal import ( + CoordTransform, DataSource, GDALException, OGRGeometry, OGRGeomType, + SpatialReference, +) from django.contrib.gis.gdal.field import ( - OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime) -from django.db import models, transaction + OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime, +) +from django.core.exceptions import FieldDoesNotExist, ObjectDoesNotExist +from django.db import connections, models, router, transaction from django.utils import six from django.utils.encoding import force_text diff --git a/django/contrib/gis/utils/ogrinspect.py b/django/contrib/gis/utils/ogrinspect.py index 16732556d41..9c9a4c7f8cc 100644 --- a/django/contrib/gis/utils/ogrinspect.py +++ b/django/contrib/gis/utils/ogrinspect.py @@ -3,11 +3,12 @@ This module is for inspecting OGR data sources and generating either models for GeoDjango and/or mapping dictionaries for use with the `LayerMapping` utility. """ -from django.utils.six.moves import zip -# Requires GDAL to use. from django.contrib.gis.gdal import DataSource -from django.contrib.gis.gdal.field import OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime +from django.contrib.gis.gdal.field import ( + OFTDate, OFTDateTime, OFTInteger, OFTReal, OFTString, OFTTime, +) from django.utils import six +from django.utils.six.moves import zip def mapping(data_source, geom_name='geom', layer_key=0, multi_geom=False): diff --git a/django/contrib/gis/utils/srs.py b/django/contrib/gis/utils/srs.py index 1460be2de90..59ba77c6dda 100644 --- a/django/contrib/gis/utils/srs.py +++ b/django/contrib/gis/utils/srs.py @@ -1,5 +1,5 @@ from django.contrib.gis.gdal import SpatialReference -from django.db import connections, DEFAULT_DB_ALIAS +from django.db import DEFAULT_DB_ALIAS, connections def add_srs_entry(srs, auth_name='EPSG', auth_srid=None, ref_sys_name=None, diff --git a/django/contrib/humanize/apps.py b/django/contrib/humanize/apps.py index 67b3012175e..c518ee12df8 100644 --- a/django/contrib/humanize/apps.py +++ b/django/contrib/humanize/apps.py @@ -1,5 +1,4 @@ from django.apps import AppConfig - from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/humanize/templatetags/humanize.py b/django/contrib/humanize/templatetags/humanize.py index 81c6d2a04c2..bb9bc7b1cac 100644 --- a/django/contrib/humanize/templatetags/humanize.py +++ b/django/contrib/humanize/templatetags/humanize.py @@ -11,8 +11,8 @@ from django.template import defaultfilters from django.utils.encoding import force_text from django.utils.formats import number_format from django.utils.safestring import mark_safe -from django.utils.translation import pgettext, ungettext, ugettext as _ from django.utils.timezone import is_aware, utc +from django.utils.translation import pgettext, ugettext as _, ungettext register = template.Library() diff --git a/django/contrib/humanize/tests.py b/django/contrib/humanize/tests.py index a9882e479fd..84528fd29db 100644 --- a/django/contrib/humanize/tests.py +++ b/django/contrib/humanize/tests.py @@ -1,21 +1,22 @@ from __future__ import unicode_literals + import datetime from decimal import Decimal from unittest import skipIf +from django.contrib.humanize.templatetags import humanize +from django.template import Context, Template, defaultfilters +from django.test import TestCase, override_settings +from django.utils import translation +from django.utils.html import escape +from django.utils.timezone import get_fixed_timezone, utc +from django.utils.translation import ugettext as _ + try: import pytz except ImportError: pytz = None -from django.contrib.humanize.templatetags import humanize -from django.template import Template, Context, defaultfilters -from django.test import TestCase, override_settings -from django.utils.html import escape -from django.utils.timezone import utc, get_fixed_timezone -from django.utils import translation -from django.utils.translation import ugettext as _ - # Mock out datetime in some tests so they don't fail occasionally when they # run too slow. Use a fixed datetime for datetime.now(). DST change in diff --git a/django/contrib/messages/apps.py b/django/contrib/messages/apps.py index 1a9189383ef..de48c8aa4d6 100644 --- a/django/contrib/messages/apps.py +++ b/django/contrib/messages/apps.py @@ -1,5 +1,4 @@ from django.apps import AppConfig - from django.utils.translation import ugettext_lazy as _ diff --git a/django/contrib/messages/storage/base.py b/django/contrib/messages/storage/base.py index 43dd3dbdd2c..74f1ce7d9c5 100644 --- a/django/contrib/messages/storage/base.py +++ b/django/contrib/messages/storage/base.py @@ -1,9 +1,8 @@ from __future__ import unicode_literals from django.conf import settings -from django.utils.encoding import force_text, python_2_unicode_compatible from django.contrib.messages import constants, utils - +from django.utils.encoding import force_text, python_2_unicode_compatible LEVEL_TAGS = utils.get_level_tags() diff --git a/django/contrib/messages/storage/cookie.py b/django/contrib/messages/storage/cookie.py index 71eee0cdfa8..eb927411a73 100644 --- a/django/contrib/messages/storage/cookie.py +++ b/django/contrib/messages/storage/cookie.py @@ -3,9 +3,9 @@ import json from django.conf import settings from django.contrib.messages.storage.base import BaseStorage, Message from django.http import SimpleCookie -from django.utils.crypto import salted_hmac, constant_time_compare -from django.utils.safestring import SafeData, mark_safe from django.utils import six +from django.utils.crypto import constant_time_compare, salted_hmac +from django.utils.safestring import SafeData, mark_safe class MessageEncoder(json.JSONEncoder): diff --git a/django/contrib/messages/storage/session.py b/django/contrib/messages/storage/session.py index c3e293c22e9..7903fb03c19 100644 --- a/django/contrib/messages/storage/session.py +++ b/django/contrib/messages/storage/session.py @@ -1,7 +1,9 @@ import json from django.contrib.messages.storage.base import BaseStorage -from django.contrib.messages.storage.cookie import MessageEncoder, MessageDecoder +from django.contrib.messages.storage.cookie import ( + MessageDecoder, MessageEncoder, +) from django.utils import six diff --git a/django/contrib/messages/tests/base.py b/django/contrib/messages/tests/base.py index 139d32c0677..d1f951789f5 100644 --- a/django/contrib/messages/tests/base.py +++ b/django/contrib/messages/tests/base.py @@ -2,10 +2,10 @@ from unittest import skipUnless from django import http from django.apps import apps -from django.contrib.messages import constants, utils, get_level, set_level +from django.contrib.messages import constants, get_level, set_level, utils from django.contrib.messages.api import MessageFailure from django.contrib.messages.constants import DEFAULT_LEVELS -from django.contrib.messages.storage import default_storage, base +from django.contrib.messages.storage import base, default_storage from django.contrib.messages.storage.base import Message from django.core.urlresolvers import reverse from django.test import modify_settings, override_settings diff --git a/django/contrib/messages/tests/test_api.py b/django/contrib/messages/tests/test_api.py index 335a2004504..f79db958660 100644 --- a/django/contrib/messages/tests/test_api.py +++ b/django/contrib/messages/tests/test_api.py @@ -1,6 +1,5 @@ -from django.test import TestCase, RequestFactory - from django.contrib import messages +from django.test import RequestFactory, TestCase class DummyStorage(object): diff --git a/django/contrib/messages/tests/test_cookie.py b/django/contrib/messages/tests/test_cookie.py index ba7b4dc08b0..c986a174cae 100644 --- a/django/contrib/messages/tests/test_cookie.py +++ b/django/contrib/messages/tests/test_cookie.py @@ -1,10 +1,11 @@ import json from django.contrib.messages import constants -from django.contrib.messages.tests.base import BaseTests -from django.contrib.messages.storage.cookie import (CookieStorage, - MessageEncoder, MessageDecoder) from django.contrib.messages.storage.base import Message +from django.contrib.messages.storage.cookie import ( + CookieStorage, MessageDecoder, MessageEncoder, +) +from django.contrib.messages.tests.base import BaseTests from django.test import TestCase, override_settings from django.utils.safestring import SafeData, mark_safe diff --git a/django/contrib/messages/tests/test_fallback.py b/django/contrib/messages/tests/test_fallback.py index cd0b1888f38..0afbe75ae66 100644 --- a/django/contrib/messages/tests/test_fallback.py +++ b/django/contrib/messages/tests/test_fallback.py @@ -1,11 +1,14 @@ from django.contrib.messages import constants -from django.contrib.messages.storage.fallback import (FallbackStorage, - CookieStorage) +from django.contrib.messages.storage.fallback import ( + CookieStorage, FallbackStorage, +) from django.contrib.messages.tests.base import BaseTests -from django.contrib.messages.tests.test_cookie import (set_cookie_data, - stored_cookie_messages_count) -from django.contrib.messages.tests.test_session import (set_session_data, - stored_session_messages_count) +from django.contrib.messages.tests.test_cookie import ( + set_cookie_data, stored_cookie_messages_count, +) +from django.contrib.messages.tests.test_session import ( + set_session_data, stored_session_messages_count, +) from django.test import TestCase diff --git a/django/contrib/messages/tests/test_mixins.py b/django/contrib/messages/tests/test_mixins.py index 35bb86d057d..bb0bb797d48 100644 --- a/django/contrib/messages/tests/test_mixins.py +++ b/django/contrib/messages/tests/test_mixins.py @@ -1,6 +1,6 @@ -from django.test import TestCase, override_settings from django.contrib.messages.tests.urls import ContactFormViewWithMsg from django.core.urlresolvers import reverse +from django.test import TestCase, override_settings @override_settings(ROOT_URLCONF='django.contrib.messages.tests.urls') diff --git a/django/contrib/messages/tests/test_session.py b/django/contrib/messages/tests/test_session.py index 940e1c02d03..cca659d3d8d 100644 --- a/django/contrib/messages/tests/test_session.py +++ b/django/contrib/messages/tests/test_session.py @@ -1,9 +1,9 @@ from django.contrib.messages import constants -from django.contrib.messages.tests.base import BaseTests from django.contrib.messages.storage.base import Message from django.contrib.messages.storage.session import SessionStorage -from django.utils.safestring import SafeData, mark_safe +from django.contrib.messages.tests.base import BaseTests from django.test import TestCase +from django.utils.safestring import SafeData, mark_safe def set_session_data(storage, messages): diff --git a/django/contrib/messages/tests/urls.py b/django/contrib/messages/tests/urls.py index 43cc6063cb4..d7486900447 100644 --- a/django/contrib/messages/tests/urls.py +++ b/django/contrib/messages/tests/urls.py @@ -1,14 +1,15 @@ +from django import forms from django.conf.urls import url from django.contrib import messages +from django.contrib.messages.views import SuccessMessageMixin from django.core.urlresolvers import reverse -from django import forms -from django.http import HttpResponseRedirect, HttpResponse +from django.http import HttpResponse, HttpResponseRedirect from django.template import engines from django.template.response import TemplateResponse from django.views.decorators.cache import never_cache -from django.contrib.messages.views import SuccessMessageMixin from django.views.generic.edit import FormView + TEMPLATE = """{% if messages %}