Skip to content

Commit

Permalink
Fixed #21302 -- Fixed unused imports and import *.
Browse files Browse the repository at this point in the history
  • Loading branch information
timgraham committed Nov 2, 2013
1 parent 9f76ea1 commit 36ded01
Show file tree
Hide file tree
Showing 116 changed files with 248 additions and 181 deletions.
8 changes: 8 additions & 0 deletions django/contrib/admin/__init__.py
Expand Up @@ -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 change: 0 additions & 1 deletion 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
Expand Down
2 changes: 0 additions & 2 deletions 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
Expand Down
1 change: 0 additions & 1 deletion 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
Expand Down
1 change: 0 additions & 1 deletion django/contrib/auth/tests/test_views.py
Expand Up @@ -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

Expand Down
4 changes: 4 additions & 0 deletions django/contrib/formtools/wizard/storage/__init__.py
Expand Up @@ -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:
Expand Down
17 changes: 13 additions & 4 deletions 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
8 changes: 4 additions & 4 deletions 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)
2 changes: 2 additions & 0 deletions 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'
Expand Down
4 changes: 4 additions & 0 deletions 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',
]
2 changes: 1 addition & 1 deletion 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


Expand Down
6 changes: 3 additions & 3 deletions 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
2 changes: 1 addition & 1 deletion django/contrib/gis/forms/fields.py
Expand Up @@ -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


Expand Down
24 changes: 17 additions & 7 deletions django/contrib/gis/gdal/__init__.py
Expand Up @@ -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
3 changes: 3 additions & 0 deletions django/contrib/gis/geoip/__init__.py
Expand Up @@ -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
2 changes: 1 addition & 1 deletion django/contrib/gis/geoip/base.py
Expand Up @@ -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)
Expand Down
2 changes: 2 additions & 0 deletions 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']
13 changes: 12 additions & 1 deletion django/contrib/gis/geos/__init__.py
Expand Up @@ -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

Expand All @@ -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',
]
2 changes: 2 additions & 0 deletions django/contrib/gis/geos/io.py
Expand Up @@ -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):
Expand Down
10 changes: 5 additions & 5 deletions django/contrib/gis/geos/prototypes/__init__.py
Expand Up @@ -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
5 changes: 5 additions & 0 deletions django/contrib/gis/maps/google/__init__.py
Expand Up @@ -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',
]
2 changes: 2 additions & 0 deletions 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']
10 changes: 5 additions & 5 deletions django/contrib/gis/utils/__init__.py
Expand Up @@ -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
4 changes: 2 additions & 2 deletions 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
6 changes: 2 additions & 4 deletions django/core/cache/__init__.py
Expand Up @@ -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'
Expand Down
1 change: 0 additions & 1 deletion django/core/cache/backends/db.py
@@ -1,6 +1,5 @@
"Database cache backend."
import base64
import time
from datetime import datetime

try:
Expand Down
2 changes: 2 additions & 0 deletions django/core/files/__init__.py
@@ -1 +1,3 @@
from django.core.files.base import File

__all__ = ['File']
2 changes: 1 addition & 1 deletion django/core/handlers/wsgi.py
Expand Up @@ -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')

Expand Down
8 changes: 8 additions & 0 deletions django/core/mail/__init__.py
Expand Up @@ -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.
Expand Down
2 changes: 1 addition & 1 deletion django/core/management/base.py
Expand Up @@ -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:
Expand Down

0 comments on commit 36ded01

Please sign in to comment.