← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] lp:~cjwatson/launchpad/code-lint into lp:launchpad

 

Colin Watson has proposed merging lp:~cjwatson/launchpad/code-lint into lp:launchpad.

Commit message:
Remove lots of lint from lp.code*.

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/code-lint/+merge/274880

Remove lots of lint from lp.code*.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of lp:~cjwatson/launchpad/code-lint into lp:launchpad.
=== modified file 'lib/lp/code/browser/tests/test_gitrepository.py'
--- lib/lp/code/browser/tests/test_gitrepository.py	2015-10-13 16:58:20 +0000
+++ lib/lp/code/browser/tests/test_gitrepository.py	2015-10-19 11:35:18 +0000
@@ -11,10 +11,7 @@
 from BeautifulSoup import BeautifulSoup
 from fixtures import FakeLogger
 import pytz
-from testtools.matchers import (
-    DocTestMatches,
-    Equals,
-    )
+from testtools.matchers import DocTestMatches
 import transaction
 from zope.component import getUtility
 from zope.formlib.itemswidgets import ItemDisplayWidget

=== modified file 'lib/lp/code/browser/tests/test_sourcepackagerecipelisting.py'
--- lib/lp/code/browser/tests/test_sourcepackagerecipelisting.py	2015-10-13 16:58:20 +0000
+++ lib/lp/code/browser/tests/test_sourcepackagerecipelisting.py	2015-10-19 11:35:18 +0000
@@ -6,8 +6,6 @@
 __metaclass__ = type
 
 
-from testtools.matchers import Equals
-
 from lp.testing import (
     BrowserTestCase,
     person_logged_in,

=== modified file 'lib/lp/code/interfaces/branchmergeproposal.py'
--- lib/lp/code/interfaces/branchmergeproposal.py	2015-10-13 17:32:48 +0000
+++ lib/lp/code/interfaces/branchmergeproposal.py	2015-10-19 11:35:18 +0000
@@ -602,8 +602,8 @@
             to the current merge_target).
         :param merge_prerequisite: The merge_prerequisite for the new
             proposal (defaults to the current merge_prerequisite).
-        :param commit_message: The commit message for the new proposal (defaults
-            to the current commit message).
+        :param commit_message: The commit message for the new proposal
+            (defaults to the current commit message).
         :param description: The description for the new proposal (defaults to
             the current description).
         """

=== modified file 'lib/lp/code/interfaces/codeimportevent.py'
--- lib/lp/code/interfaces/codeimportevent.py	2013-01-07 02:40:55 +0000
+++ lib/lp/code/interfaces/codeimportevent.py	2015-10-19 11:35:18 +0000
@@ -56,6 +56,7 @@
         strings or None.
         """
 
+
 class ICodeImportEventSet(Interface):
     """The set of all CodeImportEvent objects."""
 

=== modified file 'lib/lp/code/mail/branchmergeproposal.py'
--- lib/lp/code/mail/branchmergeproposal.py	2015-09-08 11:56:33 +0000
+++ lib/lp/code/mail/branchmergeproposal.py	2015-10-19 11:35:18 +0000
@@ -205,7 +205,8 @@
         if not self.merge_proposal.commit_message:
             return ''
         else:
-            return 'Commit message:\n%s\n\n' % self.merge_proposal.commit_message
+            return 'Commit message:\n%s\n\n' % (
+                self.merge_proposal.commit_message)
 
     def _getRequestedReviews(self):
         """Return a string describing the requested reviews, if any."""

=== modified file 'lib/lp/code/model/codereviewcomment.py'
--- lib/lp/code/model/codereviewcomment.py	2015-07-08 16:05:11 +0000
+++ lib/lp/code/model/codereviewcomment.py	2015-10-19 11:35:18 +0000
@@ -124,4 +124,3 @@
         if self.message.raw is None:
             return None
         return signed_message_from_string(self.message.raw.read())
-

=== modified file 'lib/lp/code/model/tests/test_codeimportjob.py'
--- lib/lp/code/model/tests/test_codeimportjob.py	2013-05-01 21:23:16 +0000
+++ lib/lp/code/model/tests/test_codeimportjob.py	2015-10-19 11:35:18 +0000
@@ -245,7 +245,7 @@
 
     def test_upToDateJob(self):
         # A job that was updated recently is not considered reclaimable.
-        self.makeJobWithHeartbeatInPast(self.LIMIT/2)
+        self.makeJobWithHeartbeatInPast(self.LIMIT / 2)
         self.assertReclaimableJobs([])
 
     def test_staleJob(self):
@@ -266,8 +266,8 @@
     def test_staleAndFreshJobs(self):
         # If there are both fresh and stake jobs in the DB, only the
         # stale ones are returned by getReclaimableJobs().
-        self.makeJobWithHeartbeatInPast(self.LIMIT/2)
-        stale_job = self.makeJobWithHeartbeatInPast(self.LIMIT*2)
+        self.makeJobWithHeartbeatInPast(self.LIMIT / 2)
+        stale_job = self.makeJobWithHeartbeatInPast(self.LIMIT * 2)
         self.assertReclaimableJobs([stale_job])
 
 
@@ -279,7 +279,7 @@
     def test_getJobForMachineGardens(self):
         # getJobForMachine reclaims all reclaimable jobs each time it is
         # called.
-        stale_job = self.makeJobWithHeartbeatInPast(self.LIMIT*2)
+        stale_job = self.makeJobWithHeartbeatInPast(self.LIMIT * 2)
         # We assume that this is the only reclaimable job.
         self.assertReclaimableJobs([stale_job])
         machine = self.factory.makeCodeImportMachine(set_online=True)
@@ -422,8 +422,9 @@
         # recent than the effective_update_interval, then the new
         # CodeImportJob has date_due set in the future.
         code_import = self.getCodeImportForDateDueTest()
-        # A code import job is automatically started when a reviewed code import
-        # is created. Remove it, so a "clean" one can be created later.
+        # A code import job is automatically started when a reviewed code
+        # import is created. Remove it, so a "clean" one can be created
+        # later.
         removeSecurityProxy(code_import).import_job.destroySelf()
         # Create a CodeImportResult that started a long time ago. This one
         # must be superseded by the more recent one created below.

=== modified file 'lib/lp/code/model/tests/test_sourcepackagerecipebuild.py'
--- lib/lp/code/model/tests/test_sourcepackagerecipebuild.py	2015-09-28 17:38:45 +0000
+++ lib/lp/code/model/tests/test_sourcepackagerecipebuild.py	2015-10-19 11:35:18 +0000
@@ -9,7 +9,6 @@
     datetime,
     timedelta,
     )
-import re
 
 from pytz import utc
 from storm.locals import Store
@@ -27,15 +26,11 @@
     ISourcePackageRecipeBuild,
     ISourcePackageRecipeBuildSource,
     )
-from lp.code.mail.sourcepackagerecipebuild import (
-    SourcePackageRecipeBuildMailer,
-    )
 from lp.code.model.sourcepackagerecipebuild import SourcePackageRecipeBuild
 from lp.registry.interfaces.pocket import PackagePublishingPocket
 from lp.registry.interfaces.series import SeriesStatus
 from lp.services.database.interfaces import IStore
 from lp.services.log.logger import BufferLogger
-from lp.services.mail.sendmail import format_address
 from lp.services.webapp.authorization import check_permission
 from lp.testing import (
     admin_logged_in,

=== modified file 'lib/lp/code/tests/codeimporthelpers.py'
--- lib/lp/code/tests/codeimporthelpers.py	2011-12-20 23:28:22 +0000
+++ lib/lp/code/tests/codeimporthelpers.py	2015-10-19 11:35:18 +0000
@@ -124,10 +124,11 @@
 def make_all_result_types(code_import, factory, machine, start, count):
     """Make a code import result of each possible type for the code import."""
     start_dates = time_counter(
-        datetime(2007,12,1,12, tzinfo=UTC), timedelta(days=1))
+        datetime(2007, 12, 1, 12, tzinfo=UTC), timedelta(days=1))
     end_dates = time_counter(
-        datetime(2007,12,1,13, tzinfo=UTC), timedelta(days=1, hours=1))
-    for result_status in sorted(CodeImportResultStatus.items)[start:start+count]:
+        datetime(2007, 12, 1, 13, tzinfo=UTC), timedelta(days=1, hours=1))
+    for result_status in sorted(CodeImportResultStatus.items)[
+            start:start + count]:
         factory.makeCodeImportResult(
             code_import, result_status, start_dates.next(), end_dates.next(),
             machine=machine)

=== modified file 'lib/lp/code/vocabularies/gitrepository.py'
--- lib/lp/code/vocabularies/gitrepository.py	2015-07-08 16:05:11 +0000
+++ lib/lp/code/vocabularies/gitrepository.py	2015-10-19 11:35:18 +0000
@@ -64,6 +64,7 @@
     def _getCollection(self):
         return getUtility(IAllGitRepositories)
 
+
 class GitRepositoryRestrictedOnProductVocabulary(GitRepositoryVocabulary):
     """A vocabulary for searching git repositories restricted on product."""
 
@@ -79,4 +80,3 @@
     def _getCollection(self):
         return getUtility(IAllGitRepositories).inProject(
             self.product).isExclusive()
-

=== modified file 'lib/lp/code/vocabularies/tests/test_gitrepository_vocabularies.py'
--- lib/lp/code/vocabularies/tests/test_gitrepository_vocabularies.py	2015-06-24 21:36:49 +0000
+++ lib/lp/code/vocabularies/tests/test_gitrepository_vocabularies.py	2015-10-19 11:35:18 +0000
@@ -103,7 +103,8 @@
         # If there is a single search result that matches, use that
         # as the result.
         term = self.vocab.getTermByToken('mountain')
-        self.assertEqual(u'~scotty/widget/+git/mountain', term.value.unique_name)
+        self.assertEqual(
+            u'~scotty/widget/+git/mountain', term.value.unique_name)
 
     def test_multipleQueryResult(self):
         # If there are more than one search result, a LookupError is still

=== modified file 'lib/lp/code/xmlrpc/tests/test_codehosting.py'
--- lib/lp/code/xmlrpc/tests/test_codehosting.py	2015-09-28 17:38:45 +0000
+++ lib/lp/code/xmlrpc/tests/test_codehosting.py	2015-10-19 11:35:18 +0000
@@ -309,7 +309,6 @@
         # Creating a branch with an invalid product name fails.
         owner = self.factory.makePerson()
         name = self.factory.getUniqueString()
-        from lp.code.interfaces.codehosting import BRANCH_ALIAS_PREFIX
         branch_name = "/%s/fiz:buzz/%s" % (BRANCH_ALIAS_PREFIX, name)
         fault = self.codehosting_api.createBranch(
             owner.id, branch_name)

=== modified file 'lib/lp/codehosting/codeimport/dispatcher.py'
--- lib/lp/codehosting/codeimport/dispatcher.py	2011-12-29 05:29:36 +0000
+++ lib/lp/codehosting/codeimport/dispatcher.py	2015-10-19 11:35:18 +0000
@@ -65,13 +65,11 @@
             [interpreter, self.worker_script, str(job_id), '-vv',
              '--log-file', log_file])
 
-
     def findAndDispatchJob(self, scheduler_client):
         """Check for and dispatch a job if necessary.
 
         :return: A boolean, true if a job was found and dispatched.
         """
-
         job_id = scheduler_client.getJobForMachine(
             self.getHostname(), self.worker_limit)
 
@@ -93,7 +91,7 @@
         We assume worker_limit will be roughly the number of CPUs in the
         machine, so load/worker_limit is roughly how loaded the machine is.
         """
-        return 5*os.getloadavg()[0]/self.worker_limit
+        return 5 * os.getloadavg()[0] / self.worker_limit
 
     def findAndDispatchJobs(self, scheduler_client):
         """Call findAndDispatchJob until no job is found."""

=== modified file 'lib/lp/codehosting/codeimport/tests/test_dispatcher.py'
--- lib/lp/codehosting/codeimport/tests/test_dispatcher.py	2012-01-06 11:08:30 +0000
+++ lib/lp/codehosting/codeimport/tests/test_dispatcher.py	2015-10-19 11:35:18 +0000
@@ -86,8 +86,8 @@
             arg for arg in arglist if not arg.startswith('--log-file=')]
         while '--log-file' in arglist:
             index = arglist.index('--log-file')
-            del arglist[index] # Delete the argument
-            del arglist[index] # And its parameter
+            del arglist[index]  # Delete the argument
+            del arglist[index]  # And its parameter
 
         parser = OptionParser()
         scripts.logger_options(parser)
@@ -158,10 +158,12 @@
         # returned by _getSleepInterval.
         sleep_calls = []
         interval = self.factory.getUniqueInteger()
+
         def _sleep(delay):
             sleep_calls.append(delay)
+
         dispatcher = self.makeDispatcher(_sleep=_sleep)
         dispatcher.dispatchJob = lambda job_id: None
-        dispatcher._getSleepInterval = lambda : interval
+        dispatcher._getSleepInterval = lambda: interval
         dispatcher.findAndDispatchJobs(StubSchedulerClient([10, 0]))
         self.assertEqual([interval], sleep_calls)

=== modified file 'lib/lp/codehosting/puller/__init__.py'
--- lib/lp/codehosting/puller/__init__.py	2012-06-29 08:40:05 +0000
+++ lib/lp/codehosting/puller/__init__.py	2015-10-19 11:35:18 +0000
@@ -43,4 +43,3 @@
     deferred.addCallback(recordSuccess)
     deferred.addBoth(unlock)
     return deferred
-

=== modified file 'lib/lp/codehosting/scanner/__init__.py'
--- lib/lp/codehosting/scanner/__init__.py	2007-11-05 20:37:08 +0000
+++ lib/lp/codehosting/scanner/__init__.py	2015-10-19 11:35:18 +0000
@@ -1,1 +0,0 @@
-

=== modified file 'lib/lp/codehosting/scripts/modifiedbranches.py'
--- lib/lp/codehosting/scripts/modifiedbranches.py	2012-06-29 08:40:05 +0000
+++ lib/lp/codehosting/scripts/modifiedbranches.py	2015-10-19 11:35:18 +0000
@@ -127,4 +127,3 @@
             print location
 
         self.logger.info("Done.")
-

=== modified file 'lib/lp/codehosting/sftp.py'
--- lib/lp/codehosting/sftp.py	2015-07-08 16:05:11 +0000
+++ lib/lp/codehosting/sftp.py	2015-10-19 11:35:18 +0000
@@ -189,8 +189,10 @@
         """See `ISFTPFile`."""
         deferred = self.transport.readv(
             self._escaped_path, [(offset, length)])
+
         def get_first_chunk(read_things):
             return read_things.next()[1]
+
         def handle_short_read(failure):
             """Handle short reads by reading what was available.
 
@@ -202,6 +204,7 @@
             """
             failure.trap(bzr_errors.ShortReadvError)
             return self.readChunk(failure.value.offset, failure.value.actual)
+
         deferred.addCallback(get_first_chunk)
         return deferred.addErrback(handle_short_read)
 
@@ -228,9 +231,11 @@
             return self._truncateFile()
 
         deferred = self.transport.has(self._escaped_path)
+
         def maybe_create_file(already_exists):
             if not already_exists:
                 return self._truncateFile()
+
         return deferred.addCallback(maybe_create_file)
 
 
@@ -307,11 +312,13 @@
         """See `ISFTPServer`."""
         escaped_path = urlutils.escape(path)
         deferred = self.transport.list_dir(escaped_path)
+
         def produce_entries_from_file_list(file_list):
             stats_deferred = self._stat_files_in_list(file_list, escaped_path)
             stats_deferred.addCallback(
                 self._format_directory_entries, file_list)
             return stats_deferred
+
         return deferred.addCallback(
             produce_entries_from_file_list).addCallback(DirectoryListing)
 
@@ -320,12 +327,14 @@
         """See `ISFTPServer`."""
         directory = os.path.dirname(path)
         deferred = self.transport.stat(directory)
+
         def open_file(stat_result):
             if stat.S_ISDIR(stat_result.st_mode):
                 return TransportSFTPFile(self.transport, path, flags, self)
             else:
                 raise filetransfer.SFTPError(
                     filetransfer.FX_NO_SUCH_FILE, directory)
+
         return deferred.addCallback(open_file)
 
     def readLink(self, path):
@@ -335,9 +344,11 @@
     def realPath(self, relpath):
         """See `ISFTPServer`."""
         deferred = self.transport.local_realPath(urlutils.escape(relpath))
+
         def unescape_path(path):
             unescaped_path = urlutils.unescape(path)
             return unescaped_path.encode('utf-8')
+
         return deferred.addCallback(unescape_path)
 
     def setAttrs(self, path, attrs):

=== modified file 'lib/lp/codehosting/sshserver/session.py'
--- lib/lp/codehosting/sshserver/session.py	2015-07-08 16:05:11 +0000
+++ lib/lp/codehosting/sshserver/session.py	2015-10-19 11:35:18 +0000
@@ -140,7 +140,7 @@
 
         :return: The pid, communication directory, and request socket.
         """
-        assert executable == 'bzr', executable # Maybe .endswith()
+        assert executable == 'bzr', executable  # Maybe .endswith()
         assert args[0] == 'bzr', args[0]
         message = ['fork-env %s\n' % (' '.join(args[1:]),)]
         for key, value in environment.iteritems():

=== modified file 'lib/lp/codehosting/tests/test_format_comparison.py'
--- lib/lp/codehosting/tests/test_format_comparison.py	2011-08-12 11:19:40 +0000
+++ lib/lp/codehosting/tests/test_format_comparison.py	2015-10-19 11:35:18 +0000
@@ -9,23 +9,29 @@
 
 from lp.codehosting.bzrutils import identical_formats
 
+
 # Define a bunch of different fake format classes to pass to identical_formats
 
 class BzrDirFormatA:
     pass
 
+
 class BzrDirFormatB:
     pass
 
+
 class BranchFormatA:
     pass
 
+
 class BranchFormatB:
     pass
 
+
 class RepoFormatA:
     pass
 
+
 class RepoFormatB:
     pass
 

=== modified file 'lib/lp/codehosting/vfs/tests/test_branchfsclient.py'
--- lib/lp/codehosting/vfs/tests/test_branchfsclient.py	2015-05-26 12:40:44 +0000
+++ lib/lp/codehosting/vfs/tests/test_branchfsclient.py	2015-10-19 11:35:18 +0000
@@ -121,7 +121,7 @@
         fake_data = self.factory.getUniqueString()
         client._addToCache(
             (BRANCH_TRANSPORT, fake_data, ''), '/%s' % branch.unique_name)
-        self.advanceTime(expiry_time/2)
+        self.advanceTime(expiry_time / 2)
         result = client._getFromCache('/%s/foo/bar' % branch.unique_name)
         self.assertEqual(
             (BRANCH_TRANSPORT, fake_data, 'foo/bar'), result)
@@ -136,7 +136,7 @@
         fake_data = self.factory.getUniqueString()
         client._addToCache(
             (BRANCH_TRANSPORT, fake_data, ''), '/%s' % branch.unique_name)
-        self.advanceTime(expiry_time*2)
+        self.advanceTime(expiry_time * 2)
         self.assertRaises(NotInCache, client._getFromCache,
                           '/%s/foo/bar' % branch.unique_name)
 
@@ -172,10 +172,12 @@
             (BRANCH_TRANSPORT, fake_data, ''), '/%s' % branch.unique_name)
         requested_path = '/%s/foo/bar' % branch.unique_name
         deferred = client.translatePath(requested_path)
+
         def path_translated((transport_type, data, trailing_path)):
             self.assertEqual(BRANCH_TRANSPORT, transport_type)
             self.assertEqual(fake_data, data)
             self.assertEqual('foo/bar', trailing_path)
+
         return deferred.addCallback(path_translated)
 
     def test_translatePath_adds_to_cache(self):
@@ -198,10 +200,13 @@
         deferred = client.translatePath(
             '/~' + branch.owner.name + '/' + branch.product.name +
             '/.bzr/format')
+
         def call_translatePath_again(ignored):
             return client.translatePath('/' + branch.unique_name)
+
         def check_results((transport_type, data, trailing_path)):
             self.assertEqual(BRANCH_TRANSPORT, transport_type)
+
         deferred.addCallback(call_translatePath_again)
         deferred.addCallback(check_results)
         return deferred
@@ -210,12 +215,15 @@
         # Don't cache failed translations. What would be the point?
         client = self.makeClient()
         deferred = client.translatePath('/foo/bar/baz')
+
         def translated_successfully(result):
             self.fail(
                 "Translated successfully. Expected error, got %r" % result)
+
         def failed_translation(failure):
             self.assertRaises(
                 NotInCache, client._getFromCache, '/foo/bar/baz')
+
         return deferred.addCallbacks(
             translated_successfully, failed_translation)
 

=== modified file 'lib/lp/codehosting/vfs/transport.py'
--- lib/lp/codehosting/vfs/transport.py	2013-01-07 03:29:28 +0000
+++ lib/lp/codehosting/vfs/transport.py	2015-10-19 11:35:18 +0000
@@ -100,7 +100,7 @@
         """Return the absolute, escaped path to `relpath` without the schema.
         """
         return urlutils.joinpath(
-            self.base[len(self.server.get_url())-1:], relpath)
+            self.base[len(self.server.get_url()) - 1:], relpath)
 
     def _getUnderylingTransportAndPath(self, relpath):
         """Return the underlying transport and path for `relpath`."""
@@ -176,17 +176,21 @@
 
     def iter_files_recursive(self):
         deferred = self._getUnderylingTransportAndPath('.')
+
         @no_traceback_failures
         def iter_files((transport, path)):
             return transport.clone(path).iter_files_recursive()
+
         deferred.addCallback(iter_files)
         return deferred
 
     def listable(self):
         deferred = self._getUnderylingTransportAndPath('.')
+
         @no_traceback_failures
         def listable((transport, path)):
             return transport.listable()
+
         deferred.addCallback(listable)
         return deferred
 


Follow ups