Skip to content

Commit

Permalink
Fixed a number of lint warnings, particularly around unused variables.
Browse files Browse the repository at this point in the history
  • Loading branch information
alex committed Aug 4, 2013
1 parent ebb3e50 commit 3e0eb2d
Show file tree
Hide file tree
Showing 18 changed files with 39 additions and 52 deletions.
2 changes: 1 addition & 1 deletion django/contrib/admindocs/views.py
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion django/contrib/auth/hashers.py
Expand Up @@ -172,7 +172,7 @@ def _load_library(self):
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:
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/auth/tests/test_context_processors.py
Expand Up @@ -161,7 +161,7 @@ def test_user_attrs(self):
# 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
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/auth/tests/test_forms.py
Expand Up @@ -307,7 +307,7 @@ class Meta(UserChangeForm.Meta):
fields = ('groups',)

# Just check we can create it
form = MyUserForm({})
MyUserForm({})

def test_unsuable_password(self):
user = User.objects.get(username='empty_password')
Expand Down
8 changes: 4 additions & 4 deletions django/contrib/auth/tests/test_views.py
Expand Up @@ -184,7 +184,7 @@ def test_poisoned_http_host_admin_site(self):

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])

Expand Down Expand Up @@ -328,7 +328,7 @@ def fail_login(self, password='password'):
})

def logout(self):
response = self.client.get('/logout/')
self.client.get('/logout/')

def test_password_change_fails_with_invalid_old_password(self):
self.login()
Expand All @@ -350,7 +350,7 @@ def test_password_change_fails_with_mismatched_passwords(self):

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',
Expand Down Expand Up @@ -465,7 +465,7 @@ def test_security_check(self, password='password'):

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)
Expand Down
3 changes: 1 addition & 2 deletions django/contrib/auth/views.py
Expand Up @@ -7,10 +7,9 @@
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
Expand Down
2 changes: 1 addition & 1 deletion django/contrib/formtools/preview.py
Expand Up @@ -39,7 +39,7 @@ def unused_name(self, name):
"""
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 += '_'
Expand Down
3 changes: 1 addition & 2 deletions django/contrib/formtools/tests/wizard/wizardtests/forms.py
Expand Up @@ -9,10 +9,9 @@
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)

Expand Down
2 changes: 1 addition & 1 deletion django/contrib/gis/admin/options.py
Expand Up @@ -55,7 +55,7 @@ def formfield_for_dbfield(self, db_field, **kwargs):
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)
Expand Down
6 changes: 3 additions & 3 deletions django/contrib/gis/db/backends/spatialite/creation.py
@@ -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):
Expand Down Expand Up @@ -53,16 +55,14 @@ def create_test_db(self, verbosity=1, autoclobber=False):
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):
call_command('createcachetable', cache._table, database=self.connection.alias)

# 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

Expand Down
4 changes: 2 additions & 2 deletions django/contrib/gis/gdal/geometries.py
Expand Up @@ -101,7 +101,7 @@ def __init__(self, geom_input, srs=None):
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
Expand Down Expand Up @@ -341,7 +341,7 @@ def wkb(self):
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))

Expand Down
6 changes: 3 additions & 3 deletions django/contrib/gis/gdal/tests/test_envelope.py
Expand Up @@ -22,9 +22,9 @@ def setUp(self):
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))
Expand Down
21 changes: 9 additions & 12 deletions django/contrib/gis/gdal/tests/test_geom.py
Expand Up @@ -25,15 +25,12 @@ def test00a_geomtype(self):
"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)
Expand Down Expand Up @@ -127,7 +124,7 @@ def test01e_json(self):
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)
Expand Down Expand Up @@ -243,15 +240,15 @@ def test07b_closepolygons(self):
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
self.assertEqual(OGRGeometry('POINT(2.5 2.5)'), poly.centroid)

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)
Expand Down
4 changes: 2 additions & 2 deletions django/contrib/gis/gdal/tests/test_srs.py
Expand Up @@ -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."
Expand Down Expand Up @@ -150,7 +150,7 @@ def test12_coordtransform(self):
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."
Expand Down
3 changes: 2 additions & 1 deletion django/contrib/gis/geoip/base.py
Expand Up @@ -18,7 +18,8 @@
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.
Expand Down
1 change: 0 additions & 1 deletion django/contrib/gis/geos/geometry.py
Expand Up @@ -18,7 +18,6 @@
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
Expand Down
18 changes: 5 additions & 13 deletions django/contrib/gis/geos/tests/test_geos.py
Expand Up @@ -124,24 +124,16 @@ def test_hexewkb(self):
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)
Expand All @@ -158,7 +150,7 @@ def test_errors(self):
# 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'))
Expand Down
2 changes: 1 addition & 1 deletion django/core/handlers/wsgi.py
Expand Up @@ -11,7 +11,7 @@
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
Expand Down

0 comments on commit 3e0eb2d

Please sign in to comment.