Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

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

  • Loading branch information...
commit 3e0eb2d7885fdccabcc4b97e5c57e68bbd5d7978 1 parent ebb3e50
Alex Gaynor alex authored
2  django/contrib/admindocs/views.py
View
@@ -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
2  django/contrib/auth/hashers.py
View
@@ -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:
2  django/contrib/auth/tests/test_context_processors.py
View
@@ -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
2  django/contrib/auth/tests/test_forms.py
View
@@ -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')
8 django/contrib/auth/tests/test_views.py
View
@@ -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])
@@ -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()
@@ -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',
@@ -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)
3  django/contrib/auth/views.py
View
@@ -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
2  django/contrib/formtools/preview.py
View
@@ -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 += '_'
3  django/contrib/formtools/tests/wizard/wizardtests/forms.py
View
@@ -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)
2  django/contrib/gis/admin/options.py
View
@@ -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)
6 django/contrib/gis/db/backends/spatialite/creation.py
View
@@ -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 @@ 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):
@@ -62,7 +62,7 @@ def create_test_db(self, verbosity=1, autoclobber=False):
# 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
4 django/contrib/gis/gdal/geometries.py
View
@@ -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
@@ -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))
6 django/contrib/gis/gdal/tests/test_envelope.py
View
@@ -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))
21 django/contrib/gis/gdal/tests/test_geom.py
View
@@ -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)
@@ -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)
@@ -243,7 +240,7 @@ 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
@@ -251,7 +248,7 @@ def test07b_closepolygons(self):
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)
4 django/contrib/gis/gdal/tests/test_srs.py
View
@@ -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 @@ 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."
3  django/contrib/gis/geoip/base.py
View
@@ -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.
1  django/contrib/gis/geos/geometry.py
View
@@ -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
18 django/contrib/gis/geos/tests/test_geos.py
View
@@ -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)
@@ -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'))
2  django/core/handlers/wsgi.py
View
@@ -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
Please sign in to comment.
Something went wrong with that request. Please try again.