Fixed a number of lint warnings, particularly around unused variables.

This commit is contained in:
Alex Gaynor 2013-08-04 09:17:10 -07:00
parent ebb3e50243
commit 3e0eb2d788
18 changed files with 39 additions and 52 deletions

View File

@ -319,7 +319,7 @@ def load_all_installed_template_libraries():
libraries = []
for library_name in libraries:
try:
lib = template.get_library(library_name)
template.get_library(library_name)
except template.InvalidTemplateLibrary:
pass

View File

@ -172,7 +172,7 @@ class BasePasswordHasher(object):
if isinstance(self.library, (tuple, list)):
name, mod_path = self.library
else:
name = mod_path = self.library
mod_path = self.library
try:
module = importlib.import_module(mod_path)
except ImportError as e:

View File

@ -161,7 +161,7 @@ class AuthContextProcessorTests(TestCase):
# Exception RuntimeError: 'maximum recursion depth exceeded while
# calling a Python object' in <type 'exceptions.AttributeError'>
# ignored"
query = Q(user=response.context['user']) & Q(someflag=True)
Q(user=response.context['user']) & Q(someflag=True)
# Tests for user equality. This is hard because User defines
# equality in a non-duck-typing way

View File

@ -307,7 +307,7 @@ class UserChangeFormTest(TestCase):
fields = ('groups',)
# Just check we can create it
form = MyUserForm({})
MyUserForm({})
def test_unsuable_password(self):
user = User.objects.get(username='empty_password')

View File

@ -184,7 +184,7 @@ class PasswordResetTest(AuthViewsTestCase):
def _test_confirm_start(self):
# Start by creating the email
response = self.client.post('/password_reset/', {'email': 'staffmember@example.com'})
self.client.post('/password_reset/', {'email': 'staffmember@example.com'})
self.assertEqual(len(mail.outbox), 1)
return self._read_signup_email(mail.outbox[0])
@ -328,7 +328,7 @@ class ChangePasswordTest(AuthViewsTestCase):
})
def logout(self):
response = self.client.get('/logout/')
self.client.get('/logout/')
def test_password_change_fails_with_invalid_old_password(self):
self.login()
@ -350,7 +350,7 @@ class ChangePasswordTest(AuthViewsTestCase):
def test_password_change_succeeds(self):
self.login()
response = self.client.post('/password_change/', {
self.client.post('/password_change/', {
'old_password': 'password',
'new_password1': 'password1',
'new_password2': 'password1',
@ -465,7 +465,7 @@ class LoginTest(AuthViewsTestCase):
def test_login_form_contains_request(self):
# 15198
response = self.client.post('/custom_requestauth_login/', {
self.client.post('/custom_requestauth_login/', {
'username': 'testclient',
'password': 'password',
}, follow=True)

View File

@ -7,10 +7,9 @@ from django.conf import settings
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect, QueryDict
from django.template.response import TemplateResponse
from django.utils.http import base36_to_int, is_safe_url, urlsafe_base64_decode, urlsafe_base64_encode
from django.utils.http import is_safe_url, urlsafe_base64_decode
from django.utils.translation import ugettext as _
from django.shortcuts import resolve_url
from django.utils.encoding import force_bytes, force_text
from django.views.decorators.debug import sensitive_post_parameters
from django.views.decorators.cache import never_cache
from django.views.decorators.csrf import csrf_protect

View File

@ -39,7 +39,7 @@ class FormPreview(object):
"""
while 1:
try:
f = self.form.base_fields[name]
self.form.base_fields[name]
except KeyError:
break # This field name isn't being used by the form.
name += '_'

View File

@ -9,10 +9,9 @@ from django.forms.models import modelformset_factory
from django.http import HttpResponse
from django.template import Template, Context
from django.contrib.auth.models import User
from django.contrib.formtools.wizard.views import WizardView
temp_storage_location = tempfile.mkdtemp(dir=os.environ.get('DJANGO_TEST_TEMP_DIR'))
temp_storage = FileSystemStorage(location=temp_storage_location)

View File

@ -55,7 +55,7 @@ class GeoModelAdmin(ModelAdmin):
3D editing).
"""
if isinstance(db_field, models.GeometryField) and db_field.dim < 3:
request = kwargs.pop('request', None)
kwargs.pop('request', None)
# Setting the widget with the newly defined widget.
kwargs['widget'] = self.get_map_widget(db_field)
return db_field.formfield(**kwargs)

View File

@ -1,10 +1,12 @@
import os
from django.conf import settings
from django.core.cache import get_cache
from django.core.cache.backends.db import BaseDatabaseCache
from django.core.exceptions import ImproperlyConfigured
from django.db.backends.sqlite3.creation import DatabaseCreation
class SpatiaLiteCreation(DatabaseCreation):
def create_test_db(self, verbosity=1, autoclobber=False):
@ -53,8 +55,6 @@ class SpatiaLiteCreation(DatabaseCreation):
interactive=False,
database=self.connection.alias)
from django.core.cache import get_cache
from django.core.cache.backends.db import BaseDatabaseCache
for cache_alias in settings.CACHES:
cache = get_cache(cache_alias)
if isinstance(cache, BaseDatabaseCache):
@ -62,7 +62,7 @@ class SpatiaLiteCreation(DatabaseCreation):
# Get a cursor (even though we don't need one yet). This has
# the side effect of initializing the test database.
cursor = self.connection.cursor()
self.connection.cursor()
return test_database_name

View File

@ -101,7 +101,7 @@ class OGRGeometry(GDALBase):
else:
# Seeing if the input is a valid short-hand string
# (e.g., 'Point', 'POLYGON').
ogr_t = OGRGeomType(geom_input)
OGRGeomType(geom_input)
g = capi.create_geom(OGRGeomType(geom_input).num)
elif isinstance(geom_input, memoryview):
# WKB was passed in
@ -341,7 +341,7 @@ class OGRGeometry(GDALBase):
sz = self.wkb_size
# Creating the unsigned character buffer, and passing it in by reference.
buf = (c_ubyte * sz)()
wkb = capi.to_wkb(self.ptr, byteorder, byref(buf))
capi.to_wkb(self.ptr, byteorder, byref(buf))
# Returning a buffer of the string at the pointer.
return memoryview(string_at(buf, sz))

View File

@ -22,9 +22,9 @@ class EnvelopeTest(unittest.TestCase):
def test01_init(self):
"Testing Envelope initilization."
e1 = Envelope((0, 0, 5, 5))
e2 = Envelope(0, 0, 5, 5)
e3 = Envelope(0, '0', '5', 5) # Thanks to ww for this
e4 = Envelope(e1._envelope)
Envelope(0, 0, 5, 5)
Envelope(0, '0', '5', 5) # Thanks to ww for this
Envelope(e1._envelope)
self.assertRaises(OGRException, Envelope, (5, 5, 0, 0))
self.assertRaises(OGRException, Envelope, 5, 5, 0, 0)
self.assertRaises(OGRException, Envelope, (0, 0, 5, 5, 3))

View File

@ -25,15 +25,12 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
"Testing OGRGeomType object."
# OGRGeomType should initialize on all these inputs.
try:
g = OGRGeomType(1)
g = OGRGeomType(7)
g = OGRGeomType('point')
g = OGRGeomType('GeometrycollectioN')
g = OGRGeomType('LINearrING')
g = OGRGeomType('Unknown')
except:
self.fail('Could not create an OGRGeomType object!')
OGRGeomType(1)
OGRGeomType(7)
OGRGeomType('point')
OGRGeomType('GeometrycollectioN')
OGRGeomType('LINearrING')
OGRGeomType('Unknown')
# Should throw TypeError on this input
self.assertRaises(OGRException, OGRGeomType, 23)
@ -127,7 +124,7 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
def test02_points(self):
"Testing Point objects."
prev = OGRGeometry('POINT(0 0)')
OGRGeometry('POINT(0 0)')
for p in self.geometries.points:
if not hasattr(p, 'z'): # No 3D
pnt = OGRGeometry(p.wkt)
@ -243,7 +240,7 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
poly = OGRGeometry('POLYGON((0 0, 5 0, 5 5, 0 5), (1 1, 2 1, 2 2, 2 1))')
self.assertEqual(8, poly.point_count)
with self.assertRaises(OGRException):
_ = poly.centroid
poly.centroid
poly.close_rings()
self.assertEqual(10, poly.point_count) # Two closing points should've been added
@ -251,7 +248,7 @@ class OGRGeomTest(unittest.TestCase, TestDataMixin):
def test08_multipolygons(self):
"Testing MultiPolygon objects."
prev = OGRGeometry('POINT(0 0)')
OGRGeometry('POINT(0 0)')
for mp in self.geometries.multipolygons:
mpoly = OGRGeometry(mp.wkt)
self.assertEqual(6, mpoly.geom_type)

View File

@ -58,7 +58,7 @@ class SpatialRefTest(unittest.TestCase):
def test01_wkt(self):
"Testing initialization on valid OGC WKT."
for s in srlist:
srs = SpatialReference(s.wkt)
SpatialReference(s.wkt)
def test02_bad_wkt(self):
"Testing initialization on invalid WKT."
@ -150,7 +150,7 @@ class SpatialRefTest(unittest.TestCase):
target = SpatialReference('WGS84')
for s in srlist:
if s.proj:
ct = CoordTransform(SpatialReference(s.wkt), target)
CoordTransform(SpatialReference(s.wkt), target)
def test13_attr_value(self):
"Testing the attr_value() method."

View File

@ -18,7 +18,8 @@ free_regex = re.compile(r'^GEO-\d{3}FREE')
lite_regex = re.compile(r'^GEO-\d{3}LITE')
#### GeoIP classes ####
class GeoIPException(Exception): pass
class GeoIPException(Exception):
pass
class GeoIP(object):
# The flags for GeoIP memory caching.

View File

@ -18,7 +18,6 @@ from django.contrib.gis.geos.base import GEOSBase, gdal
from django.contrib.gis.geos.coordseq import GEOSCoordSeq
from django.contrib.gis.geos.error import GEOSException, GEOSIndexError
from django.contrib.gis.geos.libgeos import GEOM_PTR, GEOS_PREPARE
from django.contrib.gis.geos.mutable_list import ListMixin
# All other functions in this module come from the ctypes
# prototypes module -- which handles all interaction with

View File

@ -124,24 +124,16 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
self.assertEqual(hexewkb_3d, pnt_3d.hexewkb)
self.assertEqual(True, GEOSGeometry(hexewkb_3d).hasz)
else:
try:
hexewkb = pnt_3d.hexewkb
except GEOSException:
pass
else:
self.fail('Should have raised GEOSException.')
with self.assertRaises(GEOSException):
pnt_3d.hexewkb
# Same for EWKB.
self.assertEqual(memoryview(a2b_hex(hexewkb_2d)), pnt_2d.ewkb)
if GEOS_PREPARE:
self.assertEqual(memoryview(a2b_hex(hexewkb_3d)), pnt_3d.ewkb)
else:
try:
ewkb = pnt_3d.ewkb
except GEOSException:
pass
else:
self.fail('Should have raised GEOSException')
with self.assertRaises(GEOSException):
pnt_3d.ewkb
# Redundant sanity check.
self.assertEqual(4326, GEOSGeometry(hexewkb_2d).srid)
@ -158,7 +150,7 @@ class GEOSTest(unittest.TestCase, TestDataMixin):
# string-based
for err in self.geometries.errors:
with self.assertRaises((GEOSException, ValueError)):
_ = fromstr(err.wkt)
fromstr(err.wkt)
# Bad WKB
self.assertRaises(GEOSException, GEOSGeometry, memoryview(b'0'))

View File

@ -11,7 +11,7 @@ from django.core import signals
from django.core.handlers import base
from django.core.urlresolvers import set_script_prefix
from django.utils import datastructures
from django.utils.encoding import force_str, force_text, iri_to_uri
from django.utils.encoding import force_str
# For backwards compatibility -- lots of code uses this in the wild!
from django.http.response import REASON_PHRASES as STATUS_CODE_TEXT