← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/pyflakes-cleanups into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/pyflakes-cleanups into lp:launchpad.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/pyflakes-cleanups/+merge/102202

== Summary ==

This branch cleans up a slew of pyflakes warnings that were annoying me (due to pyflakes.vim) when editing code elsewhere.  The warnings I addressed fall into the following categories:

 * Unused imports.  I avoided those in files (particularly doctest bootstrap code) that were doing specialised things like re-exporting symbols for use elsewhere or importing modules for their side-effects, as well as the usual false positives due to ImportError handling, but I think most of the cases I touched were pretty obvious.
 * Exports from __all__ that didn't actually exist.  Mostly no-brainers to remove, but in some cases I fixed spelling instead.
 * Variables assigned but never used.  Sometimes these indicated dead lines of code which I removed.  Sometimes I removed the pointless assignments.  In the case of tests I generally left these alone since they might serve as useful documentation.
 * Use of undefined names.  There were a couple of these which amounted to crashes on error handling paths (lib/lp/scripts/utilities/killservice.py
 * Duplicate method definitions.  Just one case of this that I spotted, in lib/lp/services/librarianserver/tests/test_storage.py, which looked like dead code.
 * Name shadowing.  One case I spotted in lib/lp/services/openid/tests/test_baseopenidstore.py, for which it seems clearest to rename one of the variables.

This should amount to >100 lines of code removed with no downside, I think.
-- 
https://code.launchpad.net/~cjwatson/launchpad/pyflakes-cleanups/+merge/102202
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/pyflakes-cleanups into lp:launchpad.
=== modified file 'cronscripts/process-job-source.py'
--- cronscripts/process-job-source.py	2012-01-01 03:14:54 +0000
+++ cronscripts/process-job-source.py	2012-04-16 23:21:20 +0000
@@ -13,7 +13,6 @@
 
 from twisted.python import log
 
-from lp.services.config import config
 from lp.services.job import runner
 from lp.services.job.runner import JobCronScript
 

=== modified file 'lib/lp/archivepublisher/ddtp_tarball.py'
--- lib/lp/archivepublisher/ddtp_tarball.py	2010-08-20 20:31:18 +0000
+++ lib/lp/archivepublisher/ddtp_tarball.py	2012-04-16 23:21:20 +0000
@@ -15,8 +15,6 @@
 __all__ = ['process_ddtp_tarball']
 
 import os
-import stat
-import tarfile
 
 from lp.archivepublisher.customupload import CustomUpload
 

=== modified file 'lib/lp/archivepublisher/utils.py'
--- lib/lp/archivepublisher/utils.py	2011-04-04 11:41:52 +0000
+++ lib/lp/archivepublisher/utils.py	2012-04-16 23:21:20 +0000
@@ -6,7 +6,6 @@
 __metaclass__ = type
 
 __all__ = [
-    'PublishingTunableLoop',
     'RepositoryIndexFile',
     'get_ppa_reference',
     ]

=== modified file 'lib/lp/blueprints/model/specificationbranch.py'
--- lib/lp/blueprints/model/specificationbranch.py	2011-12-30 06:14:56 +0000
+++ lib/lp/blueprints/model/specificationbranch.py	2012-04-16 23:21:20 +0000
@@ -15,7 +15,6 @@
 from sqlobject import (
     ForeignKey,
     IN,
-    StringCol,
     )
 from zope.interface import implements
 

=== modified file 'lib/lp/blueprints/model/sprintattendance.py'
--- lib/lp/blueprints/model/sprintattendance.py	2011-12-30 06:14:56 +0000
+++ lib/lp/blueprints/model/sprintattendance.py	2012-04-16 23:21:20 +0000
@@ -11,7 +11,6 @@
     Bool,
     Int,
     Reference,
-    Store,
     )
 from zope.interface import implements
 

=== modified file 'lib/lp/bugs/browser/malone.py'
--- lib/lp/bugs/browser/malone.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/browser/malone.py	2012-04-16 23:21:20 +0000
@@ -11,7 +11,6 @@
 
 
 from zope.component import getUtility
-from zope.security.interfaces import Unauthorized
 
 from lp.bugs.browser.bug import MaloneView
 from lp.bugs.interfaces.bug import IBugSet

=== modified file 'lib/lp/bugs/browser/tests/test_bugtarget_patches_view.py'
--- lib/lp/bugs/browser/tests/test_bugtarget_patches_view.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/browser/tests/test_bugtarget_patches_view.py	2012-04-16 23:21:20 +0000
@@ -4,14 +4,11 @@
 __metaclass__ = type
 
 
-import unittest
-
 from lp.bugs.browser.bugtarget import BugsPatchesView
 from lp.bugs.browser.bugtask import (
     BugListingPortletStatsView,
     DISPLAY_BUG_STATUS_FOR_PATCHES,
     )
-from lp.bugs.interfaces.bugtask import BugTaskStatus
 from lp.services.webapp.servers import LaunchpadTestRequest
 from lp.testing import (
     login,

=== modified file 'lib/lp/bugs/browser/tests/test_bugtracker_component.py'
--- lib/lp/bugs/browser/tests/test_bugtracker_component.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/browser/tests/test_bugtracker_component.py	2012-04-16 23:21:20 +0000
@@ -89,7 +89,6 @@
 
     def test_unlinking(self):
         component = self._makeComponent(u'Example')
-        distro = getUtility(IDistributionSet).getByName('ubuntu')
         dsp = self._makeUbuntuSourcePackage('example')
         component.distro_source_package = dsp
         form = self._makeForm(None)

=== modified file 'lib/lp/bugs/model/bugtrackerperson.py'
--- lib/lp/bugs/model/bugtrackerperson.py	2011-12-30 06:14:56 +0000
+++ lib/lp/bugs/model/bugtrackerperson.py	2012-04-16 23:21:20 +0000
@@ -12,13 +12,9 @@
     ForeignKey,
     StringCol,
     )
-from zope.component import getUtility
 from zope.interface import implements
 
-from lp.bugs.interfaces.bugtrackerperson import (
-    BugTrackerPersonAlreadyExists,
-    IBugTrackerPerson,
-    )
+from lp.bugs.interfaces.bugtrackerperson import IBugTrackerPerson
 from lp.services.database.constants import UTC_NOW
 from lp.services.database.datetimecol import UtcDateTimeCol
 from lp.services.database.sqlbase import SQLBase

=== modified file 'lib/lp/bugs/scripts/checkwatches/remotebugupdater.py'
--- lib/lp/bugs/scripts/checkwatches/remotebugupdater.py	2011-12-30 06:14:56 +0000
+++ lib/lp/bugs/scripts/checkwatches/remotebugupdater.py	2012-04-16 23:21:20 +0000
@@ -8,8 +8,6 @@
     'RemoteBugUpdater',
     ]
 
-import sys
-
 from zope.component import getUtility
 
 from lp.bugs.externalbugtracker.base import (

=== modified file 'lib/lp/bugs/scripts/checkwatches/tests/test_remotebugupdater.py'
--- lib/lp/bugs/scripts/checkwatches/tests/test_remotebugupdater.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/scripts/checkwatches/tests/test_remotebugupdater.py	2012-04-16 23:21:20 +0000
@@ -5,8 +5,6 @@
 
 __metaclass__ = type
 
-import unittest
-
 import transaction
 
 from lp.bugs.externalbugtracker.base import (

=== modified file 'lib/lp/bugs/tests/bug.py'
--- lib/lp/bugs/tests/bug.py	2012-03-15 05:55:42 +0000
+++ lib/lp/bugs/tests/bug.py	2012-04-16 23:21:20 +0000
@@ -8,7 +8,6 @@
     timedelta,
     )
 from operator import attrgetter
-import re
 import textwrap
 
 from BeautifulSoup import BeautifulSoup

=== modified file 'lib/lp/bugs/tests/test_bugnomination.py'
--- lib/lp/bugs/tests/test_bugnomination.py	2012-02-07 06:48:22 +0000
+++ lib/lp/bugs/tests/test_bugnomination.py	2012-04-16 23:21:20 +0000
@@ -5,31 +5,14 @@
 
 __metaclass__ = type
 
-from itertools import izip
-import re
-
-from testtools.content import (
-    Content,
-    UTF8_TEXT,
-    )
-from testtools.matchers import (
-    Equals,
-    LessThan,
-    Not,
-    )
-
-from lp.services.database.sqlbase import flush_database_updates
 from lp.soyuz.interfaces.publishing import PackagePublishingStatus
 from lp.testing import (
     celebrity_logged_in,
     login,
     logout,
-    person_logged_in,
-    StormStatementRecorder,
     TestCaseWithFactory,
     )
 from lp.testing.layers import DatabaseFunctionalLayer
-from lp.testing.matchers import HasQueryCount
 
 
 class CanBeNominatedForTestMixin:

=== modified file 'lib/lp/bugs/tests/test_bugsubscription.py'
--- lib/lp/bugs/tests/test_bugsubscription.py	2012-03-13 00:45:33 +0000
+++ lib/lp/bugs/tests/test_bugsubscription.py	2012-04-16 23:21:20 +0000
@@ -5,11 +5,7 @@
 
 __metaclass__ = type
 
-from testtools.matchers import (
-    Equals,
-    LessThan,
-    MatchesAny,
-    )
+from testtools.matchers import LessThan
 from zope.security.interfaces import Unauthorized
 
 from lp.bugs.enums import BugNotificationLevel

=== modified file 'lib/lp/bugs/tests/test_duplicate_handling.py'
--- lib/lp/bugs/tests/test_duplicate_handling.py	2012-02-07 08:17:13 +0000
+++ lib/lp/bugs/tests/test_duplicate_handling.py	2012-04-16 23:21:20 +0000
@@ -8,10 +8,7 @@
 from zope.security.interfaces import ForbiddenAttribute
 
 from lp.bugs.errors import InvalidDuplicateValue
-from lp.testing import (
-    StormStatementRecorder,
-    TestCaseWithFactory,
-    )
+from lp.testing import TestCaseWithFactory
 from lp.testing.layers import DatabaseFunctionalLayer
 
 

=== modified file 'lib/lp/bugs/windmill/tests/test_bug_also_affects_new_upstream.py'
--- lib/lp/bugs/windmill/tests/test_bug_also_affects_new_upstream.py	2011-06-27 15:25:17 +0000
+++ lib/lp/bugs/windmill/tests/test_bug_also_affects_new_upstream.py	2012-04-16 23:21:20 +0000
@@ -7,10 +7,7 @@
     constants,
     lpuser,
     )
-from lp.testing.windmill.widgets import (
-    FormPickerWidgetTest,
-    search_picker_widget,
-    )
+from lp.testing.windmill.widgets import search_picker_widget
 
 
 class TestBugAlsoAffects(WindmillTestCase):

=== modified file 'lib/lp/bugs/windmill/tests/test_bug_inline_assignment.py'
--- lib/lp/bugs/windmill/tests/test_bug_inline_assignment.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/windmill/tests/test_bug_inline_assignment.py	2012-04-16 23:21:20 +0000
@@ -4,13 +4,9 @@
 import transaction
 
 from lp.bugs.windmill.testing import BugsWindmillLayer
-from lp.services.webapp import canonical_url
 from lp.testing import WindmillTestCase
 from lp.testing.windmill import lpuser
-from lp.testing.windmill.constants import (
-    FOR_ELEMENT,
-    SLEEP,
-    )
+from lp.testing.windmill.constants import FOR_ELEMENT
 
 
 ASSIGN_BUTTON = (u'//*[@id="affected-software"]//tr//td[5]' +

=== modified file 'lib/lp/bugs/windmill/tests/test_bug_tags_entry.py'
--- lib/lp/bugs/windmill/tests/test_bug_tags_entry.py	2012-01-01 02:58:52 +0000
+++ lib/lp/bugs/windmill/tests/test_bug_tags_entry.py	2012-04-16 23:21:20 +0000
@@ -10,7 +10,6 @@
 from zope.security.proxy import removeSecurityProxy
 
 from lp.bugs.windmill.testing import BugsWindmillLayer
-from lp.services.webapp import canonical_url
 from lp.testing import WindmillTestCase
 from lp.testing.windmill import (
     constants,

=== modified file 'lib/lp/code/browser/widgets/branch.py'
--- lib/lp/code/browser/widgets/branch.py	2012-01-01 02:58:52 +0000
+++ lib/lp/code/browser/widgets/branch.py	2012-04-16 23:21:20 +0000
@@ -94,7 +94,7 @@
     def _toFieldValue(self, form_input):
         try:
             return super(BranchPopupWidget, self)._toFieldValue(form_input)
-        except ConversionError, exception:
+        except ConversionError:
             # Save the initial error so we can re-raise it later.
             exc_class, exc_obj, exc_tb = sys.exc_info()
 

=== modified file 'lib/lp/code/interfaces/branchlink.py'
--- lib/lp/code/interfaces/branchlink.py	2011-12-24 16:54:44 +0000
+++ lib/lp/code/interfaces/branchlink.py	2012-04-16 23:21:20 +0000
@@ -13,13 +13,10 @@
 
 from lazr.restful.declarations import (
     call_with,
-    export_as_webservice_entry,
-    export_operation_as,
     export_write_operation,
     exported,
     operation_for_version,
     operation_parameters,
-    operation_returns_entry,
     REQUEST_USER,
     )
 from lazr.restful.fields import (
@@ -30,7 +27,6 @@
 
 from lp import _
 from lp.code.interfaces.branch import IBranch
-from lp.code.interfaces.branchtarget import IHasBranchTarget
 
 
 class IHasLinkedBranches(Interface):

=== modified file 'lib/lp/code/model/branchmergequeuecollection.py'
--- lib/lp/code/model/branchmergequeuecollection.py	2012-01-01 02:58:52 +0000
+++ lib/lp/code/model/branchmergequeuecollection.py	2012-04-16 23:21:20 +0000
@@ -5,7 +5,7 @@
 
 __metaclass__ = type
 __all__ = [
-    'GenericBranchCollection',
+    'GenericBranchMergeQueueCollection',
     ]
 
 from zope.interface import implements

=== modified file 'lib/lp/code/model/codeimportmachine.py'
--- lib/lp/code/model/codeimportmachine.py	2011-12-30 06:14:56 +0000
+++ lib/lp/code/model/codeimportmachine.py	2012-04-16 23:21:20 +0000
@@ -28,7 +28,6 @@
     ICodeImportMachine,
     ICodeImportMachineSet,
     )
-from lp.services.config import config
 from lp.services.database.constants import (
     DEFAULT,
     UTC_NOW,

=== modified file 'lib/lp/codehosting/puller/tests/__init__.py'
--- lib/lp/codehosting/puller/tests/__init__.py	2012-01-01 02:58:52 +0000
+++ lib/lp/codehosting/puller/tests/__init__.py	2012-04-16 23:21:20 +0000
@@ -10,7 +10,6 @@
 import socket
 from StringIO import StringIO
 
-from bzrlib import urlutils
 from bzrlib.tests import TestCaseWithTransport
 from bzrlib.tests.http_server import (
     HttpServer,
@@ -26,8 +25,6 @@
     )
 from lp.codehosting.safe_open import AcceptAnythingPolicy
 from lp.codehosting.tests.helpers import LoomTestMixin
-from lp.codehosting.vfs import branch_id_to_path
-from lp.services.config import config
 from lp.testing import TestCaseWithFactory
 
 

=== modified file 'lib/lp/codehosting/puller/worker.py'
--- lib/lp/codehosting/puller/worker.py	2012-01-01 07:14:04 +0000
+++ lib/lp/codehosting/puller/worker.py	2012-04-16 23:21:20 +0000
@@ -17,7 +17,6 @@
     urlutils,
     )
 from bzrlib.branch import Branch
-from bzrlib.bzrdir import BzrDir
 from bzrlib.plugins.loom.branch import LoomSupport
 from bzrlib.plugins.weave_fmt.branch import BzrBranchFormat4
 from bzrlib.plugins.weave_fmt.repository import (

=== modified file 'lib/lp/codehosting/sshserver/session.py'
--- lib/lp/codehosting/sshserver/session.py	2012-01-01 02:58:52 +0000
+++ lib/lp/codehosting/sshserver/session.py	2012-04-16 23:21:20 +0000
@@ -143,7 +143,6 @@
         """
         assert executable == 'bzr', executable # Maybe .endswith()
         assert args[0] == 'bzr', args[0]
-        command_str = ' '.join(args[1:])
         message = ['fork-env %s\n' % (' '.join(args[1:]),)]
         for key, value in environment.iteritems():
             # XXX: Currently we only pass BZR_EMAIL, should we be passing

=== modified file 'lib/lp/registry/browser/tests/test_subscription_links.py'
--- lib/lp/registry/browser/tests/test_subscription_links.py	2012-01-01 02:58:52 +0000
+++ lib/lp/registry/browser/tests/test_subscription_links.py	2012-04-16 23:21:20 +0000
@@ -5,7 +5,6 @@
 
 __metaclass__ = type
 
-import re
 import unittest
 
 from BeautifulSoup import BeautifulSoup

=== modified file 'lib/lp/registry/model/announcement.py'
--- lib/lp/registry/model/announcement.py	2011-12-30 06:14:56 +0000
+++ lib/lp/registry/model/announcement.py	2012-04-16 23:21:20 +0000
@@ -153,7 +153,6 @@
         """See IHasAnnouncements."""
 
         # Create the SQL query.
-        clauseTables = []
         query = '1=1 '
         # Filter for published news items if necessary.
         if published_only:

=== modified file 'lib/lp/registry/model/projectgroup.py'
--- lib/lp/registry/model/projectgroup.py	2012-02-08 06:00:46 +0000
+++ lib/lp/registry/model/projectgroup.py	2012-04-16 23:21:20 +0000
@@ -23,7 +23,6 @@
     Join,
     SQL,
     )
-from storm.locals import Int
 from storm.store import Store
 from zope.component import getUtility
 from zope.interface import implements

=== modified file 'lib/lp/registry/scripts/productreleasefinder/finder.py'
--- lib/lp/registry/scripts/productreleasefinder/finder.py	2011-04-12 23:25:45 +0000
+++ lib/lp/registry/scripts/productreleasefinder/finder.py	2012-04-16 23:21:20 +0000
@@ -21,7 +21,6 @@
 from lp.app.validators.name import invalid_name_pattern
 from lp.app.validators.version import sane_version
 from lp.registry.interfaces.product import IProductSet
-from lp.registry.interfaces.productrelease import UpstreamFileType
 from lp.registry.interfaces.series import SeriesStatus
 from lp.registry.scripts.productreleasefinder.filter import FilterPattern
 from lp.registry.scripts.productreleasefinder.hose import Hose

=== modified file 'lib/lp/registry/scripts/productreleasefinder/walker.py'
--- lib/lp/registry/scripts/productreleasefinder/walker.py	2012-01-01 02:58:52 +0000
+++ lib/lp/registry/scripts/productreleasefinder/walker.py	2012-04-16 23:21:20 +0000
@@ -136,7 +136,7 @@
 
             try:
                 (dirnames, filenames) = self.list(sub_dir)
-            except WalkerError, exc:
+            except WalkerError:
                 self.log.info('could not retrieve directory '
                                    'listing for %s', sub_dir)
                 continue
@@ -339,7 +339,7 @@
 
         self.log.debug("Checking if %s is a directory" % path)
         try:
-            response = self.request("HEAD", path)
+            self.request("HEAD", path)
             return False
         except urllib2.HTTPError, exc:
             if exc.code != 301:

=== modified file 'lib/lp/registry/tests/test_distributionmirror.py'
--- lib/lp/registry/tests/test_distributionmirror.py	2011-12-30 06:14:56 +0000
+++ lib/lp/registry/tests/test_distributionmirror.py	2012-04-16 23:21:20 +0000
@@ -37,10 +37,8 @@
         login('test@xxxxxxxxxxxxx')
         self.factory = LaunchpadObjectFactory()
         mirrorset = getUtility(IDistributionMirrorSet)
-        self.cdimage_mirror = getUtility(IDistributionMirrorSet).getByName(
-            'releases-mirror')
-        self.archive_mirror = getUtility(IDistributionMirrorSet).getByName(
-            'archive-mirror')
+        self.cdimage_mirror = mirrorset.getByName('releases-mirror')
+        self.archive_mirror = mirrorset.getByName('archive-mirror')
         self.hoary = getUtility(IDistributionSet)['ubuntu']['hoary']
         self.hoary_i386 = self.hoary['i386']
 

=== modified file 'lib/lp/registry/tests/test_teammembership_webservice.py'
--- lib/lp/registry/tests/test_teammembership_webservice.py	2012-01-01 02:58:52 +0000
+++ lib/lp/registry/tests/test_teammembership_webservice.py	2012-04-16 23:21:20 +0000
@@ -29,7 +29,7 @@
             name='some-team',
             owner=owner)
         membership_set = getUtility(ITeamMembershipSet)
-        membership = membership_set.new(
+        membership_set.new(
             self.person,
             self.team,
             TeamMembershipStatus.APPROVED,
@@ -43,7 +43,7 @@
         team_membership = team.members_details[1]
         # The error in this instance should be a valueerror, b/c the
         # WADL used by launchpadlib will enforce the method args.
-        api_exception = self.assertRaises(
+        self.assertRaises(
             ValueError,
             team_membership.setStatus,
             status='NOTVALIDSTATUS')

=== modified file 'lib/lp/scripts/scriptmonitor.py'
--- lib/lp/scripts/scriptmonitor.py	2011-12-30 06:14:56 +0000
+++ lib/lp/scripts/scriptmonitor.py	2012-04-16 23:21:20 +0000
@@ -25,7 +25,7 @@
         LIMIT 1
         """ % sqlvalues(hostname, scriptname, completed_from, completed_to))
     try:
-        script_id = cur.fetchone()[0]
+        cur.fetchone()[0]
         return None
     except TypeError:
         output = ("The script '%s' didn't run on '%s' between %s and %s"

=== modified file 'lib/lp/scripts/utilities/killservice.py'
--- lib/lp/scripts/utilities/killservice.py	2011-12-30 08:13:14 +0000
+++ lib/lp/scripts/utilities/killservice.py	2012-04-16 23:21:20 +0000
@@ -105,11 +105,11 @@
 def process_exists(pid):
     """True if the given process exists."""
     try:
-        pgid = os.getpgid(pid)
+        os.getpgid(pid)
     except OSError, x:
         if x.errno == 3:
             return False
-        log.error("Unknown exception from getpgid - %s", str(x))
+        logging.error("Unknown exception from getpgid - %s", str(x))
     return True
 
 

=== modified file 'lib/lp/scripts/utilities/warninghandler.py'
--- lib/lp/scripts/utilities/warninghandler.py	2012-03-22 23:21:24 +0000
+++ lib/lp/scripts/utilities/warninghandler.py	2012-04-16 23:21:20 +0000
@@ -105,7 +105,6 @@
                     metadata["doctest"] = (filename, lineno, func_name)
                 if 'self' in frame.f_locals:
                     fself = frame.f_locals['self']
-                    ftype = type(fself)
                     for cls in list(important_classes):
                         if isinstance(fself, cls):
                             important_objects[cls] = fself

=== modified file 'lib/lp/services/config/tests/test_fixture.py'
--- lib/lp/services/config/tests/test_fixture.py	2011-12-29 05:29:36 +0000
+++ lib/lp/services/config/tests/test_fixture.py	2012-04-16 23:21:20 +0000
@@ -5,9 +5,6 @@
 
 __metaclass__ = type
 
-import os
-from textwrap import dedent
-
 from testtools import TestCase
 
 from lp.services.config import config

=== modified file 'lib/lp/services/database/__init__.py'
--- lib/lp/services/database/__init__.py	2011-12-30 06:14:56 +0000
+++ lib/lp/services/database/__init__.py	2012-04-16 23:21:20 +0000
@@ -36,7 +36,7 @@
             try:
                 return func(*args, **kwargs)
             except (DisconnectionError, IntegrityError,
-                    TransactionRollbackError), exc:
+                    TransactionRollbackError):
                 if attempt >= RETRY_ATTEMPTS:
                     raise # tried too many times
     return mergeFunctionMetadata(func, retry_transaction_decorator)

=== modified file 'lib/lp/services/database/stormbase.py'
--- lib/lp/services/database/stormbase.py	2012-01-31 01:19:45 +0000
+++ lib/lp/services/database/stormbase.py	2012-04-16 23:21:20 +0000
@@ -7,7 +7,6 @@
     ]
 
 from storm.base import Storm
-from zope.component import getUtility
 
 from lp.services.propertycache import clear_property_cache
 

=== modified file 'lib/lp/services/identity/interfaces/emailaddress.py'
--- lib/lp/services/identity/interfaces/emailaddress.py	2012-04-13 02:46:33 +0000
+++ lib/lp/services/identity/interfaces/emailaddress.py	2012-04-16 23:21:20 +0000
@@ -26,7 +26,6 @@
 from zope.schema import (
     Choice,
     Int,
-    Object,
     TextLine,
     )
 

=== modified file 'lib/lp/services/librarianserver/db.py'
--- lib/lp/services/librarianserver/db.py	2011-12-30 06:14:56 +0000
+++ lib/lp/services/librarianserver/db.py	2012-04-16 23:21:20 +0000
@@ -6,8 +6,6 @@
 __metaclass__ = type
 __all__ = [
     'Library',
-    'read_transaction',
-    'write_transaction',
     ]
 
 from sqlobject.sqlbuilder import AND

=== modified file 'lib/lp/services/librarianserver/testing/tests/test_fakelibrarian.py'
--- lib/lp/services/librarianserver/testing/tests/test_fakelibrarian.py	2011-12-30 01:48:17 +0000
+++ lib/lp/services/librarianserver/testing/tests/test_fakelibrarian.py	2012-04-16 23:21:20 +0000
@@ -129,7 +129,6 @@
 
     def test_deleted_alias_has_no_url(self):
         name, text, alias = self._storeFile()
-        librarian = getUtility(ILibrarianClient)
 
         self.assertNotEqual(None, alias.getURL())
         removeSecurityProxy(alias).content = None

=== modified file 'lib/lp/services/librarianserver/testing/tests/test_server_fixture.py'
--- lib/lp/services/librarianserver/testing/tests/test_server_fixture.py	2011-12-30 01:48:17 +0000
+++ lib/lp/services/librarianserver/testing/tests/test_server_fixture.py	2012-04-16 23:21:20 +0000
@@ -12,9 +12,6 @@
 from textwrap import dedent
 from urllib import urlopen
 
-from testtools.content import Content
-from testtools.content_type import UTF8_TEXT
-
 from lp.services.config import config
 from lp.services.config.fixture import ConfigFixture
 from lp.services.librarianserver.testing.server import LibrarianServerFixture
@@ -23,10 +20,6 @@
     BaseLayer,
     DatabaseLayer,
     )
-from lp.testing.tests.test_layers_functional import (
-    BaseLayerIsolator,
-    LayerFixture,
-    )
 
 
 class TestLibrarianServerFixture(TestCase):

=== modified file 'lib/lp/services/librarianserver/tests/test_apachelogparser.py'
--- lib/lp/services/librarianserver/tests/test_apachelogparser.py	2011-12-30 01:48:17 +0000
+++ lib/lp/services/librarianserver/tests/test_apachelogparser.py	2012-04-16 23:21:20 +0000
@@ -106,7 +106,6 @@
             self.logger.getLogBuffer().strip(),
             'INFO Parsed 1 lines resulting in 1 download stats.')
 
-        date = datetime(2008, 6, 13)
         self.assertEqual(downloads,
             {'15018215': {datetime(2008, 6, 13): {'US': 1}}})
 

=== modified file 'lib/lp/services/librarianserver/tests/test_storage.py'
--- lib/lp/services/librarianserver/tests/test_storage.py	2011-12-30 01:48:17 +0000
+++ lib/lp/services/librarianserver/tests/test_storage.py	2012-04-16 23:21:20 +0000
@@ -139,9 +139,6 @@
     def lookupBySHA1(self, digest):
         return []
 
-    def add(self, digest, size):
-        return 99
-
     def addAlias(self, fileid, filename, mimetype):
         pass
 

=== modified file 'lib/lp/services/mail/mbox.py'
--- lib/lp/services/mail/mbox.py	2011-08-12 14:49:34 +0000
+++ lib/lp/services/mail/mbox.py	2012-04-16 23:21:20 +0000
@@ -10,7 +10,6 @@
 import email
 from email.Utils import make_msgid
 from logging import getLogger
-import mailbox
 
 from zope.app import zapi
 from zope.interface import implements

=== modified file 'lib/lp/services/messages/browser/message.py'
--- lib/lp/services/messages/browser/message.py	2012-01-01 02:58:52 +0000
+++ lib/lp/services/messages/browser/message.py	2012-04-16 23:21:20 +0000
@@ -48,7 +48,6 @@
 def message_to_canonical_url_data(message):
     """This factory creates `ICanonicalUrlData` for Message."""
     # Circular imports
-    from lp.bugs.interfaces.bugmessage import IBugMessage
     from lp.answers.interfaces.questionmessage import IQuestionMessage
     if IIndexedMessage.providedBy(message):
         return IndexedBugMessageCanonicalUrlData(message)

=== modified file 'lib/lp/services/openid/adapters/openid.py'
--- lib/lp/services/openid/adapters/openid.py	2012-01-01 02:58:52 +0000
+++ lib/lp/services/openid/adapters/openid.py	2012-04-16 23:21:20 +0000
@@ -18,7 +18,6 @@
     implementer,
     implements,
     )
-from zope.security.proxy import removeSecurityProxy
 
 from lp.registry.interfaces.person import IPerson
 from lp.services.database.lpstorm import IStore

=== modified file 'lib/lp/services/openid/tests/test_baseopenidstore.py'
--- lib/lp/services/openid/tests/test_baseopenidstore.py	2011-12-21 14:58:31 +0000
+++ lib/lp/services/openid/tests/test_baseopenidstore.py	2012-04-16 23:21:20 +0000
@@ -115,9 +115,9 @@
         self.assertEqual(
             self.store.useNonce('server-url', timestamp, 'salt'), True)
         storm_store = IMasterStore(self.store.Nonce)
-        nonce = storm_store.get(
+        new_nonce = storm_store.get(
             self.store.Nonce, (u'server-url', timestamp, u'salt'))
-        self.assertIsNot(None, nonce)
+        self.assertIsNot(None, new_nonce)
 
         self.assertEqual(
             self.store.useNonce('server-url', timestamp, 'salt'), False)

=== modified file 'lib/lp/services/scripts/tests/test_cronscript_enabled.py'
--- lib/lp/services/scripts/tests/test_cronscript_enabled.py	2011-08-12 11:37:08 +0000
+++ lib/lp/services/scripts/tests/test_cronscript_enabled.py	2012-04-16 23:21:20 +0000
@@ -5,8 +5,6 @@
 
 __metaclass__ = type
 
-from cStringIO import StringIO
-from logging import DEBUG
 import os.path
 import subprocess
 import sys

=== modified file 'lib/lp/services/spriteutils.py'
--- lib/lp/services/spriteutils.py	2010-10-26 15:47:24 +0000
+++ lib/lp/services/spriteutils.py	2012-04-16 23:21:20 +0000
@@ -105,7 +105,6 @@
                 continue
             match = smartsprites_exp.search(rule.cssText)
             if match is not None:
-                smartsprites_info = match.group(1)
                 parameters = self._parseCommentParameters(match.group(1))
                 # Currently, only a single combined image is supported.
                 if parameters['sprite-ref'] == group_name:

=== modified file 'lib/lp/services/sshserver/service.py'
--- lib/lp/services/sshserver/service.py	2011-12-09 14:42:31 +0000
+++ lib/lp/services/sshserver/service.py	2012-04-16 23:21:20 +0000
@@ -31,7 +31,6 @@
     )
 from lp.services.sshserver.auth import SSHUserAuthServer
 from lp.services.twistedsupport import gatherResults
-from lp.services.twistedsupport.loggingsupport import set_up_oops_reporting
 
 
 class KeepAliveSettingSSHServerTransport(SSHServerTransport):

=== modified file 'lib/lp/services/temporaryblobstorage/interfaces.py'
--- lib/lp/services/temporaryblobstorage/interfaces.py	2011-12-24 16:54:44 +0000
+++ lib/lp/services/temporaryblobstorage/interfaces.py	2012-04-16 23:21:20 +0000
@@ -21,7 +21,6 @@
     exported,
     operation_parameters,
     rename_parameters_as,
-    REQUEST_USER,
     )
 from lazr.restful.interface import copy_field
 from zope.interface import (

=== modified file 'lib/lp/services/testing/parallel.py'
--- lib/lp/services/testing/parallel.py	2012-01-01 02:58:52 +0000
+++ lib/lp/services/testing/parallel.py	2012-04-16 23:21:20 +0000
@@ -7,7 +7,6 @@
 __all__ = ["main"]
 
 import itertools
-import os
 import subprocess
 import sys
 import tempfile

=== modified file 'lib/lp/services/tests/test_command_spawner.py'
--- lib/lp/services/tests/test_command_spawner.py	2011-12-19 23:38:16 +0000
+++ lib/lp/services/tests/test_command_spawner.py	2012-04-16 23:21:20 +0000
@@ -102,7 +102,6 @@
     def test_start_runs_its_command(self):
         spawner, process = self._makeSpawnerAndProcess()
         spawner.start("/bin/true")
-        spawn_calls = spawner._spawn.calls
         self.assertEqual([("/bin/true", )], spawner._spawn.extract_args())
 
     def test_output_is_nonblocking(self):

=== modified file 'lib/lp/services/timeline/tests/test_requesttimeline.py'
--- lib/lp/services/timeline/tests/test_requesttimeline.py	2011-12-24 17:49:30 +0000
+++ lib/lp/services/timeline/tests/test_requesttimeline.py	2012-04-16 23:21:20 +0000
@@ -6,10 +6,7 @@
 __metaclass__ = type
 
 import testtools
-from timeline.timeline import (
-    OverlappingActionError,
-    Timeline,
-    )
+from timeline.timeline import Timeline
 from zope.publisher.browser import TestRequest
 
 from lp.services import webapp

=== modified file 'lib/lp/services/tokens.py'
--- lib/lp/services/tokens.py	2011-12-21 14:58:31 +0000
+++ lib/lp/services/tokens.py	2012-04-16 23:21:20 +0000
@@ -12,8 +12,6 @@
 
 import random
 
-from zope.component import getUtility
-
 from lp.services.database.lpstorm import IMasterStore
 
 

=== modified file 'lib/lp/services/twistedsupport/loggingsupport.py'
--- lib/lp/services/twistedsupport/loggingsupport.py	2011-12-30 01:10:37 +0000
+++ lib/lp/services/twistedsupport/loggingsupport.py	2012-04-16 23:21:20 +0000
@@ -10,7 +10,6 @@
     'LaunchpadLogFile',
     'set_up_logging_for_script',
     'set_up_oops_reporting',
-    'set_up_tacfile_logging',
     ]
 
 

=== modified file 'lib/lp/services/webapp/opstats.py'
--- lib/lp/services/webapp/opstats.py	2011-12-24 17:49:30 +0000
+++ lib/lp/services/webapp/opstats.py	2012-04-16 23:21:20 +0000
@@ -4,7 +4,7 @@
 """XML-RPC interface for extracting real time stats from the appserver."""
 
 __metaclass__ = type
-__all__ = ["OpStats", "IOpStats"]
+__all__ = ["OpStats"]
 
 from cStringIO import StringIO
 from time import time

=== modified file 'lib/lp/soyuz/adapters/archivedependencies.py'
--- lib/lp/soyuz/adapters/archivedependencies.py	2011-05-19 15:26:32 +0000
+++ lib/lp/soyuz/adapters/archivedependencies.py	2012-04-16 23:21:20 +0000
@@ -227,7 +227,7 @@
                 line = archive_dep % (
                     {'series': distroarchseries.distroseries.name})
                 external_dep_lines.append(line)
-    except StandardError, e:
+    except StandardError:
         # Malformed external dependencies can incapacitate the build farm
         # manager (lp:516169). That's obviously not acceptable.
         # Log the error, and disable the PPA.

=== modified file 'lib/lp/soyuz/browser/archivepermission.py'
--- lib/lp/soyuz/browser/archivepermission.py	2011-12-24 17:49:30 +0000
+++ lib/lp/soyuz/browser/archivepermission.py	2012-04-16 23:21:20 +0000
@@ -6,7 +6,7 @@
 __metaclass__ = type
 
 __all__ = [
-    'ArchivePermissionUrl',
+    'ArchivePermissionURL',
     ]
 
 from zope.interface import implements

=== modified file 'lib/lp/soyuz/browser/tests/test_builder.py'
--- lib/lp/soyuz/browser/tests/test_builder.py	2012-03-16 01:32:05 +0000
+++ lib/lp/soyuz/browser/tests/test_builder.py	2012-04-16 23:21:20 +0000
@@ -7,7 +7,6 @@
 
 from testtools.matchers import Equals
 from zope.component import getUtility
-from zope.security.proxy import removeSecurityProxy
 
 from lp.buildmaster.interfaces.builder import IBuilderSet
 from lp.buildmaster.interfaces.buildqueue import IBuildQueueSet

=== modified file 'lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py'
--- lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py	2012-01-01 02:58:52 +0000
+++ lib/lp/soyuz/browser/tests/test_sourcepackagerelease.py	2012-04-16 23:21:20 +0000
@@ -8,7 +8,7 @@
 __metaclass__ = type
 __all__ = [
     'TestSourcePackageReleaseFiles',
-    'test_suite',
+    'TestSourcePackageReleaseView',
     ]
 
 from zope.security.proxy import removeSecurityProxy

=== modified file 'lib/lp/soyuz/model/archivearch.py'
--- lib/lp/soyuz/model/archivearch.py	2011-12-24 17:49:30 +0000
+++ lib/lp/soyuz/model/archivearch.py	2012-04-16 23:21:20 +0000
@@ -6,7 +6,6 @@
 
 from storm.expr import (
     And,
-    Join,
     LeftJoin,
     )
 from storm.locals import (

=== modified file 'lib/lp/soyuz/model/binarypackagerelease.py'
--- lib/lp/soyuz/model/binarypackagerelease.py	2011-12-30 06:14:56 +0000
+++ lib/lp/soyuz/model/binarypackagerelease.py	2012-04-16 23:21:20 +0000
@@ -15,7 +15,6 @@
     BoolCol,
     ForeignKey,
     IntCol,
-    SQLMultipleJoin,
     StringCol,
     )
 from storm.locals import (
@@ -30,12 +29,7 @@
 from lp.services.database.constants import UTC_NOW
 from lp.services.database.datetimecol import UtcDateTimeCol
 from lp.services.database.enumcol import EnumCol
-from lp.services.database.sqlbase import (
-    quote,
-    quote_like,
-    SQLBase,
-    sqlvalues,
-    )
+from lp.services.database.sqlbase import SQLBase
 from lp.services.propertycache import (
     cachedproperty,
     get_property_cache,
@@ -44,7 +38,6 @@
     BinaryPackageFileType,
     BinaryPackageFormat,
     PackagePublishingPriority,
-    PackagePublishingStatus,
     )
 from lp.soyuz.interfaces.binarypackagerelease import (
     IBinaryPackageRelease,

=== modified file 'lib/lp/soyuz/model/packagediff.py'
--- lib/lp/soyuz/model/packagediff.py	2011-12-30 06:14:56 +0000
+++ lib/lp/soyuz/model/packagediff.py	2012-04-16 23:21:20 +0000
@@ -67,7 +67,6 @@
         with the second package.
     :type to_files: ``list``
     """
-    compressed_bytes = -1
     [from_dsc] = [name for name in from_files
                   if name.lower().endswith('.dsc')]
     [to_dsc] = [name for name in to_files
@@ -189,9 +188,6 @@
             # Keep track of the files belonging to the respective packages.
             downloaded = dict(zip(directions, ([], [])))
 
-            # Please note that packages may have files in common.
-            files_seen = []
-
             # Make it easy to iterate over packages.
             packages = dict(
                 zip(directions, (self.from_source, self.to_source)))
@@ -295,13 +291,13 @@
 
         def preload_hook(rows):
             lfas = load(LibraryFileAlias, (pd.diff_contentID for pd in rows))
-            lfcs = load(LibraryFileContent, (lfa.contentID for lfa in lfas))
+            load(LibraryFileContent, (lfa.contentID for lfa in lfas))
             sprs = load(
                 SourcePackageRelease,
                 itertools.chain.from_iterable(
                     (pd.from_sourceID, pd.to_sourceID) for pd in rows))
             archives = load(Archive, (spr.upload_archiveID for spr in sprs))
-            distros = load(Distribution, (a.distributionID for a in archives))
+            load(Distribution, (a.distributionID for a in archives))
 
         if preload_for_display:
             return DecoratedResultSet(result, pre_iter_hook=preload_hook)

=== modified file 'lib/lp/soyuz/scripts/changeoverride.py'
--- lib/lp/soyuz/scripts/changeoverride.py	2011-06-09 10:50:25 +0000
+++ lib/lp/soyuz/scripts/changeoverride.py	2012-04-16 23:21:20 +0000
@@ -6,8 +6,8 @@
 __metaclass__ = type
 
 __all__ = [
-    'ArchiveOverrider',
     'ArchiveOverriderError',
+    'ChangeOverride',
     ]
 
 from zope.component import getUtility

=== modified file 'lib/lp/soyuz/scripts/processdeathrow.py'
--- lib/lp/soyuz/scripts/processdeathrow.py	2012-01-06 11:08:30 +0000
+++ lib/lp/soyuz/scripts/processdeathrow.py	2012-04-16 23:21:20 +0000
@@ -69,7 +69,7 @@
             "Unpublishing death row for %s." % archive.displayname)
         try:
             death_row.reap(self.options.dry_run)
-        except Exception, e:
+        except Exception:
             self.logger.exception(
                 "Unexpected exception while doing death-row unpublish")
             self.txn.abort()

=== modified file 'lib/lp/soyuz/tests/test_hasbuildrecords.py'
--- lib/lp/soyuz/tests/test_hasbuildrecords.py	2012-01-01 02:58:52 +0000
+++ lib/lp/soyuz/tests/test_hasbuildrecords.py	2012-04-16 23:21:20 +0000
@@ -22,10 +22,7 @@
 from lp.registry.interfaces.person import IPersonSet
 from lp.registry.interfaces.pocket import PackagePublishingPocket
 from lp.registry.model.sourcepackage import SourcePackage
-from lp.soyuz.enums import (
-    ArchivePurpose,
-    PackagePublishingStatus,
-    )
+from lp.soyuz.enums import ArchivePurpose
 from lp.soyuz.interfaces.binarypackagebuild import IBinaryPackageBuild
 from lp.soyuz.interfaces.buildrecords import (
     IHasBuildRecords,

=== modified file 'lib/lp/translations/browser/translationtemplatesbuild.py'
--- lib/lp/translations/browser/translationtemplatesbuild.py	2012-01-01 02:58:52 +0000
+++ lib/lp/translations/browser/translationtemplatesbuild.py	2012-04-16 23:21:20 +0000
@@ -5,8 +5,6 @@
 
 __metaclass__ = type
 __all__ = [
-    'TranslationTemplatesBuildNavigation',
-    'TranslationTemplatesBuildUrl',
     'TranslationTemplatesBuildView',
     ]
 

=== modified file 'lib/lp/translations/browser/translator.py'
--- lib/lp/translations/browser/translator.py	2012-01-01 02:58:52 +0000
+++ lib/lp/translations/browser/translator.py	2012-04-16 23:21:20 +0000
@@ -8,8 +8,6 @@
     'TranslatorRemoveView',
     ]
 
-import cgi
-
 from lp.app.browser.launchpadform import (
     action,
     LaunchpadEditFormView,

=== modified file 'lib/lp/translations/interfaces/translationgroup.py'
--- lib/lp/translations/interfaces/translationgroup.py	2011-12-24 16:54:44 +0000
+++ lib/lp/translations/interfaces/translationgroup.py	2012-04-16 23:21:20 +0000
@@ -17,7 +17,6 @@
     collection_default_content,
     export_as_webservice_collection,
     export_as_webservice_entry,
-    export_operation_as,
     export_read_operation,
     exported,
     operation_for_version,

=== modified file 'scripts/copy-translations-from-parent.py'
--- scripts/copy-translations-from-parent.py	2012-01-01 03:13:08 +0000
+++ scripts/copy-translations-from-parent.py	2012-04-16 23:21:20 +0000
@@ -18,7 +18,6 @@
 
 from zope.component import getUtility
 
-from lp.services.config import config
 from lp.services.scripts.base import LaunchpadCronScript
 from lp.translations.scripts.copy_distroseries_translations import (
     copy_distroseries_translations,


Follow ups