Fixed a number of flake8 errors -- particularly around unused imports and local variables
This commit is contained in:
parent
a9589dd280
commit
2530735d2d
@ -58,7 +58,7 @@ class RemoteUserMiddleware(object):
|
|||||||
auth.BACKEND_SESSION_KEY, ''))
|
auth.BACKEND_SESSION_KEY, ''))
|
||||||
if isinstance(stored_backend, RemoteUserBackend):
|
if isinstance(stored_backend, RemoteUserBackend):
|
||||||
auth.logout(request)
|
auth.logout(request)
|
||||||
except ImproperlyConfigured as e:
|
except ImproperlyConfigured:
|
||||||
# backend failed to load
|
# backend failed to load
|
||||||
auth.logout(request)
|
auth.logout(request)
|
||||||
return
|
return
|
||||||
|
@ -6,7 +6,6 @@ from django.core import validators
|
|||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models.manager import EmptyManager
|
from django.db.models.manager import EmptyManager
|
||||||
from django.utils.crypto import get_random_string
|
from django.utils.crypto import get_random_string
|
||||||
from django.utils.http import urlquote
|
|
||||||
from django.utils import six
|
from django.utils import six
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
from django.utils import timezone
|
from django.utils import timezone
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
from __future__ import unicode_literals
|
from __future__ import unicode_literals
|
||||||
|
|
||||||
from django import forms
|
from django import forms
|
||||||
from django.utils import six
|
|
||||||
from django.utils.translation import ugettext_lazy as _
|
from django.utils.translation import ugettext_lazy as _
|
||||||
|
|
||||||
# While this couples the geographic forms to the GEOS library,
|
# While this couples the geographic forms to the GEOS library,
|
||||||
@ -85,7 +84,7 @@ class GeometryField(forms.Field):
|
|||||||
try:
|
try:
|
||||||
data = self.to_python(data)
|
data = self.to_python(data)
|
||||||
initial = self.to_python(initial)
|
initial = self.to_python(initial)
|
||||||
except ValidationError:
|
except forms.ValidationError:
|
||||||
return True
|
return True
|
||||||
|
|
||||||
# Only do a geographic comparison if both values are available
|
# Only do a geographic comparison if both values are available
|
||||||
|
@ -424,10 +424,6 @@ class FileSessionTests(SessionTestsMixin, unittest.TestCase):
|
|||||||
# Make sure the file backend checks for a good storage dir
|
# Make sure the file backend checks for a good storage dir
|
||||||
self.assertRaises(ImproperlyConfigured, self.backend)
|
self.assertRaises(ImproperlyConfigured, self.backend)
|
||||||
|
|
||||||
def test_invalid_key_backslash(self):
|
|
||||||
# This key should be refused and a new session should be created
|
|
||||||
self.assertTrue(self.backend("a\\b\\c").load())
|
|
||||||
|
|
||||||
def test_invalid_key_backslash(self):
|
def test_invalid_key_backslash(self):
|
||||||
# Ensure we don't allow directory-traversal.
|
# Ensure we don't allow directory-traversal.
|
||||||
# This is tested directly on _key_to_file, as load() will swallow
|
# This is tested directly on _key_to_file, as load() will swallow
|
||||||
|
2
django/core/cache/__init__.py
vendored
2
django/core/cache/__init__.py
vendored
@ -85,7 +85,7 @@ def parse_backend_conf(backend, **kwargs):
|
|||||||
else:
|
else:
|
||||||
try:
|
try:
|
||||||
# Trying to import the given backend, in case it's a dotted path
|
# Trying to import the given backend, in case it's a dotted path
|
||||||
backend_cls = import_by_path(backend)
|
import_by_path(backend)
|
||||||
except ImproperlyConfigured as e:
|
except ImproperlyConfigured as e:
|
||||||
raise InvalidCacheBackendError("Could not find backend '%s': %s" % (
|
raise InvalidCacheBackendError("Could not find backend '%s': %s" % (
|
||||||
backend, e))
|
backend, e))
|
||||||
|
@ -6,7 +6,6 @@ import os
|
|||||||
import warnings
|
import warnings
|
||||||
import zipfile
|
import zipfile
|
||||||
from optparse import make_option
|
from optparse import make_option
|
||||||
import warnings
|
|
||||||
|
|
||||||
from django.conf import settings
|
from django.conf import settings
|
||||||
from django.core import serializers
|
from django.core import serializers
|
||||||
|
@ -9,7 +9,6 @@ from django.conf import settings
|
|||||||
from django.core.management.base import CommandError
|
from django.core.management.base import CommandError
|
||||||
from django.db import models
|
from django.db import models
|
||||||
from django.db.models import get_models
|
from django.db.models import get_models
|
||||||
from django.utils._os import upath
|
|
||||||
|
|
||||||
|
|
||||||
def sql_create(app, style, connection):
|
def sql_create(app, style, connection):
|
||||||
|
@ -1,12 +1,11 @@
|
|||||||
import copy
|
import copy
|
||||||
import datetime
|
|
||||||
from django.utils import six
|
|
||||||
from django.db.backends.schema import BaseDatabaseSchemaEditor
|
from django.db.backends.schema import BaseDatabaseSchemaEditor
|
||||||
from django.db.utils import DatabaseError
|
from django.db.utils import DatabaseError
|
||||||
|
|
||||||
|
|
||||||
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
|
class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
|
||||||
|
|
||||||
sql_create_column = "ALTER TABLE %(table)s ADD %(column)s %(definition)s"
|
sql_create_column = "ALTER TABLE %(table)s ADD %(column)s %(definition)s"
|
||||||
sql_alter_column_type = "MODIFY %(column)s %(type)s"
|
sql_alter_column_type = "MODIFY %(column)s %(type)s"
|
||||||
sql_alter_column_null = "MODIFY %(column)s NULL"
|
sql_alter_column_null = "MODIFY %(column)s NULL"
|
||||||
@ -15,7 +14,7 @@ class DatabaseSchemaEditor(BaseDatabaseSchemaEditor):
|
|||||||
sql_alter_column_no_default = "MODIFY %(column)s DEFAULT NULL"
|
sql_alter_column_no_default = "MODIFY %(column)s DEFAULT NULL"
|
||||||
sql_delete_column = "ALTER TABLE %(table)s DROP COLUMN %(column)s"
|
sql_delete_column = "ALTER TABLE %(table)s DROP COLUMN %(column)s"
|
||||||
sql_delete_table = "DROP TABLE %(table)s CASCADE CONSTRAINTS"
|
sql_delete_table = "DROP TABLE %(table)s CASCADE CONSTRAINTS"
|
||||||
|
|
||||||
def delete_model(self, model):
|
def delete_model(self, model):
|
||||||
# Run superclass action
|
# Run superclass action
|
||||||
super(DatabaseSchemaEditor, self).delete_model(model)
|
super(DatabaseSchemaEditor, self).delete_model(model)
|
||||||
|
@ -1,6 +1,5 @@
|
|||||||
import hashlib
|
import hashlib
|
||||||
import operator
|
import operator
|
||||||
import sys
|
|
||||||
|
|
||||||
from django.db.backends.creation import BaseDatabaseCreation
|
from django.db.backends.creation import BaseDatabaseCreation
|
||||||
from django.db.backends.util import truncate_name
|
from django.db.backends.util import truncate_name
|
||||||
|
@ -289,7 +289,8 @@ class BaseFormSet(object):
|
|||||||
# We loop over every form.errors here rather than short circuiting on the
|
# We loop over every form.errors here rather than short circuiting on the
|
||||||
# first failure to make sure validation gets triggered for every form.
|
# first failure to make sure validation gets triggered for every form.
|
||||||
forms_valid = True
|
forms_valid = True
|
||||||
err = self.errors
|
# This triggers a full clean.
|
||||||
|
self.errors
|
||||||
for i in range(0, self.total_form_count()):
|
for i in range(0, self.total_form_count()):
|
||||||
form = self.forms[i]
|
form = self.forms[i]
|
||||||
if self.can_delete:
|
if self.can_delete:
|
||||||
|
@ -54,7 +54,6 @@ class CsrfTokenNode(Node):
|
|||||||
else:
|
else:
|
||||||
# It's very probable that the token is missing because of
|
# It's very probable that the token is missing because of
|
||||||
# misconfiguration, so we raise a warning
|
# misconfiguration, so we raise a warning
|
||||||
from django.conf import settings
|
|
||||||
if settings.DEBUG:
|
if settings.DEBUG:
|
||||||
warnings.warn("A {% csrf_token %} was used in a template, but the context did not provide the value. This is usually caused by not using RequestContext.")
|
warnings.warn("A {% csrf_token %} was used in a template, but the context did not provide the value. This is usually caused by not using RequestContext.")
|
||||||
return ''
|
return ''
|
||||||
|
@ -91,8 +91,6 @@ class ClientHandler(BaseHandler):
|
|||||||
super(ClientHandler, self).__init__(*args, **kwargs)
|
super(ClientHandler, self).__init__(*args, **kwargs)
|
||||||
|
|
||||||
def __call__(self, environ):
|
def __call__(self, environ):
|
||||||
from django.conf import settings
|
|
||||||
|
|
||||||
# Set up middleware if needed. We couldn't do this earlier, because
|
# Set up middleware if needed. We couldn't do this earlier, because
|
||||||
# settings weren't available.
|
# settings weren't available.
|
||||||
if self._request_middleware is None:
|
if self._request_middleware is None:
|
||||||
|
@ -210,7 +210,6 @@ def urlize(text, trim_url_limit=None, nofollow=False, autoescape=False):
|
|||||||
safe_input = isinstance(text, SafeData)
|
safe_input = isinstance(text, SafeData)
|
||||||
words = word_split_re.split(force_text(text))
|
words = word_split_re.split(force_text(text))
|
||||||
for i, word in enumerate(words):
|
for i, word in enumerate(words):
|
||||||
match = None
|
|
||||||
if '.' in word or '@' in word or ':' in word:
|
if '.' in word or '@' in word or ':' in word:
|
||||||
# Deal with punctuation.
|
# Deal with punctuation.
|
||||||
lead, middle, trail = '', word, ''
|
lead, middle, trail = '', word, ''
|
||||||
|
Loading…
x
Reference in New Issue
Block a user