diff --git a/django/contrib/admin/__init__.py b/django/contrib/admin/__init__.py index cba84cf807..d8fc12e0a5 100644 --- a/django/contrib/admin/__init__.py +++ b/django/contrib/admin/__init__.py @@ -10,6 +10,14 @@ from django.contrib.admin.filters import (ListFilter, SimpleListFilter, ChoicesFieldListFilter, DateFieldListFilter, AllValuesFieldListFilter) from django.utils.module_loading import autodiscover_modules +__all__ = [ + "register", "ACTION_CHECKBOX_NAME", "ModelAdmin", "HORIZONTAL", "VERTICAL", + "StackedInline", "TabularInline", "AdminSite", "site", "ListFilter", + "SimpleListFilter", "FieldListFilter", "BooleanFieldListFilter", + "RelatedFieldListFilter", "ChoicesFieldListFilter", "DateFieldListFilter", + "AllValuesFieldListFilter", "autodiscover", +] + def autodiscover(): autodiscover_modules('admin', register_to=site) diff --git a/django/contrib/auth/models.py b/django/contrib/auth/models.py index 75107688d7..18757f9e62 100644 --- a/django/contrib/auth/models.py +++ b/django/contrib/auth/models.py @@ -1,5 +1,4 @@ from __future__ import unicode_literals -import re from django.core.mail import send_mail from django.core import validators diff --git a/django/contrib/auth/tests/test_decorators.py b/django/contrib/auth/tests/test_decorators.py index 35a2203ba9..22ad933644 100644 --- a/django/contrib/auth/tests/test_decorators.py +++ b/django/contrib/auth/tests/test_decorators.py @@ -1,8 +1,6 @@ from django.conf import settings from django.contrib.auth import models from django.contrib.auth.decorators import login_required, permission_required -# Trigger CustomUser perm creation: -from django.contrib.auth.tests.custom_user import CustomUser from django.contrib.auth.tests.test_views import AuthViewsTestCase from django.contrib.auth.tests.utils import skipIfCustomUser from django.core.exceptions import PermissionDenied diff --git a/django/contrib/auth/tests/test_models.py b/django/contrib/auth/tests/test_models.py index 8e2deb9562..1373a3c1c1 100644 --- a/django/contrib/auth/tests/test_models.py +++ b/django/contrib/auth/tests/test_models.py @@ -1,6 +1,5 @@ from django.contrib.auth import get_user_model from django.contrib.auth.models import AbstractUser, Group, User, UserManager -from django.contrib.auth.tests.custom_user import IsActiveTestUser1 from django.contrib.auth.tests.utils import skipIfCustomUser from django.core import mail from django.db.models.signals import post_save diff --git a/django/contrib/auth/tests/test_views.py b/django/contrib/auth/tests/test_views.py index e2c0d38152..060f0086ad 100644 --- a/django/contrib/auth/tests/test_views.py +++ b/django/contrib/auth/tests/test_views.py @@ -21,7 +21,6 @@ from django.contrib.sessions.middleware import SessionMiddleware from django.contrib.auth import SESSION_KEY, REDIRECT_FIELD_NAME from django.contrib.auth.forms import (AuthenticationForm, PasswordChangeForm, SetPasswordForm) -from django.contrib.auth.tests.custom_user import CustomUser from django.contrib.auth.tests.utils import skipIfCustomUser from django.contrib.auth.views import login as login_view diff --git a/django/contrib/formtools/wizard/storage/__init__.py b/django/contrib/formtools/wizard/storage/__init__.py index 8f57605ec5..4dbc15a298 100644 --- a/django/contrib/formtools/wizard/storage/__init__.py +++ b/django/contrib/formtools/wizard/storage/__init__.py @@ -5,6 +5,10 @@ from django.contrib.formtools.wizard.storage.base import BaseStorage from django.contrib.formtools.wizard.storage.exceptions import ( MissingStorage, NoFileStorageConfigured) +__all__ = [ + "BaseStorage", "MissingStorage", "NoFileStorageConfigured", "get_storage", +] + def get_storage(path, *args, **kwargs): try: diff --git a/django/contrib/gis/admin/__init__.py b/django/contrib/gis/admin/__init__.py index 2b56276ee7..fdf7166306 100644 --- a/django/contrib/gis/admin/__init__.py +++ b/django/contrib/gis/admin/__init__.py @@ -1,12 +1,21 @@ # Getting the normal admin routines, classes, and `site` instance. -from django.contrib.admin import autodiscover, site, AdminSite, ModelAdmin, StackedInline, TabularInline, HORIZONTAL, VERTICAL - +from django.contrib.admin import ( # NOQA: flake8 detects only the last __all__ + autodiscover, site, AdminSite, ModelAdmin, StackedInline, TabularInline, + HORIZONTAL, VERTICAL, +) # Geographic admin options classes and widgets. -from django.contrib.gis.admin.options import GeoModelAdmin -from django.contrib.gis.admin.widgets import OpenLayersWidget +from django.contrib.gis.admin.options import GeoModelAdmin # NOQA +from django.contrib.gis.admin.widgets import OpenLayersWidget # NOQA + +__all__ = [ + "autodiscover", "site", "AdminSite", "ModelAdmin", "StackedInline", + "TabularInline", "HORIZONTAL", "VERTICAL", + "GeoModelAdmin", "OpenLayersWidget", "HAS_OSM", +] try: from django.contrib.gis.admin.options import OSMGeoAdmin HAS_OSM = True + __all__ += ['OSMGeoAdmin'] except ImportError: HAS_OSM = False diff --git a/django/contrib/gis/db/models/__init__.py b/django/contrib/gis/db/models/__init__.py index 19e85b1364..835e907526 100644 --- a/django/contrib/gis/db/models/__init__.py +++ b/django/contrib/gis/db/models/__init__.py @@ -1,14 +1,14 @@ # Want to get everything from the 'normal' models package. -from django.db.models import * +from django.db.models import * # NOQA # Geographic aggregate functions -from django.contrib.gis.db.models.aggregates import * +from django.contrib.gis.db.models.aggregates import * # NOQA # The GeoManager -from django.contrib.gis.db.models.manager import GeoManager +from django.contrib.gis.db.models.manager import GeoManager # NOQA # The geographic-enabled fields. -from django.contrib.gis.db.models.fields import ( +from django.contrib.gis.db.models.fields import ( # NOQA GeometryField, PointField, LineStringField, PolygonField, MultiPointField, MultiLineStringField, MultiPolygonField, GeometryCollectionField) diff --git a/django/contrib/gis/db/models/aggregates.py b/django/contrib/gis/db/models/aggregates.py index fbfabe0a1d..43e9d1a0ae 100644 --- a/django/contrib/gis/db/models/aggregates.py +++ b/django/contrib/gis/db/models/aggregates.py @@ -1,5 +1,7 @@ from django.db.models import Aggregate +__all__ = ['Collect', 'Extent', 'Extent3D', 'MakeLine', 'Union'] + class Collect(Aggregate): name = 'Collect' diff --git a/django/contrib/gis/db/models/sql/__init__.py b/django/contrib/gis/db/models/sql/__init__.py index 38d950706e..a7d15dab63 100644 --- a/django/contrib/gis/db/models/sql/__init__.py +++ b/django/contrib/gis/db/models/sql/__init__.py @@ -1,3 +1,7 @@ from django.contrib.gis.db.models.sql.conversion import AreaField, DistanceField, GeomField from django.contrib.gis.db.models.sql.query import GeoQuery from django.contrib.gis.db.models.sql.where import GeoWhereNode + +__all__ = [ + 'AreaField', 'DistanceField', 'GeomField', 'GeoQuery', 'GeoWhereNode', +] diff --git a/django/contrib/gis/db/models/sql/aggregates.py b/django/contrib/gis/db/models/sql/aggregates.py index 07c3ddd2e5..f8f3ed1eb4 100644 --- a/django/contrib/gis/db/models/sql/aggregates.py +++ b/django/contrib/gis/db/models/sql/aggregates.py @@ -1,4 +1,4 @@ -from django.db.models.sql.aggregates import * +from django.db.models.sql.aggregates import Aggregate from django.contrib.gis.db.models.fields import GeometryField diff --git a/django/contrib/gis/forms/__init__.py b/django/contrib/gis/forms/__init__.py index 93a2d3847b..b689d6076c 100644 --- a/django/contrib/gis/forms/__init__.py +++ b/django/contrib/gis/forms/__init__.py @@ -1,5 +1,5 @@ -from django.forms import * -from .fields import (GeometryField, GeometryCollectionField, PointField, +from django.forms import * # NOQA +from .fields import (GeometryField, GeometryCollectionField, PointField, # NOQA MultiPointField, LineStringField, MultiLineStringField, PolygonField, MultiPolygonField) -from .widgets import BaseGeometryWidget, OpenLayersWidget, OSMWidget +from .widgets import BaseGeometryWidget, OpenLayersWidget, OSMWidget # NOQA diff --git a/django/contrib/gis/forms/fields.py b/django/contrib/gis/forms/fields.py index 2445e54715..151f66c39c 100644 --- a/django/contrib/gis/forms/fields.py +++ b/django/contrib/gis/forms/fields.py @@ -5,7 +5,7 @@ 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, fromstr +from django.contrib.gis.geos import GEOSException, GEOSGeometry from .widgets import OpenLayersWidget diff --git a/django/contrib/gis/gdal/__init__.py b/django/contrib/gis/gdal/__init__.py index cf3de0d3aa..659ac7f042 100644 --- a/django/contrib/gis/gdal/__init__.py +++ b/django/contrib/gis/gdal/__init__.py @@ -31,24 +31,34 @@ to a non-existant file location (e.g., `GDAL_LIBRARY_PATH='/null/path'`; setting to None/False/'' will not work as a string must be given). """ -from django.contrib.gis.gdal.error import check_err, OGRException, OGRIndexError, SRSException -from django.contrib.gis.gdal.geomtype import OGRGeomType +from django.contrib.gis.gdal.error import check_err, OGRException, OGRIndexError, SRSException # NOQA +from django.contrib.gis.gdal.geomtype import OGRGeomType # NOQA + +__all__ = [ + 'check_err', 'OGRException', 'OGRIndexError', 'SRSException', 'OGRGeomType', + 'HAS_GDAL', +] # Attempting to import objects that depend on the GDAL library. The # HAS_GDAL flag will be set to True if the library is present on # the system. try: - from django.contrib.gis.gdal.driver import Driver - from django.contrib.gis.gdal.datasource import DataSource - from django.contrib.gis.gdal.libgdal import gdal_version, gdal_full_version, GDAL_VERSION - from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform - from django.contrib.gis.gdal.geometries import OGRGeometry + from django.contrib.gis.gdal.driver import Driver # NOQA + from django.contrib.gis.gdal.datasource import DataSource # NOQA + from django.contrib.gis.gdal.libgdal import gdal_version, gdal_full_version, GDAL_VERSION # NOQA + from django.contrib.gis.gdal.srs import SpatialReference, CoordTransform # NOQA + from django.contrib.gis.gdal.geometries import OGRGeometry # NOQA HAS_GDAL = True + __all__ += [ + 'Driver', 'DataSource', 'gdal_version', 'gdal_full_version', + 'GDAL_VERSION', 'SpatialReference', 'CoordTransform', 'OGRGeometry', + ] except OGRException: HAS_GDAL = False try: from django.contrib.gis.gdal.envelope import Envelope + __all__ += ['Envelope'] except ImportError: # No ctypes, but don't raise an exception. pass diff --git a/django/contrib/gis/geoip/__init__.py b/django/contrib/gis/geoip/__init__.py index edb395f508..237567dd8a 100644 --- a/django/contrib/gis/geoip/__init__.py +++ b/django/contrib/gis/geoip/__init__.py @@ -11,8 +11,11 @@ Grab GeoIP.dat.gz and GeoLiteCity.dat.gz, and unzip them in the directory corresponding to settings.GEOIP_PATH. """ +__all__ = ['HAS_GEOIP'] + try: from .base import GeoIP, GeoIPException HAS_GEOIP = True + __all__ += ['GeoIP', 'GeoIPException'] except RuntimeError: # libgeoip.py raises a RuntimeError if no GeoIP library is found HAS_GEOIP = False diff --git a/django/contrib/gis/geoip/base.py b/django/contrib/gis/geoip/base.py index 05e3b5c268..5e3b39347a 100644 --- a/django/contrib/gis/geoip/base.py +++ b/django/contrib/gis/geoip/base.py @@ -5,7 +5,7 @@ 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 ( - GeoIPRecord, GeoIPTag, GeoIP_open, GeoIP_delete, GeoIP_database_info, + 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) diff --git a/django/contrib/gis/geometry/backend/geos.py b/django/contrib/gis/geometry/backend/geos.py index cdc40ed93f..b4d48dbc98 100644 --- a/django/contrib/gis/geometry/backend/geos.py +++ b/django/contrib/gis/geometry/backend/geos.py @@ -1,2 +1,4 @@ from django.contrib.gis.geos import ( GEOSGeometry as Geometry, GEOSException as GeometryException) + +__all__ = ['Geometry', 'GeometryException'] diff --git a/django/contrib/gis/geos/__init__.py b/django/contrib/gis/geos/__init__.py index 9e7c700aa0..70b73fad8b 100644 --- a/django/contrib/gis/geos/__init__.py +++ b/django/contrib/gis/geos/__init__.py @@ -3,9 +3,12 @@ The GeoDjango GEOS module. Please consult the GeoDjango documentation for more details: http://geodjango.org/docs/geos.html """ +__all__ = ['HAS_GEOS'] + try: - from .libgeos import geos_version, geos_version_info, GEOS_PREPARE + from .libgeos import geos_version, geos_version_info, GEOS_PREPARE # NOQA: flake8 detects only the last __all__ HAS_GEOS = True + __all__ += ['geos_version', 'geos_version_info', 'GEOS_PREPARE'] except ImportError: HAS_GEOS = False @@ -18,3 +21,11 @@ if HAS_GEOS: from .error import GEOSException, GEOSIndexError from .io import WKTReader, WKTWriter, WKBReader, WKBWriter from .factory import fromfile, fromstr + + __all__ += [ + 'GEOSGeometry', 'wkt_regex', 'hex_regex', 'Point', 'LineString', + 'LinearRing', 'Polygon', 'GeometryCollection', 'MultiPoint', + 'MultiLineString', 'MultiPolygon', 'GEOSException', 'GEOSIndexError', + 'WKTReader', 'WKTWriter', 'WKBReader', 'WKBWriter', 'fromfile', + 'fromstr', + ] diff --git a/django/contrib/gis/geos/io.py b/django/contrib/gis/geos/io.py index 97c4016865..f12be89830 100644 --- a/django/contrib/gis/geos/io.py +++ b/django/contrib/gis/geos/io.py @@ -6,6 +6,8 @@ reader and writer classes. from django.contrib.gis.geos.geometry import GEOSGeometry from django.contrib.gis.geos.prototypes.io import _WKTReader, _WKBReader, WKBWriter, WKTWriter +__all__ = ['WKBWriter', 'WKTWriter', 'WKBReader', 'WKTReader'] + # Public classes for (WKB|WKT)Reader, which return GEOSGeometry class WKBReader(_WKBReader): diff --git a/django/contrib/gis/geos/prototypes/__init__.py b/django/contrib/gis/geos/prototypes/__init__.py index 992a1ac514..72c9d7a0c1 100644 --- a/django/contrib/gis/geos/prototypes/__init__.py +++ b/django/contrib/gis/geos/prototypes/__init__.py @@ -5,12 +5,12 @@ """ # Coordinate sequence routines. -from django.contrib.gis.geos.prototypes.coordseq import (create_cs, get_cs, +from django.contrib.gis.geos.prototypes.coordseq import (create_cs, get_cs, # NOQA cs_clone, cs_getordinate, cs_setordinate, cs_getx, cs_gety, cs_getz, cs_setx, cs_sety, cs_setz, cs_getsize, cs_getdims) # Geometry routines. -from django.contrib.gis.geos.prototypes.geom import (from_hex, from_wkb, from_wkt, +from django.contrib.gis.geos.prototypes.geom import (from_hex, from_wkb, from_wkt, # NOQA create_point, create_linestring, create_linearring, create_polygon, create_collection, destroy_geom, get_extring, get_intring, get_nrings, get_geomn, geom_clone, geos_normalize, geos_type, geos_typeid, geos_get_srid, geos_set_srid, @@ -18,13 +18,13 @@ from django.contrib.gis.geos.prototypes.geom import (from_hex, from_wkb, from_wk to_hex, to_wkb, to_wkt) # Miscellaneous routines. -from django.contrib.gis.geos.prototypes.misc import * +from django.contrib.gis.geos.prototypes.misc import * # NOQA # Predicates -from django.contrib.gis.geos.prototypes.predicates import (geos_hasz, geos_isempty, +from django.contrib.gis.geos.prototypes.predicates import (geos_hasz, geos_isempty, # NOQA geos_isring, geos_issimple, geos_isvalid, geos_contains, geos_crosses, geos_disjoint, geos_equals, geos_equalsexact, geos_intersects, geos_overlaps, geos_relatepattern, geos_touches, geos_within) # Topology routines -from django.contrib.gis.geos.prototypes.topology import * +from django.contrib.gis.geos.prototypes.topology import * # NOQA diff --git a/django/contrib/gis/maps/google/__init__.py b/django/contrib/gis/maps/google/__init__.py index 37fdf94f1e..4f528f90c6 100644 --- a/django/contrib/gis/maps/google/__init__.py +++ b/django/contrib/gis/maps/google/__init__.py @@ -59,3 +59,8 @@ from django.contrib.gis.maps.google.gmap import GoogleMap, GoogleMapSet from django.contrib.gis.maps.google.overlays import GEvent, GIcon, GMarker, GPolygon, GPolyline from django.contrib.gis.maps.google.zoom import GoogleZoom + +__all__ = [ + 'GoogleMap', 'GoogleMapSet', 'GEvent', 'GIcon', 'GMarker', 'GPolygon', + 'GPolyline', 'GoogleZoom', +] diff --git a/django/contrib/gis/sitemaps/__init__.py b/django/contrib/gis/sitemaps/__init__.py index b2c96e4a55..4da3400a7c 100644 --- a/django/contrib/gis/sitemaps/__init__.py +++ b/django/contrib/gis/sitemaps/__init__.py @@ -1,3 +1,5 @@ # Geo-enabled Sitemap classes. from django.contrib.gis.sitemaps.georss import GeoRSSSitemap from django.contrib.gis.sitemaps.kml import KMLSitemap, KMZSitemap + +__all__ = ['GeoRSSSitemap', 'KMLSitemap', 'KMZSitemap'] diff --git a/django/contrib/gis/utils/__init__.py b/django/contrib/gis/utils/__init__.py index bdec5f0742..f6050e6b95 100644 --- a/django/contrib/gis/utils/__init__.py +++ b/django/contrib/gis/utils/__init__.py @@ -4,15 +4,15 @@ # Importing the utilities that depend on GDAL, if available. from django.contrib.gis.gdal import HAS_GDAL if HAS_GDAL: - from django.contrib.gis.utils.ogrinfo import ogrinfo, sample - from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect - from django.contrib.gis.utils.srs import add_postgis_srs, add_srs_entry + from django.contrib.gis.utils.ogrinfo import ogrinfo, sample # NOQA + from django.contrib.gis.utils.ogrinspect import mapping, ogrinspect # NOQA + from django.contrib.gis.utils.srs import add_postgis_srs, add_srs_entry # NOQA from django.core.exceptions import ImproperlyConfigured try: # LayerMapping requires DJANGO_SETTINGS_MODULE to be set, # so this needs to be in try/except. - from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError + from django.contrib.gis.utils.layermapping import LayerMapping, LayerMapError # NOQA except ImproperlyConfigured: pass -from django.contrib.gis.utils.wkt import precision_wkt +from django.contrib.gis.utils.wkt import precision_wkt # NOQA diff --git a/django/contrib/messages/__init__.py b/django/contrib/messages/__init__.py index a835f29dc9..40ba6ea6c7 100644 --- a/django/contrib/messages/__init__.py +++ b/django/contrib/messages/__init__.py @@ -1,2 +1,2 @@ -from django.contrib.messages.api import * -from django.contrib.messages.constants import * +from django.contrib.messages.api import * # NOQA +from django.contrib.messages.constants import * # NOQA diff --git a/django/core/cache/__init__.py b/django/core/cache/__init__.py index c242671c6c..747a12a023 100644 --- a/django/core/cache/__init__.py +++ b/django/core/cache/__init__.py @@ -14,19 +14,17 @@ class. See docs/topics/cache.txt for information on the public API. """ -import importlib - from django.conf import settings from django.core import signals from django.core.cache.backends.base import ( InvalidCacheBackendError, CacheKeyWarning, BaseCache) from django.core.exceptions import ImproperlyConfigured from django.utils.module_loading import import_by_path -from django.utils.six.moves.urllib.parse import parse_qsl __all__ = [ - 'get_cache', 'cache', 'DEFAULT_CACHE_ALIAS' + 'get_cache', 'cache', 'DEFAULT_CACHE_ALIAS', 'InvalidCacheBackendError', + 'CacheKeyWarning', 'BaseCache', ] DEFAULT_CACHE_ALIAS = 'default' diff --git a/django/core/cache/backends/db.py b/django/core/cache/backends/db.py index 40d1320e37..84786f7cfc 100644 --- a/django/core/cache/backends/db.py +++ b/django/core/cache/backends/db.py @@ -1,6 +1,5 @@ "Database cache backend." import base64 -import time from datetime import datetime try: diff --git a/django/core/files/__init__.py b/django/core/files/__init__.py index 0c3ef57af8..58a6fd8f85 100644 --- a/django/core/files/__init__.py +++ b/django/core/files/__init__.py @@ -1 +1,3 @@ from django.core.files.base import File + +__all__ = ['File'] diff --git a/django/core/handlers/wsgi.py b/django/core/handlers/wsgi.py index c310f1678a..4c54b3e39d 100644 --- a/django/core/handlers/wsgi.py +++ b/django/core/handlers/wsgi.py @@ -17,7 +17,7 @@ from django.utils.encoding import force_str, force_text from django.utils import six # For backwards compatibility -- lots of code uses this in the wild! -from django.http.response import REASON_PHRASES as STATUS_CODE_TEXT +from django.http.response import REASON_PHRASES as STATUS_CODE_TEXT # NOQA logger = logging.getLogger('django.request') diff --git a/django/core/mail/__init__.py b/django/core/mail/__init__.py index 1e2b35cc2f..5a01adc4ea 100644 --- a/django/core/mail/__init__.py +++ b/django/core/mail/__init__.py @@ -17,6 +17,14 @@ from django.core.mail.message import ( DEFAULT_ATTACHMENT_MIME_TYPE, make_msgid, BadHeaderError, forbid_multi_line_headers) +__all__ = [ + 'CachedDnsName', 'DNS_NAME', 'EmailMessage', 'EmailMultiAlternatives', + 'SafeMIMEText', 'SafeMIMEMultipart', 'DEFAULT_ATTACHMENT_MIME_TYPE', + 'make_msgid', 'BadHeaderError', 'forbid_multi_line_headers', + 'get_connection', 'send_mail', 'send_mass_mail', 'mail_admins', + 'mail_managers', +] + def get_connection(backend=None, fail_silently=False, **kwds): """Load an email backend and return an instance of it. diff --git a/django/core/management/base.py b/django/core/management/base.py index 17b8ab71af..ef967d021f 100644 --- a/django/core/management/base.py +++ b/django/core/management/base.py @@ -265,7 +265,7 @@ class BaseCommand(object): self.stderr = OutputWrapper(options.get('stderr', sys.stderr), self.style.ERROR) if self.can_import_settings: - from django.conf import settings + from django.conf import settings # NOQA saved_locale = None if not self.leave_locale_alone: diff --git a/django/core/management/commands/squashmigrations.py b/django/core/management/commands/squashmigrations.py index 3282fc54ee..ce8f667ebe 100644 --- a/django/core/management/commands/squashmigrations.py +++ b/django/core/management/commands/squashmigrations.py @@ -1,16 +1,12 @@ import sys -import os from optparse import make_option from django.core.management.base import BaseCommand, CommandError -from django.core.exceptions import ImproperlyConfigured from django.utils import six from django.db import connections, DEFAULT_DB_ALIAS, migrations -from django.db.migrations.loader import MigrationLoader, AmbiguityError -from django.db.migrations.autodetector import MigrationAutodetector, InteractiveMigrationQuestioner +from django.db.migrations.loader import AmbiguityError from django.db.migrations.executor import MigrationExecutor from django.db.migrations.writer import MigrationWriter -from django.db.models.loading import cache from django.db.migrations.optimizer import MigrationOptimizer diff --git a/django/core/management/validation.py b/django/core/management/validation.py index 90a78403fb..f0d6cae039 100644 --- a/django/core/management/validation.py +++ b/django/core/management/validation.py @@ -122,7 +122,7 @@ def get_validation_errors(outfile, app=None): e.add(opts, invalid_values_msg % f.name) if isinstance(f, models.ImageField): try: - from django.utils.image import Image + from django.utils.image import Image # NOQA except ImportError: e.add(opts, '"%s": To use ImageFields, you need to install Pillow. Get it at https://pypi.python.org/pypi/Pillow.' % f.name) if isinstance(f, models.BooleanField) and getattr(f, 'null', False): diff --git a/django/core/servers/basehttp.py b/django/core/servers/basehttp.py index 010b5e07dd..0e6d0d437c 100644 --- a/django/core/servers/basehttp.py +++ b/django/core/servers/basehttp.py @@ -14,12 +14,11 @@ import socket import sys import traceback from wsgiref import simple_server -from wsgiref.util import FileWrapper # for backwards compatibility +from wsgiref.util import FileWrapper # NOQA: for backwards compatibility from django.core.management.color import color_style from django.core.wsgi import get_wsgi_application from django.utils.module_loading import import_by_path -from django.utils import six from django.utils.six.moves.urllib.parse import urljoin from django.utils.six.moves import socketserver diff --git a/django/core/servers/fastcgi.py b/django/core/servers/fastcgi.py index a612142969..c42817c393 100644 --- a/django/core/servers/fastcgi.py +++ b/django/core/servers/fastcgi.py @@ -101,7 +101,7 @@ def runfastcgi(argset=[], **kwargs): return fastcgi_help() try: - import flup + import flup # NOQA except ImportError as e: sys.stderr.write("ERROR: %s\n" % e) sys.stderr.write(" Unable to load the flup package. In order to run django\n") diff --git a/django/db/migrations/__init__.py b/django/db/migrations/__init__.py index e072786473..e006bcbabc 100644 --- a/django/db/migrations/__init__.py +++ b/django/db/migrations/__init__.py @@ -1,2 +1,2 @@ -from .migration import Migration -from .operations import * +from .migration import Migration # NOQA +from .operations import * # NOQA diff --git a/django/db/migrations/operations/__init__.py b/django/db/migrations/operations/__init__.py index de91961298..c26fd84744 100644 --- a/django/db/migrations/operations/__init__.py +++ b/django/db/migrations/operations/__init__.py @@ -1,3 +1,11 @@ -from .models import CreateModel, DeleteModel, AlterModelTable, AlterUniqueTogether, AlterIndexTogether +from .models import (CreateModel, DeleteModel, AlterModelTable, + AlterUniqueTogether, AlterIndexTogether) from .fields import AddField, RemoveField, AlterField, RenameField from .special import SeparateDatabaseAndState, RunSQL, RunPython + +__all__ = [ + 'CreateModel', 'DeleteModel', 'AlterModelTable', 'AlterUniqueTogether', + 'AlterIndexTogether', + 'AddField', 'RemoveField', 'AlterField', 'RenameField', + 'SeparateDatabaseAndState', 'RunSQL', 'RunPython', +] diff --git a/django/db/models/__init__.py b/django/db/models/__init__.py index 2ee525faf1..cf219d39aa 100644 --- a/django/db/models/__init__.py +++ b/django/db/models/__init__.py @@ -1,18 +1,23 @@ from functools import wraps -from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured -from django.db.models.loading import get_apps, get_app_path, get_app_paths, get_app, get_models, get_model, register_models, UnavailableApp -from django.db.models.query import Q, QuerySet -from django.db.models.expressions import F -from django.db.models.manager import Manager -from django.db.models.base import Model -from django.db.models.aggregates import * -from django.db.models.fields import * -from django.db.models.fields.subclassing import SubfieldBase -from django.db.models.fields.files import FileField, ImageField -from django.db.models.fields.related import ForeignKey, ForeignObject, OneToOneField, ManyToManyField, ManyToOneRel, ManyToManyRel, OneToOneRel -from django.db.models.deletion import CASCADE, PROTECT, SET, SET_NULL, SET_DEFAULT, DO_NOTHING, ProtectedError -from django.db.models import signals +from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured # NOQA +from django.db.models.loading import ( # NOQA + get_apps, get_app_path, get_app_paths, get_app, get_models, get_model, + register_models, UnavailableApp) +from django.db.models.query import Q, QuerySet # NOQA +from django.db.models.expressions import F # NOQA +from django.db.models.manager import Manager # NOQA +from django.db.models.base import Model # NOQA +from django.db.models.aggregates import * # NOQA +from django.db.models.fields import * # NOQA +from django.db.models.fields.subclassing import SubfieldBase # NOQA +from django.db.models.fields.files import FileField, ImageField # NOQA +from django.db.models.fields.related import ( # NOQA + ForeignKey, ForeignObject, OneToOneField, ManyToManyField, + ManyToOneRel, ManyToManyRel, OneToOneRel) +from django.db.models.deletion import ( # NOQA + CASCADE, PROTECT, SET, SET_NULL, SET_DEFAULT, DO_NOTHING, ProtectedError) +from django.db.models import signals # NOQA def permalink(func): diff --git a/django/db/models/aggregates.py b/django/db/models/aggregates.py index 1db3890204..1ec11b4acb 100644 --- a/django/db/models/aggregates.py +++ b/django/db/models/aggregates.py @@ -3,6 +3,10 @@ Classes to represent the definitions of aggregate functions. """ from django.db.models.constants import LOOKUP_SEP +__all__ = [ + 'Aggregate', 'Avg', 'Count', 'Max', 'Min', 'StdDev', 'Sum', 'Variance', +] + def refs_aggregate(lookup_parts, aggregates): """ diff --git a/django/db/models/base.py b/django/db/models/base.py index fa3a1703e5..73df8633ca 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -5,7 +5,7 @@ import sys from functools import update_wrapper from django.utils.six.moves import zip -import django.db.models.manager # Imported to register signal handler. +import django.db.models.manager # NOQA: Imported to register signal handler. from django.conf import settings from django.core.exceptions import (ObjectDoesNotExist, MultipleObjectsReturned, FieldError, ValidationError, NON_FIELD_ERRORS) @@ -19,7 +19,7 @@ from django.db.models.query_utils import DeferredAttribute, deferred_class_facto from django.db.models.deletion import Collector from django.db.models.options import Options from django.db.models import signals -from django.db.models.loading import register_models, get_model, MODELS_MODULE_NAME +from django.db.models.loading import get_model, MODELS_MODULE_NAME from django.utils.translation import ugettext_lazy as _ from django.utils.functional import curry from django.utils.encoding import force_str, force_text diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index 8fe1c9e4e4..022de52134 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -25,6 +25,18 @@ from django.utils.encoding import smart_text, force_text, force_bytes from django.utils.ipv6 import clean_ipv6_address from django.utils import six +# Avoid "TypeError: Item in ``from list'' not a string" -- unicode_literals +# makes these strings unicode +__all__ = [str(x) for x in ( + 'AutoField', 'BLANK_CHOICE_DASH', 'BigIntegerField', 'BinaryField', + 'BooleanField', 'CharField', 'CommaSeparatedIntegerField', 'DateField', + 'DateTimeField', 'DecimalField', 'EmailField', 'Empty', 'Field', + 'FieldDoesNotExist', 'FilePathField', 'FloatField', + 'GenericIPAddressField', 'IPAddressField', 'IntegerField', 'NOT_PROVIDED', + 'NullBooleanField', 'PositiveIntegerField', 'PositiveSmallIntegerField', + 'SlugField', 'SmallIntegerField', 'TextField', 'TimeField', 'URLField', +)] + class Empty(object): pass diff --git a/django/db/models/query.py b/django/db/models/query.py index 2b8feed8cb..ca49f67712 100644 --- a/django/db/models/query.py +++ b/django/db/models/query.py @@ -8,7 +8,7 @@ import sys from django.conf import settings from django.core import exceptions -from django.db import connections, router, transaction, DatabaseError, IntegrityError +from django.db import connections, router, transaction, IntegrityError from django.db.models.constants import LOOKUP_SEP from django.db.models.fields import AutoField, Empty from django.db.models.query_utils import (Q, select_related_descend, diff --git a/django/db/models/sql/__init__.py b/django/db/models/sql/__init__.py index 8bc60c1d10..d1898bab6e 100644 --- a/django/db/models/sql/__init__.py +++ b/django/db/models/sql/__init__.py @@ -1,6 +1,6 @@ from django.db.models.sql.datastructures import EmptyResultSet -from django.db.models.sql.subqueries import * -from django.db.models.sql.query import * +from django.db.models.sql.subqueries import * # NOQA +from django.db.models.sql.query import * # NOQA from django.db.models.sql.where import AND, OR diff --git a/django/db/utils.py b/django/db/utils.py index 5d81fee44b..43abaf9b5a 100644 --- a/django/db/utils.py +++ b/django/db/utils.py @@ -1,4 +1,3 @@ -from functools import wraps from importlib import import_module import os import pkgutil diff --git a/django/dispatch/__init__.py b/django/dispatch/__init__.py index e6cd630d0c..be3baa30e1 100644 --- a/django/dispatch/__init__.py +++ b/django/dispatch/__init__.py @@ -6,4 +6,4 @@ See license.txt for original license. Heavily modified for Django's purposes. """ -from django.dispatch.dispatcher import Signal, receiver +from django.dispatch.dispatcher import Signal, receiver # NOQA diff --git a/django/forms/__init__.py b/django/forms/__init__.py index 34896d948d..c6573388db 100644 --- a/django/forms/__init__.py +++ b/django/forms/__init__.py @@ -2,8 +2,8 @@ Django validation and HTML form handling. """ -from django.core.exceptions import ValidationError -from django.forms.fields import * -from django.forms.forms import * -from django.forms.models import * -from django.forms.widgets import * +from django.core.exceptions import ValidationError # NOQA +from django.forms.fields import * # NOQA +from django.forms.forms import * # NOQA +from django.forms.models import * # NOQA +from django.forms.widgets import * # NOQA diff --git a/django/forms/extras/__init__.py b/django/forms/extras/__init__.py index 28316f472c..1026bce5e5 100644 --- a/django/forms/extras/__init__.py +++ b/django/forms/extras/__init__.py @@ -1 +1,3 @@ -from django.forms.extras.widgets import * +from django.forms.extras.widgets import SelectDateWidget + +__all__ = ['SelectDateWidget'] diff --git a/django/forms/fields.py b/django/forms/fields.py index b5816889f9..bd62a57200 100644 --- a/django/forms/fields.py +++ b/django/forms/fields.py @@ -30,7 +30,7 @@ from django.utils.six.moves.urllib.parse import urlsplit, urlunsplit from django.utils.translation import ugettext_lazy as _, ungettext_lazy # Provide this import for backwards compatibility. -from django.core.validators import EMPTY_VALUES +from django.core.validators import EMPTY_VALUES # NOQA __all__ = ( diff --git a/django/forms/widgets.py b/django/forms/widgets.py index 58bcabef98..a3f69d86ae 100644 --- a/django/forms/widgets.py +++ b/django/forms/widgets.py @@ -15,7 +15,7 @@ from django.utils.html import conditional_escape, format_html from django.utils.translation import ugettext_lazy from django.utils.encoding import force_text, python_2_unicode_compatible from django.utils.safestring import mark_safe -from django.utils import datetime_safe, formats, six +from django.utils import formats, six from django.utils.six.moves.urllib.parse import urljoin __all__ = ( diff --git a/django/http/__init__.py b/django/http/__init__.py index bd6429ffbb..dd24495c0f 100644 --- a/django/http/__init__.py +++ b/django/http/__init__.py @@ -1,10 +1,21 @@ from django.http.cookie import SimpleCookie, parse_cookie -from django.http.request import (HttpRequest, QueryDict, RawPostDataException, - UnreadablePostError, build_request_repr) +from django.http.request import (HttpRequest, QueryDict, + RawPostDataException, UnreadablePostError, build_request_repr) from django.http.response import (HttpResponse, StreamingHttpResponse, HttpResponseRedirect, HttpResponsePermanentRedirect, HttpResponseNotModified, HttpResponseBadRequest, HttpResponseForbidden, HttpResponseNotFound, HttpResponseNotAllowed, HttpResponseGone, HttpResponseServerError, Http404, BadHeaderError) -from django.http.utils import (fix_location_header, conditional_content_removal, - fix_IE_for_attach, fix_IE_for_vary) +from django.http.utils import (fix_location_header, + conditional_content_removal, fix_IE_for_attach, fix_IE_for_vary) + +__all__ = [ + 'SimpleCookie', 'parse_cookie', 'HttpRequest', 'QueryDict', + 'RawPostDataException', 'UnreadablePostError', 'build_request_repr', + 'HttpResponse', 'StreamingHttpResponse', 'HttpResponseRedirect', + 'HttpResponsePermanentRedirect', 'HttpResponseNotModified', + 'HttpResponseBadRequest', 'HttpResponseForbidden', 'HttpResponseNotFound', + 'HttpResponseNotAllowed', 'HttpResponseGone', 'HttpResponseServerError', + 'Http404', 'BadHeaderError', 'fix_location_header', + 'conditional_content_removal', 'fix_IE_for_attach', 'fix_IE_for_vary', +] diff --git a/django/middleware/doc.py b/django/middleware/doc.py index a2f00b6ded..2034880eca 100644 --- a/django/middleware/doc.py +++ b/django/middleware/doc.py @@ -3,4 +3,4 @@ import warnings warnings.warn(__doc__, DeprecationWarning, stacklevel=2) -from django.contrib.admindocs.middleware import XViewMiddleware +from django.contrib.admindocs.middleware import XViewMiddleware # NOQA diff --git a/django/template/__init__.py b/django/template/__init__.py index ca1bd49b4f..576d3bc920 100644 --- a/django/template/__init__.py +++ b/django/template/__init__.py @@ -50,7 +50,7 @@ u'' """ # Template lexing symbols -from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END, +from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END, # NOQA BLOCK_TAG_START, COMMENT_TAG_END, COMMENT_TAG_START, FILTER_ARGUMENT_SEPARATOR, FILTER_SEPARATOR, SINGLE_BRACE_END, SINGLE_BRACE_START, TOKEN_BLOCK, TOKEN_COMMENT, TOKEN_TEXT, TOKEN_VAR, @@ -58,22 +58,22 @@ from django.template.base import (ALLOWED_VARIABLE_CHARS, BLOCK_TAG_END, VARIABLE_TAG_END, VARIABLE_TAG_START, filter_re, tag_re) # Exceptions -from django.template.base import (ContextPopException, InvalidTemplateLibrary, +from django.template.base import (ContextPopException, InvalidTemplateLibrary, # NOQA TemplateDoesNotExist, TemplateEncodingError, TemplateSyntaxError, VariableDoesNotExist) # Template parts -from django.template.base import (Context, FilterExpression, Lexer, Node, +from django.template.base import (Context, FilterExpression, Lexer, Node, # NOQA NodeList, Parser, RequestContext, Origin, StringOrigin, Template, TextNode, Token, TokenParser, Variable, VariableNode, constant_string, filter_raw_string) # Compiling templates -from django.template.base import (compile_string, resolve_variable, +from django.template.base import (compile_string, resolve_variable, # NOQA unescape_string_literal, generic_tag_compiler) # Library management -from django.template.base import (Library, add_to_builtins, builtins, +from django.template.base import (Library, add_to_builtins, builtins, # NOQA get_library, get_templatetags_modules, get_text_list, import_library, libraries) diff --git a/django/template/base.py b/django/template/base.py index 5cc5dd684f..2979f2a8f1 100644 --- a/django/template/base.py +++ b/django/template/base.py @@ -6,7 +6,7 @@ from importlib import import_module from inspect import getargspec, getcallargs from django.conf import settings -from django.template.context import (BaseContext, Context, RequestContext, +from django.template.context import (BaseContext, Context, RequestContext, # NOQA: imported for backwards compatability ContextPopException) from django.utils.itercompat import is_iterable from django.utils.text import (smart_split, unescape_string_literal, diff --git a/django/test/__init__.py b/django/test/__init__.py index 58d54df5e2..98ff4393a3 100644 --- a/django/test/__init__.py +++ b/django/test/__init__.py @@ -8,3 +8,9 @@ from django.test.testcases import (TestCase, TransactionTestCase, skipUnlessDBFeature ) from django.test.utils import override_settings + +__all__ = [ + 'Client', 'RequestFactory', 'TestCase', 'TransactionTestCase', + 'SimpleTestCase', 'LiveServerTestCase', 'skipIfDBFeature', + 'skipUnlessDBFeature', 'override_settings', +] diff --git a/django/test/testcases.py b/django/test/testcases.py index b2d386cc44..3fed8c6aa7 100644 --- a/django/test/testcases.py +++ b/django/test/testcases.py @@ -12,7 +12,7 @@ import socket import sys import threading import unittest -from unittest import skipIf # Imported here for backward compatibility +from unittest import skipIf # NOQA: Imported here for backward compatibility from unittest.util import safe_repr from django.conf import settings diff --git a/django/utils/autoreload.py b/django/utils/autoreload.py index 66ffd0db4d..70fe508284 100644 --- a/django/utils/autoreload.py +++ b/django/utils/autoreload.py @@ -44,7 +44,7 @@ except ImportError: # This import does nothing, but it's necessary to avoid some race conditions # in the threading module. See http://code.djangoproject.com/ticket/2330 . try: - import threading + import threading # NOQA except ImportError: pass diff --git a/django/utils/log.py b/django/utils/log.py index e7044741f0..488632882c 100644 --- a/django/utils/log.py +++ b/django/utils/log.py @@ -1,5 +1,4 @@ import logging -import traceback from django.conf import settings from django.core import mail @@ -7,8 +6,8 @@ from django.core.mail import get_connection from django.views.debug import ExceptionReporter, get_exception_reporter_filter # Imports kept for backwards-compatibility in Django 1.7. -from logging import NullHandler -from logging.config import dictConfig +from logging import NullHandler # NOQA +from logging.config import dictConfig # NOQA getLogger = logging.getLogger diff --git a/django/utils/text.py b/django/utils/text.py index 15a231de8a..8f20e8ed88 100644 --- a/django/utils/text.py +++ b/django/utils/text.py @@ -15,7 +15,7 @@ from django.utils.safestring import mark_safe if six.PY2: # Import force_unicode even though this module doesn't use it, because some # people rely on it being here. - from django.utils.encoding import force_unicode + from django.utils.encoding import force_unicode # NOQA # Capitalizes the first letter of a string. capfirst = lambda x: x and force_text(x)[0].upper() + force_text(x)[1:] diff --git a/django/views/generic/__init__.py b/django/views/generic/__init__.py index 1a98067aa6..d0dbd53256 100644 --- a/django/views/generic/__init__.py +++ b/django/views/generic/__init__.py @@ -7,6 +7,14 @@ from django.views.generic.edit import FormView, CreateView, UpdateView, DeleteVi from django.views.generic.list import ListView +__all__ = [ + 'View', 'TemplateView', 'RedirectView', 'ArchiveIndexView', + 'YearArchiveView', 'MonthArchiveView', 'WeekArchiveView', 'DayArchiveView', + 'TodayArchiveView', 'DateDetailView', 'DetailView', 'FormView', + 'CreateView', 'UpdateView', 'DeleteView', 'ListView', 'GenericViewError', +] + + class GenericViewError(Exception): """A problem in a generic view.""" pass diff --git a/setup.cfg b/setup.cfg index 9577ecc88a..986dc37cd3 100644 --- a/setup.cfg +++ b/setup.cfg @@ -3,8 +3,8 @@ doc_files = docs extras AUTHORS INSTALL LICENSE README.rst install-script = scripts/rpm-install.sh [flake8] -exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py,./django/utils/six.py -ignore=E124,E125,E127,E128,E226,E241,E251,E302,E501,E261,F401,F403,W601 +exclude=./django/utils/dictconfig.py,./django/contrib/comments/*,./django/utils/unittest.py,./tests/comment_tests/*,./django/test/_doctest.py,./django/utils/six.py,./django/conf/app_template/* +ignore=E124,E125,E127,E128,E226,E241,E251,E302,E501,E261,W601 [metadata] license-file = LICENSE diff --git a/tests/admin_changelist/admin.py b/tests/admin_changelist/admin.py index b42f025b79..d0797581dc 100644 --- a/tests/admin_changelist/admin.py +++ b/tests/admin_changelist/admin.py @@ -1,8 +1,7 @@ from django.contrib import admin from django.core.paginator import Paginator -from .models import (Event, Child, Parent, Genre, Band, Musician, Group, - Quartet, Membership, ChordsMusician, ChordsBand, Invitation, Swallow) +from .models import Event, Child, Parent, Swallow site = admin.AdminSite(name="admin") diff --git a/tests/admin_custom_urls/tests.py b/tests/admin_custom_urls/tests.py index 7b46f4848a..f7a469efe9 100644 --- a/tests/admin_custom_urls/tests.py +++ b/tests/admin_custom_urls/tests.py @@ -1,5 +1,4 @@ from __future__ import unicode_literals -import warnings from django.contrib.admin.utils import quote from django.core.urlresolvers import reverse diff --git a/tests/admin_scripts/broken_app/models.py b/tests/admin_scripts/broken_app/models.py index f37f1efc11..2c407ddcdc 100644 --- a/tests/admin_scripts/broken_app/models.py +++ b/tests/admin_scripts/broken_app/models.py @@ -1 +1 @@ -from django.db import modelz +from django.db import modelz # NOQA diff --git a/tests/admin_scripts/complex_app/models/bar.py b/tests/admin_scripts/complex_app/models/bar.py index 6c1ee89b76..8db46f4f57 100644 --- a/tests/admin_scripts/complex_app/models/bar.py +++ b/tests/admin_scripts/complex_app/models/bar.py @@ -1,7 +1,5 @@ from django.db import models -from ..admin import foo - class Bar(models.Model): name = models.CharField(max_length=5) diff --git a/tests/admin_scripts/simple_app/models.py b/tests/admin_scripts/simple_app/models.py index e5b9e297c5..d555ad80ea 100644 --- a/tests/admin_scripts/simple_app/models.py +++ b/tests/admin_scripts/simple_app/models.py @@ -1 +1,3 @@ from ..complex_app.models.bar import Bar + +__all__ = ['Bar'] diff --git a/tests/admin_validation/tests.py b/tests/admin_validation/tests.py index 705de9cb54..f1346647ee 100644 --- a/tests/admin_validation/tests.py +++ b/tests/admin_validation/tests.py @@ -6,7 +6,7 @@ from django.core.exceptions import ImproperlyConfigured from django.test import TestCase from django.test.utils import str_prefix -from .models import Song, Book, Album, TwoAlbumFKAndAnE, State, City +from .models import Song, Book, Album, TwoAlbumFKAndAnE, City class SongForm(forms.ModelForm): diff --git a/tests/admin_views/tests.py b/tests/admin_views/tests.py index d5232fb8f2..91af9521a3 100644 --- a/tests/admin_views/tests.py +++ b/tests/admin_views/tests.py @@ -3419,7 +3419,6 @@ class SeleniumAdminViewsFirefoxTests(AdminSeleniumWebDriverTestCase): main form and with stacked and tabular inlines. Refs #13068, #9264, #9983, #9784. """ - from selenium.common.exceptions import TimeoutException self.admin_login(username='super', password='secret', login_url='/test_admin/admin/') self.selenium.get('%s%s' % (self.live_server_url, '/test_admin/admin/admin_views/mainprepopulated/add/')) diff --git a/tests/app_loading/tests.py b/tests/app_loading/tests.py index 1c2502bbcf..20ec064d69 100644 --- a/tests/app_loading/tests.py +++ b/tests/app_loading/tests.py @@ -3,10 +3,8 @@ from __future__ import unicode_literals import copy import os import sys -import time from unittest import TestCase -from django.conf import Settings from django.db.models.loading import cache, load_app, get_model, get_models, AppCache from django.test.utils import override_settings from django.utils._os import upath diff --git a/tests/context_processors/urls.py b/tests/context_processors/urls.py index 9340cdfc38..1b9f47c6b6 100644 --- a/tests/context_processors/urls.py +++ b/tests/context_processors/urls.py @@ -1,4 +1,4 @@ -from django.conf.urls import patterns, url +from django.conf.urls import patterns from . import views diff --git a/tests/delete/tests.py b/tests/delete/tests.py index 70bdd3e331..7bef83a670 100644 --- a/tests/delete/tests.py +++ b/tests/delete/tests.py @@ -4,7 +4,7 @@ from django.db import models, IntegrityError, connection from django.test import TestCase, skipUnlessDBFeature, skipIfDBFeature from django.utils.six.moves import xrange -from .models import (R, RChild, S, T, U, A, M, MR, MRNull, +from .models import (R, RChild, S, T, A, M, MR, MRNull, create_a, get_default_r, User, Avatar, HiddenUser, HiddenUserProfile, M2MTo, M2MFrom, Parent, Child, Base) diff --git a/tests/deprecation/tests.py b/tests/deprecation/tests.py index 61baf5ca12..f949bea24e 100644 --- a/tests/deprecation/tests.py +++ b/tests/deprecation/tests.py @@ -3,7 +3,6 @@ import warnings from django.test import SimpleTestCase, RequestFactory from django.utils import six -from django.utils.datastructures import MergeDict from django.utils.deprecation import RenameMethodsBase diff --git a/tests/file_storage/tests.py b/tests/file_storage/tests.py index 36996a69ef..1f676d04b1 100644 --- a/tests/file_storage/tests.py +++ b/tests/file_storage/tests.py @@ -15,7 +15,6 @@ try: except ImportError: import dummy_threading as threading -from django.conf import settings from django.core.cache import cache from django.core.exceptions import SuspiciousOperation, ImproperlyConfigured from django.core.files.base import File, ContentFile diff --git a/tests/files/tests.py b/tests/files/tests.py index d18e153b0d..43138d9b57 100644 --- a/tests/files/tests.py +++ b/tests/files/tests.py @@ -4,7 +4,6 @@ from __future__ import unicode_literals from io import BytesIO import os import gzip -import shutil import tempfile import unittest import zlib @@ -15,7 +14,6 @@ from django.core.files.move import file_move_safe from django.core.files.base import ContentFile from django.core.files.uploadedfile import SimpleUploadedFile, UploadedFile from django.core.files.temp import NamedTemporaryFile -from django.test import TestCase from django.utils._os import upath from django.utils import six diff --git a/tests/forms_tests/urls.py b/tests/forms_tests/urls.py index cbd760081a..835e6507eb 100644 --- a/tests/forms_tests/urls.py +++ b/tests/forms_tests/urls.py @@ -1,5 +1,4 @@ from django.conf.urls import patterns, url -from django.views.generic.edit import UpdateView from .views import ArticleFormView diff --git a/tests/generic_inline_admin/tests.py b/tests/generic_inline_admin/tests.py index d56c7fb8e8..1cf2f492a4 100644 --- a/tests/generic_inline_admin/tests.py +++ b/tests/generic_inline_admin/tests.py @@ -2,7 +2,6 @@ from __future__ import unicode_literals import warnings -from django.conf import settings from django.contrib import admin from django.contrib.admin.sites import AdminSite from django.contrib.contenttypes.generic import ( diff --git a/tests/i18n/tests.py b/tests/i18n/tests.py index 0f9bf7e4ed..3101418d58 100644 --- a/tests/i18n/tests.py +++ b/tests/i18n/tests.py @@ -16,7 +16,7 @@ from django.test.utils import override_settings, TransRealMixin from django.utils import translation from django.utils.formats import (get_format, date_format, time_format, localize, localize_input, iter_format_modules, get_format_modules, - number_format, reset_format_cache, sanitize_separators) + reset_format_cache, sanitize_separators) from django.utils.numberformat import format as nformat from django.utils._os import upath from django.utils.safestring import mark_safe, SafeBytes, SafeString, SafeText @@ -25,11 +25,11 @@ from django.utils.six import PY3 from django.utils.translation import (activate, deactivate, get_language, get_language_from_request, get_language_info, to_locale, trans_real, - gettext, gettext_lazy, + gettext_lazy, ugettext, ugettext_lazy, - ngettext, ngettext_lazy, - ungettext, ungettext_lazy, - pgettext, pgettext_lazy, + ngettext_lazy, + ungettext_lazy, + pgettext, npgettext, npgettext_lazy, check_for_language) diff --git a/tests/logging_tests/tests.py b/tests/logging_tests/tests.py index 00fcef2a6d..bd1983f74e 100644 --- a/tests/logging_tests/tests.py +++ b/tests/logging_tests/tests.py @@ -1,9 +1,6 @@ from __future__ import unicode_literals -import copy import logging -import sys -from unittest import skipUnless import warnings from django.conf import LazySettings diff --git a/tests/managers_regress/tests.py b/tests/managers_regress/tests.py index f05e3e6085..3798b91ef5 100644 --- a/tests/managers_regress/tests.py +++ b/tests/managers_regress/tests.py @@ -1,7 +1,6 @@ from __future__ import unicode_literals import copy -from django.conf import settings from django.db import models from django.db.models.loading import cache from django.template import Context, Template diff --git a/tests/many_to_one_regress/tests.py b/tests/many_to_one_regress/tests.py index 60856a800a..adb51b6879 100644 --- a/tests/many_to_one_regress/tests.py +++ b/tests/many_to_one_regress/tests.py @@ -2,7 +2,6 @@ from __future__ import unicode_literals from django.db import models from django.test import TestCase -from django.utils import six from .models import ( First, Third, Parent, Child, Category, Record, Relation, Car, Driver) diff --git a/tests/middleware/tests.py b/tests/middleware/tests.py index b11dda0c68..b474f6b0e3 100644 --- a/tests/middleware/tests.py +++ b/tests/middleware/tests.py @@ -5,7 +5,7 @@ import gzip from io import BytesIO import random import re -from unittest import expectedFailure, skipIf +from unittest import skipIf import warnings from django.conf import settings diff --git a/tests/migrations/faulty_migrations/import_error/__init__.py b/tests/migrations/faulty_migrations/import_error/__init__.py index 616c209dad..a07bc4fa6d 100644 --- a/tests/migrations/faulty_migrations/import_error/__init__.py +++ b/tests/migrations/faulty_migrations/import_error/__init__.py @@ -1 +1 @@ -import fake_python_module +import fake_python_module # NOQA diff --git a/tests/migrations/test_executor.py b/tests/migrations/test_executor.py index e86d215849..5c0131d1d3 100644 --- a/tests/migrations/test_executor.py +++ b/tests/migrations/test_executor.py @@ -1,4 +1,3 @@ -from django.test import TransactionTestCase from django.test.utils import override_settings from django.db import connection from django.db.migrations.executor import MigrationExecutor diff --git a/tests/migrations/test_optimizer.py b/tests/migrations/test_optimizer.py index c7913d3352..1564ba91b4 100644 --- a/tests/migrations/test_optimizer.py +++ b/tests/migrations/test_optimizer.py @@ -1,5 +1,4 @@ # encoding: utf8 -import operator from django.test import TestCase from django.db.migrations.optimizer import MigrationOptimizer from django.db import migrations diff --git a/tests/model_forms/models.py b/tests/model_forms/models.py index 37c3b37864..34644a4bb9 100644 --- a/tests/model_forms/models.py +++ b/tests/model_forms/models.py @@ -102,7 +102,7 @@ class TextFile(models.Model): return self.description try: - from django.utils.image import Image + from django.utils.image import Image # NOQA: detect if Pillow is installed test_images = True diff --git a/tests/model_package/models/__init__.py b/tests/model_package/models/__init__.py index ec29d667f9..943b8fa4aa 100644 --- a/tests/model_package/models/__init__.py +++ b/tests/model_package/models/__init__.py @@ -1,3 +1,5 @@ # Import all the models from subpackages from .article import Article from .publication import Publication + +__all__ = ['Article', 'Publication'] diff --git a/tests/modeladmin/tests.py b/tests/modeladmin/tests.py index f5f2ba49a4..99cbc29951 100644 --- a/tests/modeladmin/tests.py +++ b/tests/modeladmin/tests.py @@ -4,7 +4,6 @@ from datetime import date import unittest from django import forms -from django.conf import settings from django.contrib.admin.options import (ModelAdmin, TabularInline, HORIZONTAL, VERTICAL) from django.contrib.admin.sites import AdminSite diff --git a/tests/proxy_models/tests.py b/tests/proxy_models/tests.py index 22ba47b84f..3582625f45 100644 --- a/tests/proxy_models/tests.py +++ b/tests/proxy_models/tests.py @@ -1,7 +1,6 @@ from __future__ import unicode_literals import copy -from django.conf import settings from django.contrib import admin from django.contrib.contenttypes.models import ContentType from django.core import management @@ -17,7 +16,7 @@ from .models import (MyPerson, Person, StatusPerson, LowerStatusPerson, MyPersonProxy, Abstract, OtherPerson, User, UserProxy, UserProxyProxy, Country, State, StateProxy, TrackerUser, BaseUser, Bug, ProxyTrackerUser, Improvement, ProxyProxyBug, ProxyBug, ProxyImprovement, Issue) -from .admin import admin as force_admin_model_registration +from .admin import admin as force_admin_model_registration # NOQA class ProxyModelTests(TestCase): diff --git a/tests/queryset_pickle/tests.py b/tests/queryset_pickle/tests.py index 602739fa54..7ce4348c1a 100644 --- a/tests/queryset_pickle/tests.py +++ b/tests/queryset_pickle/tests.py @@ -3,7 +3,6 @@ from __future__ import unicode_literals import pickle import datetime -from django.db import models from django.test import TestCase from .models import Group, Event, Happening, Container, M2MModel diff --git a/tests/requests/tests.py b/tests/requests/tests.py index 067d71b3d7..137b324588 100644 --- a/tests/requests/tests.py +++ b/tests/requests/tests.py @@ -6,9 +6,8 @@ from io import BytesIO from itertools import chain import time from unittest import skipIf -import warnings -from django.db import connection, connections, DEFAULT_DB_ALIAS +from django.db import connection, connections from django.core import signals from django.core.exceptions import SuspiciousOperation from django.core.handlers.wsgi import WSGIRequest, LimitedStream diff --git a/tests/select_for_update/tests.py b/tests/select_for_update/tests.py index b24181981c..6fadbdb799 100644 --- a/tests/select_for_update/tests.py +++ b/tests/select_for_update/tests.py @@ -1,6 +1,5 @@ from __future__ import unicode_literals -import sys import time import unittest diff --git a/tests/select_related_regress/tests.py b/tests/select_related_regress/tests.py index 5e155ab033..7b1455753d 100644 --- a/tests/select_related_regress/tests.py +++ b/tests/select_related_regress/tests.py @@ -5,7 +5,7 @@ from django.utils import six from .models import (Building, Child, Device, Port, Item, Country, Connection, ClientStatus, State, Client, SpecialClient, TUser, Person, Student, - Organizer, Class, Enrollment, Hen, Chick, Base, A, B, C) + Organizer, Class, Enrollment, Hen, Chick, A, B, C) class SelectRelatedRegressTests(TestCase): diff --git a/tests/serializers/tests.py b/tests/serializers/tests.py index 71f5c1802e..a381396b40 100644 --- a/tests/serializers/tests.py +++ b/tests/serializers/tests.py @@ -14,7 +14,6 @@ except ImportError: HAS_YAML = False -from django.conf import settings from django.core import management, serializers from django.db import transaction, connection from django.test import TestCase, TransactionTestCase diff --git a/tests/serializers_regress/tests.py b/tests/serializers_regress/tests.py index 6d0bb70170..a56abe0b6b 100644 --- a/tests/serializers_regress/tests.py +++ b/tests/serializers_regress/tests.py @@ -26,7 +26,6 @@ from django.db import connection, models from django.http import HttpResponse from django.test import TestCase from django.utils import six -from django.utils.encoding import force_text from django.utils.functional import curry from .models import (BinaryData, BooleanData, CharData, DateData, DateTimeData, EmailData, diff --git a/tests/settings_tests/models.py b/tests/settings_tests/models.py deleted file mode 100644 index e69de29bb2..0000000000 diff --git a/tests/settings_tests/tests.py b/tests/settings_tests/tests.py index 4a0c363c39..b1321d50f3 100644 --- a/tests/settings_tests/tests.py +++ b/tests/settings_tests/tests.py @@ -1,8 +1,7 @@ -import os import unittest import warnings -from django.conf import settings, global_settings +from django.conf import settings from django.core.exceptions import ImproperlyConfigured from django.http import HttpRequest from django.test import SimpleTestCase, TransactionTestCase, TestCase, signals diff --git a/tests/tablespaces/tests.py b/tests/tablespaces/tests.py index 401195b5c3..f04bf29611 100644 --- a/tests/tablespaces/tests.py +++ b/tests/tablespaces/tests.py @@ -4,7 +4,6 @@ import copy from django.conf import settings from django.db import connection -from django.db import models from django.db.models.loading import cache from django.core.management.color import no_style from django.test import TestCase, skipIfDBFeature, skipUnlessDBFeature diff --git a/tests/template_tests/templatetags/broken_tag.py b/tests/template_tests/templatetags/broken_tag.py index c70e183f0e..414dc8412f 100644 --- a/tests/template_tests/templatetags/broken_tag.py +++ b/tests/template_tests/templatetags/broken_tag.py @@ -1 +1 @@ -from django import Xtemplate +from django import Xtemplate # NOQA diff --git a/tests/template_tests/templatetags/subpackage/echo_invalid.py b/tests/template_tests/templatetags/subpackage/echo_invalid.py index c12ea65507..0764b9c8fa 100644 --- a/tests/template_tests/templatetags/subpackage/echo_invalid.py +++ b/tests/template_tests/templatetags/subpackage/echo_invalid.py @@ -1 +1 @@ -import nonexistent.module +import nonexistent.module # NOQA diff --git a/tests/test_client/tests.py b/tests/test_client/tests.py index a01d1f3845..cd59f50213 100644 --- a/tests/test_client/tests.py +++ b/tests/test_client/tests.py @@ -22,7 +22,6 @@ rather than the HTML rendered to the end-user. """ from __future__ import unicode_literals -from django.conf import settings from django.core import mail from django.test import Client, TestCase, RequestFactory from django.test.utils import override_settings @@ -430,7 +429,6 @@ class ClientTest(TestCase): except KeyError: pass - from django.contrib.sessions.models import Session self.client.post('/test_client/session_view/') # Check that the session was modified diff --git a/tests/test_runner/test_discover_runner.py b/tests/test_runner/test_discover_runner.py index bd26e2e73d..d577f26826 100644 --- a/tests/test_runner/test_discover_runner.py +++ b/tests/test_runner/test_discover_runner.py @@ -1,6 +1,5 @@ from contextlib import contextmanager import os -import sys from unittest import expectedFailure, TestSuite, TextTestRunner, defaultTestLoader from django.test import TestCase diff --git a/tests/test_runner/tests.py b/tests/test_runner/tests.py index 255f8f864f..8b9dbe3fae 100644 --- a/tests/test_runner/tests.py +++ b/tests/test_runner/tests.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals from importlib import import_module from optparse import make_option -import sys import unittest from django.core.exceptions import ImproperlyConfigured diff --git a/tests/test_runner_deprecation_app/models.py b/tests/test_runner_deprecation_app/models.py index 71a8362390..e69de29bb2 100644 --- a/tests/test_runner_deprecation_app/models.py +++ b/tests/test_runner_deprecation_app/models.py @@ -1,3 +0,0 @@ -from django.db import models - -# Create your models here. diff --git a/tests/timezones/tests.py b/tests/timezones/tests.py index 79fdcaa971..f5f75c5284 100644 --- a/tests/timezones/tests.py +++ b/tests/timezones/tests.py @@ -1,7 +1,6 @@ from __future__ import unicode_literals import datetime -import os import re import sys from unittest import skipIf @@ -13,10 +12,8 @@ try: except ImportError: pytz = None -from django.conf import settings from django.core import serializers from django.core.urlresolvers import reverse -from django.db import connection from django.db.models import Min, Max from django.http import HttpRequest from django.template import Context, RequestContext, Template, TemplateSyntaxError diff --git a/tests/timezones/urls.py b/tests/timezones/urls.py index e9a7a90df9..bb028d917a 100644 --- a/tests/timezones/urls.py +++ b/tests/timezones/urls.py @@ -1,7 +1,7 @@ from django.conf.urls import patterns, include from django.contrib import admin -from . import admin as tz_admin +from . import admin as tz_admin # NOQA: register tz_admin urlpatterns = patterns('', (r'^admin/', include(admin.site.urls)), diff --git a/tests/urlpatterns_reverse/erroneous_views_module.py b/tests/urlpatterns_reverse/erroneous_views_module.py index 7f6b75e00f..52b9bc5163 100644 --- a/tests/urlpatterns_reverse/erroneous_views_module.py +++ b/tests/urlpatterns_reverse/erroneous_views_module.py @@ -1,4 +1,4 @@ -import non_existent +import non_existent # NOQA def erroneous_view(request): pass diff --git a/tests/urlpatterns_reverse/tests.py b/tests/urlpatterns_reverse/tests.py index 4e2c76a1a0..9572a5bc26 100644 --- a/tests/urlpatterns_reverse/tests.py +++ b/tests/urlpatterns_reverse/tests.py @@ -5,7 +5,6 @@ from __future__ import unicode_literals import unittest -from django.conf import settings from django.contrib.auth.models import User from django.core.exceptions import ImproperlyConfigured, ViewDoesNotExist from django.core.urlresolvers import (reverse, reverse_lazy, resolve, get_callable, diff --git a/tests/urlpatterns_reverse/views.py b/tests/urlpatterns_reverse/views.py index 88d169a118..6bb8849472 100644 --- a/tests/urlpatterns_reverse/views.py +++ b/tests/urlpatterns_reverse/views.py @@ -17,7 +17,7 @@ def defaults_view(request, arg1, arg2): pass def erroneous_view(request): - import non_existent + import non_existent # NOQA def pass_resolver_match_view(request, *args, **kwargs): response = HttpResponse('') diff --git a/tests/utils_tests/test_crypto.py b/tests/utils_tests/test_crypto.py index 4c1d10bb5f..d36f82e592 100644 --- a/tests/utils_tests/test_crypto.py +++ b/tests/utils_tests/test_crypto.py @@ -2,8 +2,6 @@ from __future__ import unicode_literals import binascii import hashlib -import math -import timeit import unittest from django.utils.crypto import constant_time_compare, pbkdf2 diff --git a/tests/utils_tests/test_module/bad_module.py b/tests/utils_tests/test_module/bad_module.py index 69444b0e54..55bbdd9d3a 100644 --- a/tests/utils_tests/test_module/bad_module.py +++ b/tests/utils_tests/test_module/bad_module.py @@ -1,3 +1,3 @@ -import a_package_name_that_does_not_exist +import a_package_name_that_does_not_exist # NOQA content = 'Bad Module' diff --git a/tests/utils_tests/test_module_loading.py b/tests/utils_tests/test_module_loading.py index d808ab8783..1886631006 100644 --- a/tests/utils_tests/test_module_loading.py +++ b/tests/utils_tests/test_module_loading.py @@ -44,7 +44,7 @@ class DefaultLoader(unittest.TestCase): self.assertRaises(ImportError, import_module, 'utils_tests.test_module.django') # Don't be confused by caching of import misses - import types # causes attempted import of utils_tests.types + import types # NOQA: causes attempted import of utils_tests.types self.assertFalse(module_has_submodule(sys.modules['utils_tests'], 'types')) # A module which doesn't have a __path__ (so no submodules) diff --git a/tests/utils_tests/test_safestring.py b/tests/utils_tests/test_safestring.py index 4673b26ac7..80b3fadcd0 100644 --- a/tests/utils_tests/test_safestring.py +++ b/tests/utils_tests/test_safestring.py @@ -4,7 +4,6 @@ from django.template import Template, Context from django.test import TestCase from django.utils.encoding import force_text, force_bytes from django.utils.functional import lazy, Promise -from django.utils.html import escape from django.utils.safestring import mark_safe, mark_for_escaping from django.utils import six from django.utils import translation diff --git a/tests/utils_tests/test_text.py b/tests/utils_tests/test_text.py index 1b1642e2ce..441898c0b4 100644 --- a/tests/utils_tests/test_text.py +++ b/tests/utils_tests/test_text.py @@ -1,8 +1,6 @@ # -*- coding: utf-8 -*- from __future__ import unicode_literals -import warnings - from django.test import SimpleTestCase from django.utils import text diff --git a/tests/utils_tests/test_timezone.py b/tests/utils_tests/test_timezone.py index de80afe325..fe67d105c3 100644 --- a/tests/utils_tests/test_timezone.py +++ b/tests/utils_tests/test_timezone.py @@ -4,7 +4,6 @@ import pickle import unittest from django.test.utils import override_settings -from django.utils import six from django.utils import timezone diff --git a/tests/version/tests.py b/tests/version/tests.py index 0a40d988bb..8663d52cc5 100644 --- a/tests/version/tests.py +++ b/tests/version/tests.py @@ -1,4 +1,3 @@ -import re from unittest import TestCase from django import get_version diff --git a/tests/view_tests/generic_urls.py b/tests/view_tests/generic_urls.py index a3af059e39..5130f21024 100644 --- a/tests/view_tests/generic_urls.py +++ b/tests/view_tests/generic_urls.py @@ -4,8 +4,7 @@ from __future__ import unicode_literals from django.conf.urls import patterns, url from django.views.generic import RedirectView -from . import views -from .models import Article, DateArticle, UrlArticle +from .models import Article, DateArticle date_based_info_dict = { diff --git a/tests/view_tests/tests/test_defaults.py b/tests/view_tests/tests/test_defaults.py index d55ed53454..13e56d604b 100644 --- a/tests/view_tests/tests/test_defaults.py +++ b/tests/view_tests/tests/test_defaults.py @@ -1,11 +1,10 @@ from __future__ import unicode_literals -from django.contrib.contenttypes.models import ContentType from django.test import TestCase from django.test.utils import (setup_test_template_loader, restore_template_loaders, override_settings) -from ..models import Author, Article, UrlArticle +from ..models import UrlArticle class DefaultsTests(TestCase): diff --git a/tests/view_tests/tests/test_shortcuts.py b/tests/view_tests/tests/test_shortcuts.py index 678eb36e3d..707df5ee7e 100644 --- a/tests/view_tests/tests/test_shortcuts.py +++ b/tests/view_tests/tests/test_shortcuts.py @@ -1,4 +1,3 @@ -from django.conf import settings from django.test import TestCase from django.test.utils import override_settings