Permalink
Browse files

Fixed #21302 -- Fixed unused imports and import *.

  • Loading branch information...
1 parent 9f76ea1 commit 36ded01527b690b5df0574492af9cfcc2ea3d1dc @timgraham timgraham committed Oct 18, 2013
Showing with 248 additions and 181 deletions.
  1. +8 −0 django/contrib/admin/__init__.py
  2. +0 −1 django/contrib/auth/models.py
  3. +0 −2 django/contrib/auth/tests/test_decorators.py
  4. +0 −1 django/contrib/auth/tests/test_models.py
  5. +0 −1 django/contrib/auth/tests/test_views.py
  6. +4 −0 django/contrib/formtools/wizard/storage/__init__.py
  7. +13 −4 django/contrib/gis/admin/__init__.py
  8. +4 −4 django/contrib/gis/db/models/__init__.py
  9. +2 −0 django/contrib/gis/db/models/aggregates.py
  10. +4 −0 django/contrib/gis/db/models/sql/__init__.py
  11. +1 −1 django/contrib/gis/db/models/sql/aggregates.py
  12. +3 −3 django/contrib/gis/forms/__init__.py
  13. +1 −1 django/contrib/gis/forms/fields.py
  14. +17 −7 django/contrib/gis/gdal/__init__.py
  15. +3 −0 django/contrib/gis/geoip/__init__.py
  16. +1 −1 django/contrib/gis/geoip/base.py
  17. +2 −0 django/contrib/gis/geometry/backend/geos.py
  18. +12 −1 django/contrib/gis/geos/__init__.py
  19. +2 −0 django/contrib/gis/geos/io.py
  20. +5 −5 django/contrib/gis/geos/prototypes/__init__.py
  21. +5 −0 django/contrib/gis/maps/google/__init__.py
  22. +2 −0 django/contrib/gis/sitemaps/__init__.py
  23. +5 −5 django/contrib/gis/utils/__init__.py
  24. +2 −2 django/contrib/messages/__init__.py
  25. +2 −4 django/core/cache/__init__.py
  26. +0 −1 django/core/cache/backends/db.py
  27. +2 −0 django/core/files/__init__.py
  28. +1 −1 django/core/handlers/wsgi.py
  29. +8 −0 django/core/mail/__init__.py
  30. +1 −1 django/core/management/base.py
  31. +1 −5 django/core/management/commands/squashmigrations.py
  32. +1 −1 django/core/management/validation.py
  33. +1 −2 django/core/servers/basehttp.py
  34. +1 −1 django/core/servers/fastcgi.py
  35. +2 −2 django/db/migrations/__init__.py
  36. +9 −1 django/db/migrations/operations/__init__.py
  37. +18 −13 django/db/models/__init__.py
  38. +4 −0 django/db/models/aggregates.py
  39. +2 −2 django/db/models/base.py
  40. +12 −0 django/db/models/fields/__init__.py
  41. +1 −1 django/db/models/query.py
  42. +2 −2 django/db/models/sql/__init__.py
  43. +0 −1 django/db/utils.py
  44. +1 −1 django/dispatch/__init__.py
  45. +5 −5 django/forms/__init__.py
  46. +3 −1 django/forms/extras/__init__.py
  47. +1 −1 django/forms/fields.py
  48. +1 −1 django/forms/widgets.py
  49. +15 −4 django/http/__init__.py
  50. +1 −1 django/middleware/doc.py
  51. +5 −5 django/template/__init__.py
  52. +1 −1 django/template/base.py
  53. +6 −0 django/test/__init__.py
  54. +1 −1 django/test/testcases.py
  55. +1 −1 django/utils/autoreload.py
  56. +2 −3 django/utils/log.py
  57. +1 −1 django/utils/text.py
  58. +8 −0 django/views/generic/__init__.py
  59. +2 −2 setup.cfg
  60. +1 −2 tests/admin_changelist/admin.py
  61. +0 −1 tests/admin_custom_urls/tests.py
  62. +1 −1 tests/admin_scripts/broken_app/models.py
  63. +0 −2 tests/admin_scripts/complex_app/models/bar.py
  64. +2 −0 tests/admin_scripts/simple_app/models.py
  65. +1 −1 tests/admin_validation/tests.py
  66. +0 −1 tests/admin_views/tests.py
  67. +0 −2 tests/app_loading/tests.py
  68. +1 −1 tests/context_processors/urls.py
  69. +1 −1 tests/delete/tests.py
  70. +0 −1 tests/deprecation/tests.py
  71. +0 −1 tests/file_storage/tests.py
  72. +0 −2 tests/files/tests.py
  73. +0 −1 tests/forms_tests/urls.py
  74. +0 −1 tests/generic_inline_admin/tests.py
  75. +5 −5 tests/i18n/tests.py
  76. +0 −3 tests/logging_tests/tests.py
  77. +0 −1 tests/managers_regress/tests.py
  78. +0 −1 tests/many_to_one_regress/tests.py
  79. +1 −1 tests/middleware/tests.py
  80. +1 −1 tests/migrations/faulty_migrations/import_error/__init__.py
  81. +0 −1 tests/migrations/test_executor.py
  82. +0 −1 tests/migrations/test_optimizer.py
  83. +1 −1 tests/model_forms/models.py
  84. +2 −0 tests/model_package/models/__init__.py
  85. +0 −1 tests/modeladmin/tests.py
  86. +1 −2 tests/proxy_models/tests.py
  87. +0 −1 tests/queryset_pickle/tests.py
  88. +1 −2 tests/requests/tests.py
  89. +0 −1 tests/select_for_update/tests.py
  90. +1 −1 tests/select_related_regress/tests.py
  91. +0 −1 tests/serializers/tests.py
  92. +0 −1 tests/serializers_regress/tests.py
  93. 0 tests/settings_tests/models.py
  94. +1 −2 tests/settings_tests/tests.py
  95. +0 −1 tests/tablespaces/tests.py
  96. +1 −1 tests/template_tests/templatetags/broken_tag.py
  97. +1 −1 tests/template_tests/templatetags/subpackage/echo_invalid.py
  98. +0 −2 tests/test_client/tests.py
  99. +0 −1 tests/test_runner/test_discover_runner.py
  100. +0 −1 tests/test_runner/tests.py
  101. +0 −3 tests/test_runner_deprecation_app/models.py
  102. +0 −3 tests/timezones/tests.py
  103. +1 −1 tests/timezones/urls.py
  104. +1 −1 tests/urlpatterns_reverse/erroneous_views_module.py
  105. +0 −1 tests/urlpatterns_reverse/tests.py
  106. +1 −1 tests/urlpatterns_reverse/views.py
  107. +0 −2 tests/utils_tests/test_crypto.py
  108. +1 −1 tests/utils_tests/test_module/bad_module.py
  109. +1 −1 tests/utils_tests/test_module_loading.py
  110. +0 −1 tests/utils_tests/test_safestring.py
  111. +0 −2 tests/utils_tests/test_text.py
  112. +0 −1 tests/utils_tests/test_timezone.py
  113. +0 −1 tests/version/tests.py
  114. +1 −2 tests/view_tests/generic_urls.py
  115. +1 −2 tests/view_tests/tests/test_defaults.py
  116. +0 −1 tests/view_tests/tests/test_shortcuts.py
@@ -10,6 +10,14 @@
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)
@@ -1,5 +1,4 @@
from __future__ import unicode_literals
-import re
from django.core.mail import send_mail
from django.core import validators
@@ -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
@@ -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
@@ -21,7 +21,6 @@
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
@@ -5,6 +5,10 @@
from django.contrib.formtools.wizard.storage.exceptions import (
MissingStorage, NoFileStorageConfigured)
+__all__ = [
+ "BaseStorage", "MissingStorage", "NoFileStorageConfigured", "get_storage",
+]
+
def get_storage(path, *args, **kwargs):
try:
@@ -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
@@ -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)
@@ -1,5 +1,7 @@
from django.db.models import Aggregate
+__all__ = ['Collect', 'Extent', 'Extent3D', 'MakeLine', 'Union']
+
class Collect(Aggregate):
name = 'Collect'
@@ -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',
+]
@@ -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
@@ -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
@@ -5,7 +5,7 @@
# 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
@@ -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
@@ -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
@@ -5,7 +5,7 @@
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)
@@ -1,2 +1,4 @@
from django.contrib.gis.geos import (
GEOSGeometry as Geometry, GEOSException as GeometryException)
+
+__all__ = ['Geometry', 'GeometryException']
@@ -3,9 +3,12 @@
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 @@
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',
+ ]
@@ -6,6 +6,8 @@
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):
@@ -5,26 +5,26 @@
"""
# 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,
get_dims, get_num_coords, get_num_geoms,
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
@@ -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',
+]
@@ -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']
@@ -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
@@ -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
@@ -14,19 +14,17 @@
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'
@@ -1,6 +1,5 @@
"Database cache backend."
import base64
-import time
from datetime import datetime
try:
@@ -1 +1,3 @@
from django.core.files.base import File
+
+__all__ = ['File']
@@ -17,7 +17,7 @@
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')
@@ -17,6 +17,14 @@
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.
@@ -265,7 +265,7 @@ def execute(self, *args, **options):
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:
Oops, something went wrong.

0 comments on commit 36ded01

Please sign in to comment.