From a926046ba633ac38d3306b6bc10677a670929786 Mon Sep 17 00:00:00 2001 From: Jacob Kaplan-Moss Date: Fri, 21 Jul 2006 20:39:17 +0000 Subject: [PATCH] Second half of little cleanup tweaks suggested by pyflakes. git-svn-id: http://code.djangoproject.com/svn/django/trunk@3414 bcc190cf-cafb-0310-a4f2-bffc1f526a37 --- django/core/handlers/modpython.py | 1 - django/core/management.py | 1 - django/db/models/base.py | 3 +-- django/db/models/fields/__init__.py | 2 +- django/db/models/fields/related.py | 2 +- django/db/models/manager.py | 3 --- django/db/models/manipulators.py | 4 ++-- django/middleware/cache.py | 1 - django/middleware/transaction.py | 1 - django/template/__init__.py | 2 +- django/template/loader.py | 2 +- django/template/loader_tags.py | 2 +- django/templatetags/i18n.py | 7 +++---- django/utils/termcolors.py | 2 -- django/views/debug.py | 2 -- django/views/decorators/cache.py | 1 - django/views/generic/create_update.py | 3 +-- django/views/static.py | 1 - 18 files changed, 12 insertions(+), 28 deletions(-) diff --git a/django/core/handlers/modpython.py b/django/core/handlers/modpython.py index 8da8ca41d1..07c98e3b59 100644 --- a/django/core/handlers/modpython.py +++ b/django/core/handlers/modpython.py @@ -148,7 +148,6 @@ class ModPythonHandler(BaseHandler): def populate_apache_request(http_response, mod_python_req): "Populates the mod_python request object with an HttpResponse" - from django.conf import settings mod_python_req.content_type = http_response['Content-Type'] for key, value in http_response.headers.items(): if key != 'Content-Type': diff --git a/django/core/management.py b/django/core/management.py index ecd1d1a68d..8e1c3d624d 100644 --- a/django/core/management.py +++ b/django/core/management.py @@ -692,7 +692,6 @@ startapp.args = "[appname]" def inspectdb(): "Generator that introspects the tables in the given database name and returns a Django model, one line at a time." from django.db import connection, get_introspection_module - from django.conf import settings import keyword introspection_module = get_introspection_module() diff --git a/django/db/models/base.py b/django/db/models/base.py index c89033c491..305ed9b924 100644 --- a/django/db/models/base.py +++ b/django/db/models/base.py @@ -4,8 +4,7 @@ from django.core import validators from django.core.exceptions import ObjectDoesNotExist from django.db.models.fields import AutoField, ImageField, FieldDoesNotExist from django.db.models.fields.related import OneToOneRel, ManyToOneRel -from django.db.models.related import RelatedObject -from django.db.models.query import orderlist2sql, delete_objects +from django.db.models.query import delete_objects from django.db.models.options import Options, AdminOptions from django.db import connection, backend, transaction from django.db.models import signals diff --git a/django/db/models/fields/__init__.py b/django/db/models/fields/__init__.py index e10b9beedc..6fba7f7876 100644 --- a/django/db/models/fields/__init__.py +++ b/django/db/models/fields/__init__.py @@ -4,7 +4,7 @@ from django.conf import settings from django.core import validators from django import forms from django.core.exceptions import ObjectDoesNotExist -from django.utils.functional import curry, lazy +from django.utils.functional import curry from django.utils.text import capfirst from django.utils.translation import gettext, gettext_lazy import datetime, os, time diff --git a/django/db/models/fields/related.py b/django/db/models/fields/related.py index 0aff64b11c..5dd02bccf2 100644 --- a/django/db/models/fields/related.py +++ b/django/db/models/fields/related.py @@ -1,4 +1,4 @@ -from django.db import backend, connection, transaction +from django.db import backend, transaction from django.db.models import signals, get_model from django.db.models.fields import AutoField, Field, IntegerField, get_ul_class from django.db.models.related import RelatedObject diff --git a/django/db/models/manager.py b/django/db/models/manager.py index 46a1710c1c..6005874516 100644 --- a/django/db/models/manager.py +++ b/django/db/models/manager.py @@ -1,10 +1,7 @@ -from django.utils.functional import curry -from django.db import backend, connection from django.db.models.query import QuerySet from django.dispatch import dispatcher from django.db.models import signals from django.db.models.fields import FieldDoesNotExist -from django.utils.datastructures import SortedDict # Size of each "chunk" for get_iterator calls. # Larger values are slightly faster at the expense of more storage space. diff --git a/django/db/models/manipulators.py b/django/db/models/manipulators.py index 454c318e5d..69e13dd160 100644 --- a/django/db/models/manipulators.py +++ b/django/db/models/manipulators.py @@ -5,7 +5,7 @@ from django.db.models.fields import FileField, AutoField from django.dispatch import dispatcher from django.db.models import signals from django.utils.functional import curry -from django.utils.datastructures import DotExpandedDict, MultiValueDict +from django.utils.datastructures import DotExpandedDict from django.utils.text import capfirst import types @@ -76,7 +76,7 @@ class AutomaticManipulator(forms.Manipulator): # Add field for ordering. if self.change and self.opts.get_ordered_objects(): - self.fields.append(formfields.CommaSeparatedIntegerField(field_name="order_")) + self.fields.append(forms.CommaSeparatedIntegerField(field_name="order_")) def save(self, new_data): # TODO: big cleanup when core fields go -> use recursive manipulators. diff --git a/django/middleware/cache.py b/django/middleware/cache.py index fc649d9c34..08e77d1375 100644 --- a/django/middleware/cache.py +++ b/django/middleware/cache.py @@ -1,7 +1,6 @@ from django.conf import settings from django.core.cache import cache from django.utils.cache import get_cache_key, learn_cache_key, patch_response_headers -from django.http import HttpResponseNotModified class CacheMiddleware(object): """ diff --git a/django/middleware/transaction.py b/django/middleware/transaction.py index 4128e012f2..96b1538d9d 100644 --- a/django/middleware/transaction.py +++ b/django/middleware/transaction.py @@ -1,4 +1,3 @@ -from django.conf import settings from django.db import transaction class TransactionMiddleware(object): diff --git a/django/template/__init__.py b/django/template/__init__.py index ea82a4697f..a4c282f2ff 100644 --- a/django/template/__init__.py +++ b/django/template/__init__.py @@ -817,7 +817,7 @@ class Library(object): self.filters[name] = filter_func return filter_func else: - raise InvalidTemplateLibrary, "Unsupported arguments to Library.filter: (%r, %r, %r)", (name, compile_function, has_arg) + raise InvalidTemplateLibrary, "Unsupported arguments to Library.filter: (%r, %r)", (name, filter_func) def filter_function(self, func): self.filters[func.__name__] = func diff --git a/django/template/loader.py b/django/template/loader.py index ebca582ef9..60f24554f1 100644 --- a/django/template/loader.py +++ b/django/template/loader.py @@ -21,7 +21,7 @@ # installed, because pkg_resources is necessary to read eggs. from django.core.exceptions import ImproperlyConfigured -from django.template import Origin, StringOrigin, Template, Context, TemplateDoesNotExist, add_to_builtins +from django.template import Origin, Template, Context, TemplateDoesNotExist, add_to_builtins from django.conf import settings template_source_loaders = None diff --git a/django/template/loader_tags.py b/django/template/loader_tags.py index e0d9a70a98..a8e76a1844 100644 --- a/django/template/loader_tags.py +++ b/django/template/loader_tags.py @@ -1,5 +1,5 @@ from django.template import TemplateSyntaxError, TemplateDoesNotExist, resolve_variable -from django.template import Library, Context, Node +from django.template import Library, Node from django.template.loader import get_template, get_template_from_string, find_template_source from django.conf import settings diff --git a/django/templatetags/i18n.py b/django/templatetags/i18n.py index 6718a0fbac..bf6497f9aa 100644 --- a/django/templatetags/i18n.py +++ b/django/templatetags/i18n.py @@ -1,8 +1,7 @@ -from django.template import Node, NodeList, Template, Context, resolve_variable +from django.template import Node, resolve_variable from django.template import TemplateSyntaxError, TokenParser, Library -from django.template import TOKEN_BLOCK, TOKEN_TEXT, TOKEN_VAR +from django.template import TOKEN_TEXT, TOKEN_VAR from django.utils import translation -import re, sys register = Library() @@ -228,7 +227,7 @@ def do_block_translate(parser, token): break if countervar and counter: if token.contents.strip() != 'plural': - raise TemplateSyntaxError, "'blocktrans' doesn't allow other block tags inside it" % tag + raise TemplateSyntaxError, "'blocktrans' doesn't allow other block tags inside it" while parser.tokens: token = parser.next_token() if token.token_type in (TOKEN_VAR, TOKEN_TEXT): diff --git a/django/utils/termcolors.py b/django/utils/termcolors.py index 3ce1d5bb6b..17a600f899 100644 --- a/django/utils/termcolors.py +++ b/django/utils/termcolors.py @@ -2,8 +2,6 @@ termcolors.py """ -import types - color_names = ('black', 'red', 'green', 'yellow', 'blue', 'magenta', 'cyan', 'white') foreground = dict([(color_names[x], '3%s' % x) for x in range(8)]) background = dict([(color_names[x], '4%s' % x) for x in range(8)]) diff --git a/django/views/debug.py b/django/views/debug.py index ffcb284a86..6934360afd 100644 --- a/django/views/debug.py +++ b/django/views/debug.py @@ -3,8 +3,6 @@ from django.template import Template, Context, TemplateDoesNotExist from django.utils.html import escape from django.http import HttpResponseServerError, HttpResponseNotFound import os, re -from itertools import count, izip -from os.path import dirname, join as pathjoin HIDDEN_SETTINGS = re.compile('SECRET|PASSWORD') diff --git a/django/views/decorators/cache.py b/django/views/decorators/cache.py index 5467ff501e..b04cc2340b 100644 --- a/django/views/decorators/cache.py +++ b/django/views/decorators/cache.py @@ -10,7 +10,6 @@ example, as that is unique across a Django project. Additionally, all headers from the response's Vary header will be taken into account on caching -- just like the middleware does. """ -import re from django.utils.decorators import decorator_from_middleware from django.utils.cache import patch_cache_control, add_never_cache_headers diff --git a/django/views/generic/create_update.py b/django/views/generic/create_update.py index a5b852c8d6..67475f01ca 100644 --- a/django/views/generic/create_update.py +++ b/django/views/generic/create_update.py @@ -4,8 +4,7 @@ from django import forms from django.db.models import FileField from django.contrib.auth.views import redirect_to_login from django.template import RequestContext -from django.core.paginator import ObjectPaginator, InvalidPage -from django.http import Http404, HttpResponse, HttpResponseRedirect +from django.http import Http404, HttpResponseRedirect from django.core.exceptions import ObjectDoesNotExist, ImproperlyConfigured def create_object(request, model, template_name=None, diff --git a/django/views/static.py b/django/views/static.py index 072a01671e..ac323944d0 100644 --- a/django/views/static.py +++ b/django/views/static.py @@ -1,5 +1,4 @@ from django.template import loader -from django.core.exceptions import ImproperlyConfigured from django.http import Http404, HttpResponse, HttpResponseRedirect, HttpResponseNotModified from django.template import Template, Context, TemplateDoesNotExist import mimetypes