← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cjwatson/launchpad:pre-commit-isort into launchpad:master

 

Colin Watson has proposed merging ~cjwatson/launchpad:pre-commit-isort into launchpad:master.

Commit message:
Run isort from pre-commit

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

For more details, see:
https://code.launchpad.net/~cjwatson/launchpad/+git/launchpad/+merge/406756

Let's never have to run format-imports by hand again.
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cjwatson/launchpad:pre-commit-isort into launchpad:master.
diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml
index 602c06d..f0e3a44 100644
--- a/.pre-commit-config.yaml
+++ b/.pre-commit-config.yaml
@@ -26,3 +26,7 @@ repos:
     hooks:
     -   id: flake8
         exclude: ^lib/contrib/
+-   repo: https://github.com/PyCQA/isort
+    rev: 5.9.2
+    hooks:
+    -   id: isort
diff --git a/_pythonpath.py b/_pythonpath.py
index eab0d63..616dcda 100644
--- a/_pythonpath.py
+++ b/_pythonpath.py
@@ -8,6 +8,7 @@ import imp
 import os.path
 import sys
 
+
 # Get path to this file.
 if __name__ == '__main__':
     filename = __file__
diff --git a/brzplugins/lpserve/__init__.py b/brzplugins/lpserve/__init__.py
index 25c53ed..39d5cf4 100644
--- a/brzplugins/lpserve/__init__.py
+++ b/brzplugins/lpserve/__init__.py
@@ -113,7 +113,10 @@ class cmd_launchpad_server(Command):
     def run(self, user_id, port=None, branch_directory=None,
             codehosting_endpoint_url=None, inet=False, protocol=None):
         from lp.codehosting.bzrutils import install_oops_handler
-        from lp.codehosting.vfs import get_lp_server, hooks
+        from lp.codehosting.vfs import (
+            get_lp_server,
+            hooks,
+            )
         install_oops_handler(user_id)
         four_gig = int(4e9)
         resource.setrlimit(resource.RLIMIT_AS, (four_gig, four_gig))
diff --git a/configs/test-playground/gunicorn.conf.py b/configs/test-playground/gunicorn.conf.py
index ba22ec1..85fc029 100644
--- a/configs/test-playground/gunicorn.conf.py
+++ b/configs/test-playground/gunicorn.conf.py
@@ -1,4 +1,6 @@
 import os
+
+
 config_dir = os.path.dirname(__file__)
 log_dir = os.path.join(config_dir, '..', '..', 'logs')
 
diff --git a/configs/testrunner-appserver/gunicorn.conf.py b/configs/testrunner-appserver/gunicorn.conf.py
index ba22ec1..85fc029 100644
--- a/configs/testrunner-appserver/gunicorn.conf.py
+++ b/configs/testrunner-appserver/gunicorn.conf.py
@@ -1,4 +1,6 @@
 import os
+
+
 config_dir = os.path.dirname(__file__)
 log_dir = os.path.join(config_dir, '..', '..', 'logs')
 
diff --git a/configs/testrunner/gunicorn.conf.py b/configs/testrunner/gunicorn.conf.py
index ba22ec1..85fc029 100644
--- a/configs/testrunner/gunicorn.conf.py
+++ b/configs/testrunner/gunicorn.conf.py
@@ -1,4 +1,6 @@
 import os
+
+
 config_dir = os.path.dirname(__file__)
 log_dir = os.path.join(config_dir, '..', '..', 'logs')
 
diff --git a/daemons/buildd-manager.tac b/daemons/buildd-manager.tac
index 06f99e5..2612d9a 100644
--- a/daemons/buildd-manager.tac
+++ b/daemons/buildd-manager.tac
@@ -9,17 +9,18 @@ import resource
 from twisted.application import service
 from twisted.scripts.twistd import ServerOptions
 
+from lp.buildmaster.manager import BuilddManager
 from lp.services.config import (
     config,
     dbconfig,
     )
 from lp.services.daemons import readyservice
-from lp.services.scripts import execute_zcml_for_scripts
-from lp.buildmaster.manager import BuilddManager
 from lp.services.mail.sendmail import set_immediate_mail_delivery
+from lp.services.scripts import execute_zcml_for_scripts
 from lp.services.twistedsupport.features import setup_feature_controller
 from lp.services.twistedsupport.loggingsupport import RotatableFileLogObserver
 
+
 execute_zcml_for_scripts()
 dbconfig.override(dbuser='buildd_manager', isolation_level='read_committed')
 # XXX wgrant 2011-09-24 bug=29744: initZopeless used to do this.
diff --git a/daemons/distributionmirror_http_server.tac b/daemons/distributionmirror_http_server.tac
index dae6fe5..191bed0 100644
--- a/daemons/distributionmirror_http_server.tac
+++ b/daemons/distributionmirror_http_server.tac
@@ -10,9 +10,10 @@ from twisted.application import (
     )
 from twisted.web import server
 
-from lp.services.daemons import readyservice
 from lp.registry.tests.distributionmirror_http_server import (
-    DistributionMirrorTestHTTPServer)
+    DistributionMirrorTestHTTPServer,
+    )
+from lp.services.daemons import readyservice
 
 
 application = service.Application('DistributionMirrorTestHTTPServer')
diff --git a/daemons/librarian.tac b/daemons/librarian.tac
index 4440621..a09f873 100644
--- a/daemons/librarian.tac
+++ b/daemons/librarian.tac
@@ -7,6 +7,7 @@
 import os
 import signal
 
+
 # Turn off the http_proxy environment variable if it is set. We
 # don't need it, but we do need to contact Keystone & Swift directly.
 # We could use no_proxy, but this requires keeping it in sync with
@@ -42,8 +43,9 @@ from lp.services.librarianserver import (
     )
 from lp.services.librarianserver.libraryprotocol import FileUploadFactory
 from lp.services.scripts import execute_zcml_for_scripts
-from lp.services.twistedsupport.loggingsupport import set_up_oops_reporting
 from lp.services.twistedsupport.features import setup_feature_controller
+from lp.services.twistedsupport.loggingsupport import set_up_oops_reporting
+
 
 # Connect to database
 dbconfig.override(
diff --git a/daemons/numbercruncher.tac b/daemons/numbercruncher.tac
index e9a7bf7..212c7f3 100644
--- a/daemons/numbercruncher.tac
+++ b/daemons/numbercruncher.tac
@@ -14,6 +14,7 @@ from lp.services.statsd.numbercruncher import NumberCruncher
 from lp.services.twistedsupport.features import setup_feature_controller
 from lp.services.twistedsupport.loggingsupport import RotatableFileLogObserver
 
+
 execute_zcml_for_scripts()
 
 options = ServerOptions()
diff --git a/daemons/sftp.tac b/daemons/sftp.tac
index 51248fe..354a55c 100644
--- a/daemons/sftp.tac
+++ b/daemons/sftp.tac
@@ -9,9 +9,6 @@ from lazr.sshserver.service import SSHService
 from twisted.application import service
 from twisted.protocols.policies import TimeoutFactory
 
-from lp.services.config import config
-from lp.services.daemons import readyservice
-
 from lp.codehosting.sshserver.daemon import (
     ACCESS_LOG_NAME,
     get_key_path,
@@ -20,6 +17,8 @@ from lp.codehosting.sshserver.daemon import (
     PRIVATE_KEY_FILE,
     PUBLIC_KEY_FILE,
     )
+from lp.services.config import config
+from lp.services.daemons import readyservice
 from lp.services.twistedsupport.gracefulshutdown import (
     ConnTrackingFactoryWrapper,
     make_web_status_service,
diff --git a/database/replication/helpers.py b/database/replication/helpers.py
index 80c33c9..8096075 100644
--- a/database/replication/helpers.py
+++ b/database/replication/helpers.py
@@ -29,6 +29,7 @@ from lp.services.scripts.logger import (
     log,
     )
 
+
 # The Slony-I clustername we use with Launchpad. Hardcoded because there
 # is no point changing this, ever.
 CLUSTERNAME = 'sl'
diff --git a/database/schema/dbcontroller.py b/database/schema/dbcontroller.py
index 77bdc22..fe0b2b2 100644
--- a/database/schema/dbcontroller.py
+++ b/database/schema/dbcontroller.py
@@ -14,6 +14,7 @@ from psycopg2.extras import NamedTupleConnection
 
 from lp.services.database.postgresql import ConnectionString
 
+
 # Increase this timeout once we are confident in the
 # implementation. We don't want to block rollouts
 # unnecessarily with slow timeouts and a flaky sync
diff --git a/database/schema/preflight.py b/database/schema/preflight.py
index a02841a..9a8d8e5 100755
--- a/database/schema/preflight.py
+++ b/database/schema/preflight.py
@@ -36,6 +36,7 @@ from lp.services.scripts import (
 from replication.helpers import Node
 import upgrade
 
+
 # Ignore connections by these users.
 SYSTEM_USERS = set(['postgres', 'slony', 'nagios', 'lagmon'])
 
diff --git a/database/schema/security.py b/database/schema/security.py
index ea62868..0c26e0e 100755
--- a/database/schema/security.py
+++ b/database/schema/security.py
@@ -24,6 +24,7 @@ from lp.services.scripts import (
     logger_options,
     )
 
+
 # The 'read' group does not get given select permission on the following
 # tables. This is to stop the ro user being given access to secrurity
 # sensitive information that interactive sessions don't need.
diff --git a/lib/contrib/apachelog.py b/lib/contrib/apachelog.py
index 20c1a3c..fc6a768 100644
--- a/lib/contrib/apachelog.py
+++ b/lib/contrib/apachelog.py
@@ -97,6 +97,7 @@ __contributors__ = [
     
 import re
 
+
 class ApacheLogParserError(Exception):
     pass
 
diff --git a/lib/contrib/glock.py b/lib/contrib/glock.py
index 69def87..542363e 100644
--- a/lib/contrib/glock.py
+++ b/lib/contrib/glock.py
@@ -29,14 +29,21 @@ __doc__ += '\n@author: %s (U{%s})\n@version: %s' % (__author__[0],
                                             __author__[1], __version__)
 __all__ = ['GlobalLock', 'GlobalLockError', 'LockAlreadyAcquired', 'NotOwner']
 
-import sys, string, os, errno, re
+import errno
+import os
+import re
+import string
+import sys
+
 
 # System-dependent imports for locking implementation:
 _windows = (sys.platform == 'win32')
 
 if _windows:
     try:
-        import win32event, win32api, pywintypes
+        import pywintypes
+        import win32api
+        import win32event
     except ImportError:
         sys.stderr.write('The win32 extensions need to be installed!')
     try:
@@ -276,7 +283,8 @@ def test():
     else: raise Exception('should have raised a NotOwner exception')
 
     # Check that <> threads of same process do block:
-    import threading, time
+    import threading
+    import time
     thread = threading.Thread(target=threadMain, args=(l,))
     print('main: locking...', end='')
     l.acquire()
diff --git a/lib/devscripts/sourcecode.py b/lib/devscripts/sourcecode.py
index d1d269f..dcd0c26 100644
--- a/lib/devscripts/sourcecode.py
+++ b/lib/devscripts/sourcecode.py
@@ -3,7 +3,11 @@
 
 """Tools for maintaining the Launchpad source code."""
 
-from __future__ import absolute_import, print_function
+from __future__ import (
+    absolute_import,
+    print_function,
+    )
+
 
 __metaclass__ = type
 __all__ = [
@@ -19,6 +23,7 @@ import os
 import shutil
 import sys
 
+
 try:
     from breezy import ui
     from breezy.branch import Branch
diff --git a/lib/devscripts/tests/test_sourcecode.py b/lib/devscripts/tests/test_sourcecode.py
index ef03676..368ea0d 100644
--- a/lib/devscripts/tests/test_sourcecode.py
+++ b/lib/devscripts/tests/test_sourcecode.py
@@ -3,7 +3,11 @@
 
 """Module docstring goes here."""
 
-from __future__ import absolute_import, print_function
+from __future__ import (
+    absolute_import,
+    print_function,
+    )
+
 
 __metaclass__ = type
 
@@ -12,6 +16,7 @@ import shutil
 import tempfile
 import unittest
 
+
 try:
     from breezy.bzr.bzrdir import BzrDir
     from breezy.tests import TestCase
@@ -20,6 +25,7 @@ except ImportError:
     from bzrlib.bzrdir import BzrDir
     from bzrlib.tests import TestCase
     from bzrlib.transport import get_transport
+
 import six
 
 from devscripts import get_launchpad_root
diff --git a/lib/launchpad_loggerhead/tests.py b/lib/launchpad_loggerhead/tests.py
index b7744e9..1c78b51 100644
--- a/lib/launchpad_loggerhead/tests.py
+++ b/lib/launchpad_loggerhead/tests.py
@@ -10,8 +10,8 @@ from six.moves.urllib_parse import (
 import soupmatchers
 from testtools.content import Content
 from testtools.content_type import UTF8_TEXT
-from zope.testbrowser.wsgi import Browser
 from zope.security.proxy import removeSecurityProxy
+from zope.testbrowser.wsgi import Browser
 
 from launchpad_loggerhead.app import RootApp
 from launchpad_loggerhead.session import SessionHandler
diff --git a/lib/lp/answers/browser/questiontarget.py b/lib/lp/answers/browser/questiontarget.py
index ef277c0..eb7aecb 100644
--- a/lib/lp/answers/browser/questiontarget.py
+++ b/lib/lp/answers/browser/questiontarget.py
@@ -757,8 +757,7 @@ class ManageAnswerContactView(UserSupportLanguagesMixin, LaunchpadFormView):
 
     @property
     def administrated_teams(self):
-        from lp.registry.browser.person import (
-            RestrictedMembershipsPersonView)
+        from lp.registry.browser.person import RestrictedMembershipsPersonView
         restricted_view = RestrictedMembershipsPersonView(self.user,
                                                           self.request)
         return restricted_view.administrated_teams
diff --git a/lib/lp/answers/model/question.py b/lib/lp/answers/model/question.py
index f03ed40..df90995 100644
--- a/lib/lp/answers/model/question.py
+++ b/lib/lp/answers/model/question.py
@@ -785,8 +785,8 @@ class QuestionSet:
     def getMostActiveProjects(self, limit=5):
         """See `IQuestionSet`."""
 
-        from lp.registry.model.product import Product
         from lp.registry.model.distribution import Distribution
+        from lp.registry.model.product import Product
 
         time_cutoff = datetime.now(pytz.UTC) - timedelta(days=60)
         question_count = Alias(Count())
@@ -1406,7 +1406,9 @@ class QuestionTargetMixin:
         them.
         """
         from lp.registry.model.person import (
-            Person, PersonLanguage)
+            Person,
+            PersonLanguage,
+            )
         origin = [
             AnswerContact,
             LeftJoin(Person, AnswerContact.person == Person.id),
@@ -1459,7 +1461,10 @@ class QuestionTargetMixin:
 
     def getAnswerContactsForLanguage(self, language):
         """See `IQuestionTarget`."""
-        from lp.registry.model.person import PersonLanguage, Person
+        from lp.registry.model.person import (
+            Person,
+            PersonLanguage,
+            )
         assert language is not None, (
             "The language cannot be None when selecting answer contacts.")
         query = []
diff --git a/lib/lp/answers/model/questionreopening.py b/lib/lp/answers/model/questionreopening.py
index 9149006..df9d1ee 100644
--- a/lib/lp/answers/model/questionreopening.py
+++ b/lib/lp/answers/model/questionreopening.py
@@ -8,8 +8,8 @@ __metaclass__ = type
 __all__ = ['QuestionReopening',
            'create_questionreopening']
 
-import pytz
 from lazr.lifecycle.event import ObjectCreatedEvent
+import pytz
 from storm.locals import (
     DateTime,
     Int,
diff --git a/lib/lp/app/__init__.py b/lib/lp/app/__init__.py
index 7006d36..5f5419e 100644
--- a/lib/lp/app/__init__.py
+++ b/lib/lp/app/__init__.py
@@ -15,8 +15,10 @@ __all__ = []
 # values, but they kindly left this global variable for you to monkey patch if
 # you want the old behaviour, just like we do.
 from zope.formlib import itemswidgets
+
 # Load versioninfo.py so that we get errors on start-up rather than waiting
 # for first page load.
 import lp.app.versioninfo  # noqa: F401
 
+
 itemswidgets.EXPLICIT_EMPTY_SELECTION = False
diff --git a/lib/lp/app/browser/root.py b/lib/lp/app/browser/root.py
index 83aa4e5..18d9581 100644
--- a/lib/lp/app/browser/root.py
+++ b/lib/lp/app/browser/root.py
@@ -43,8 +43,8 @@ from lp.services.features import getFeatureFlag
 from lp.services.memcache.interfaces import IMemcacheClient
 from lp.services.propertycache import cachedproperty
 from lp.services.sitesearch.interfaces import (
-    SiteSearchResponseError,
     active_search_service,
+    SiteSearchResponseError,
     )
 from lp.services.statistics.interfaces.statistic import ILaunchpadStatisticSet
 from lp.services.timeout import urlfetch
diff --git a/lib/lp/app/browser/tests/test_launchpad.py b/lib/lp/app/browser/tests/test_launchpad.py
index b170634..4df70c5 100644
--- a/lib/lp/app/browser/tests/test_launchpad.py
+++ b/lib/lp/app/browser/tests/test_launchpad.py
@@ -45,8 +45,8 @@ from lp.testing import (
     admin_logged_in,
     ANONYMOUS,
     celebrity_logged_in,
-    login_person,
     login,
+    login_person,
     person_logged_in,
     TestCaseWithFactory,
     )
@@ -57,6 +57,7 @@ from lp.testing.layers import (
 from lp.testing.publication import test_traverse
 from lp.testing.views import create_view
 
+
 # We set the request header HTTP_REFERER  when we want to simulate navigation
 # from a valid page. This is used in the assertDisplaysNotification check.
 DEFAULT_REFERER = 'http://launchpad.test'
diff --git a/lib/lp/app/browser/vocabulary.py b/lib/lp/app/browser/vocabulary.py
index e107cb1..f92c7a5 100644
--- a/lib/lp/app/browser/vocabulary.py
+++ b/lib/lp/app/browser/vocabulary.py
@@ -54,6 +54,7 @@ from lp.services.webapp.publisher import canonical_url
 from lp.services.webapp.vocabulary import IHugeVocabulary
 from lp.soyuz.interfaces.archive import IArchive
 
+
 # XXX: EdwinGrubbs 2009-07-27 bug=405476
 # This limits the output to one line of text, since the sprite class
 # cannot clip the background image effectively for vocabulary items
diff --git a/lib/lp/app/tests/test_help.py b/lib/lp/app/tests/test_help.py
index e4ef38a..0d6b167 100644
--- a/lib/lp/app/tests/test_help.py
+++ b/lib/lp/app/tests/test_help.py
@@ -13,6 +13,7 @@ from lp.services.webapp.interfaces import ILaunchpadApplication
 from lp.testing.layers import FunctionalLayer
 from lp.testing.systemdocs import create_view
 
+
 # The root of the tree
 ROOT = os.path.realpath(
         os.path.join(
diff --git a/lib/lp/app/validators/tests/test_validators.py b/lib/lp/app/validators/tests/test_validators.py
index cb11eea..b47ea3c 100644
--- a/lib/lp/app/validators/tests/test_validators.py
+++ b/lib/lp/app/validators/tests/test_validators.py
@@ -29,7 +29,14 @@ def test_suite():
     suite.addTest(
         DocTestSuite(validators, optionflags=ELLIPSIS | NORMALIZE_WHITESPACE))
 
-    from lp.app.validators import cve, email, name, url, username, version
+    from lp.app.validators import (
+        cve,
+        email,
+        name,
+        url,
+        username,
+        version,
+        )
     suite.addTest(suitefor(cve))
     suite.addTest(suitefor(email))
     suite.addTest(suitefor(name))
diff --git a/lib/lp/archivepublisher/debversion.py b/lib/lp/archivepublisher/debversion.py
index ea0321e..8f45ad3 100644
--- a/lib/lp/archivepublisher/debversion.py
+++ b/lib/lp/archivepublisher/debversion.py
@@ -16,6 +16,7 @@ import re
 
 from debian import changelog
 
+
 # Regular expressions make validating things easy
 valid_epoch = re.compile(r'^[0-9]+$')
 valid_upstream = re.compile(r'^[0-9][A-Za-z0-9+:.~-]*$')
diff --git a/lib/lp/archivepublisher/domination.py b/lib/lp/archivepublisher/domination.py
index dc6f1cf..42b11a1 100644
--- a/lib/lp/archivepublisher/domination.py
+++ b/lib/lp/archivepublisher/domination.py
@@ -99,6 +99,7 @@ from lp.soyuz.model.publishing import (
     )
 from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
 
+
 # Days before a package will be removed from disk.
 STAY_OF_EXECUTION = 1
 
diff --git a/lib/lp/archivepublisher/publishing.py b/lib/lp/archivepublisher/publishing.py
index 301e526..0975176 100644
--- a/lib/lp/archivepublisher/publishing.py
+++ b/lib/lp/archivepublisher/publishing.py
@@ -98,6 +98,7 @@ from lp.soyuz.model.publishing import (
     SourcePackagePublishingHistory,
     )
 
+
 # Use this as the lock file name for all scripts that may manipulate
 # archives in the filesystem.  In a Launchpad(Cron)Script, set
 # lockfilename to this value to make it use the shared lock.
diff --git a/lib/lp/archiveuploader/tests/test_utils.py b/lib/lp/archiveuploader/tests/test_utils.py
index d14cad0..03ed90e 100755
--- a/lib/lp/archiveuploader/tests/test_utils.py
+++ b/lib/lp/archiveuploader/tests/test_utils.py
@@ -230,9 +230,7 @@ class TestUtilities(TestCase):
         """lp.archiveuploader.utils.parse_maintainer should raise on incorrect
            values
         """
-        from lp.archiveuploader.utils import (
-            parse_maintainer_bytes,
-            )
+        from lp.archiveuploader.utils import parse_maintainer_bytes
 
         cases = (
             ("James Troup",
diff --git a/lib/lp/archiveuploader/uploadpolicy.py b/lib/lp/archiveuploader/uploadpolicy.py
index e7e2f8d..c91e830 100644
--- a/lib/lp/archiveuploader/uploadpolicy.py
+++ b/lib/lp/archiveuploader/uploadpolicy.py
@@ -34,6 +34,7 @@ from lp.registry.interfaces.pocket import PackagePublishingPocket
 from lp.registry.interfaces.series import SeriesStatus
 from lp.soyuz.enums import ArchivePurpose
 
+
 # Number of seconds in an hour (used later)
 HOURS = 3600
 
diff --git a/lib/lp/blueprints/model/specification.py b/lib/lp/blueprints/model/specification.py
index 58d57e8..21032d9 100644
--- a/lib/lp/blueprints/model/specification.py
+++ b/lib/lp/blueprints/model/specification.py
@@ -114,7 +114,8 @@ from lp.services.xref.interfaces import IXRefSet
 
 def recursive_blocked_query(user):
     from lp.blueprints.model.specificationsearch import (
-        get_specification_privacy_filter)
+        get_specification_privacy_filter,
+        )
     return """
         RECURSIVE blocked(id) AS (
             SELECT ?
@@ -129,7 +130,8 @@ def recursive_blocked_query(user):
 
 def recursive_dependent_query(user):
     from lp.blueprints.model.specificationsearch import (
-        get_specification_privacy_filter)
+        get_specification_privacy_filter,
+        )
     return """
         RECURSIVE dependencies(id) AS (
             SELECT ?
@@ -265,7 +267,8 @@ class Specification(SQLBase, BugLinkTargetMixin, InformationTypeMixin):
 
     def _fetch_children_or_parents(self, join_cond, cond, user):
         from lp.blueprints.model.specificationsearch import (
-            get_specification_privacy_filter)
+            get_specification_privacy_filter,
+            )
         return list(Store.of(self).using(
             Specification,
             Join(SpecificationDependency, join_cond == self.id)).find(
@@ -820,7 +823,8 @@ class Specification(SQLBase, BugLinkTargetMixin, InformationTypeMixin):
     def linkSprint(self, sprint, user):
         """See ISpecification."""
         from lp.blueprints.model.sprintspecification import (
-            SprintSpecification)
+            SprintSpecification,
+            )
         for sprint_link in self.sprint_links:
             # sprints have unique names
             if sprint_link.sprint.name == sprint.name:
@@ -953,7 +957,8 @@ class Specification(SQLBase, BugLinkTargetMixin, InformationTypeMixin):
         """See `ISpecification`."""
         # Avoid circular imports.
         from lp.blueprints.model.specificationsearch import (
-            get_specification_privacy_filter)
+            get_specification_privacy_filter,
+            )
         if self.information_type in PUBLIC_INFORMATION_TYPES:
             return True
         if user is None:
@@ -1043,7 +1048,8 @@ class SpecificationSet(HasSpecificationsMixin):
                        need_people=True, need_branches=True,
                        need_workitems=False):
         from lp.blueprints.model.specificationsearch import (
-            search_specifications)
+            search_specifications,
+            )
         return search_specifications(
             self, [], user, sort, quantity, filter, need_people=need_people,
             need_branches=need_branches, need_workitems=need_workitems)
diff --git a/lib/lp/bugs/adapters/bugchange.py b/lib/lp/bugs/adapters/bugchange.py
index ceb0272..fb104fa 100644
--- a/lib/lp/bugs/adapters/bugchange.py
+++ b/lib/lp/bugs/adapters/bugchange.py
@@ -64,6 +64,7 @@ from lp.registry.interfaces.product import IProduct
 from lp.services.librarian.browser import ProxiedLibraryFileAlias
 from lp.services.webapp.publisher import canonical_url
 
+
 # These are used lp.bugs.model.bugactivity.BugActivity.attribute to normalize
 # the output from these change objects into the attribute that actually
 # changed.  It is fragile, but a reasonable incremental step.
diff --git a/lib/lp/bugs/browser/bug.py b/lib/lp/bugs/browser/bug.py
index b1909e7..db87dc8 100644
--- a/lib/lp/bugs/browser/bug.py
+++ b/lib/lp/bugs/browser/bug.py
@@ -912,7 +912,7 @@ class BugSecrecyEditView(LaunchpadFormView, BugSubscriptionPortletDetails):
             from lp.bugs.browser.bugtask import (
                 can_add_package_task_to_bug,
                 can_add_project_task_to_bug,
-            )
+                )
             if changed:
                 result_data = self._getSubscriptionDetails()
                 result_data['can_add_project_task'] = (
@@ -1150,7 +1150,9 @@ class BugTextView(LaunchpadView):
             return message
 
         from lp.bugs.browser.bugtask import (
-            get_visible_comments, get_comments_for_bugtask)
+            get_comments_for_bugtask,
+            get_visible_comments,
+            )
 
         # XXX: kiko 2007-10-31: for some reason, get_comments_for_bugtask
         # takes a task, not a bug. For now live with it.
diff --git a/lib/lp/bugs/browser/bugtarget.py b/lib/lp/bugs/browser/bugtarget.py
index e33cc11..e355b57 100644
--- a/lib/lp/bugs/browser/bugtarget.py
+++ b/lib/lp/bugs/browser/bugtarget.py
@@ -147,6 +147,7 @@ from lp.services.webapp.authorization import check_permission
 from lp.services.webapp.batching import BatchNavigator
 from lp.services.webapp.escaping import structured
 
+
 # A simple vocabulary for the subscribe_to_existing_bug form field.
 SUBSCRIBE_TO_BUG_VOCABULARY = SimpleVocabulary.fromItems(
     [('yes', True), ('no', False)])
diff --git a/lib/lp/bugs/browser/bugtracker.py b/lib/lp/bugs/browser/bugtracker.py
index 88ca12b..4ba744b 100644
--- a/lib/lp/bugs/browser/bugtracker.py
+++ b/lib/lp/bugs/browser/bugtracker.py
@@ -77,6 +77,7 @@ from lp.services.webapp.breadcrumb import Breadcrumb
 from lp.services.webapp.interfaces import ILaunchBag
 from lp.services.webapp.menu import NavigationMenu
 
+
 # A set of bug tracker types for which there can only ever be one bug
 # tracker.
 SINGLE_INSTANCE_TRACKERS = (
diff --git a/lib/lp/bugs/externalbugtracker/base.py b/lib/lp/bugs/externalbugtracker/base.py
index 52300fb..b908b0c 100644
--- a/lib/lp/bugs/externalbugtracker/base.py
+++ b/lib/lp/bugs/externalbugtracker/base.py
@@ -45,11 +45,12 @@ from lp.bugs.interfaces.externalbugtracker import (
 from lp.services.config import config
 from lp.services.database.isolation import ensure_no_transaction
 from lp.services.timeout import (
-    raise_for_status_redacted,
     override_timeout,
+    raise_for_status_redacted,
     urlfetch,
     )
 
+
 # The user agent we send in our requests
 LP_USER_AGENT = "Launchpad Bugscraper/0.2 (https://bugs.launchpad.net/)"
 
diff --git a/lib/lp/bugs/externalbugtracker/trac.py b/lib/lp/bugs/externalbugtracker/trac.py
index 3bb303a..6fdc2ef 100644
--- a/lib/lp/bugs/externalbugtracker/trac.py
+++ b/lib/lp/bugs/externalbugtracker/trac.py
@@ -50,6 +50,7 @@ from lp.services.timeout import (
     )
 from lp.services.webapp.url import urlappend
 
+
 # Symbolic constants used for the Trac LP plugin.
 LP_PLUGIN_BUG_IDS_ONLY = 0
 LP_PLUGIN_METADATA_ONLY = 1
diff --git a/lib/lp/bugs/externalbugtracker/xmlrpc.py b/lib/lp/bugs/externalbugtracker/xmlrpc.py
index d82f03a..f9f71f4 100644
--- a/lib/lp/bugs/externalbugtracker/xmlrpc.py
+++ b/lib/lp/bugs/externalbugtracker/xmlrpc.py
@@ -32,6 +32,7 @@ from lp.services.timeout import (
     )
 from lp.services.utils import traceback_info
 
+
 # Protect against various XML parsing vulnerabilities.
 monkey_patch()
 
diff --git a/lib/lp/bugs/interfaces/bug.py b/lib/lp/bugs/interfaces/bug.py
index 5fde710..907a2c7 100644
--- a/lib/lp/bugs/interfaces/bug.py
+++ b/lib/lp/bugs/interfaces/bug.py
@@ -1029,7 +1029,9 @@ patch_collection_property(ICve, 'bugs', IBug)
 # In order to avoid circular dependencies, we only import
 # IBugSubscription (which itself imports IBug) here, and assign it as
 # the value type for the `subscriptions` collection.
-from lp.bugs.interfaces.bugsubscription import IBugSubscription # noqa: E402
+from lp.bugs.interfaces.bugsubscription import IBugSubscription  # noqa: E402
+
+
 patch_collection_property(IBug, 'subscriptions', IBugSubscription)
 
 
diff --git a/lib/lp/bugs/interfaces/bugsubscription.py b/lib/lp/bugs/interfaces/bugsubscription.py
index 3913944..d4b1870 100644
--- a/lib/lp/bugs/interfaces/bugsubscription.py
+++ b/lib/lp/bugs/interfaces/bugsubscription.py
@@ -86,5 +86,7 @@ class IBugSubscription(Interface):
 # In order to avoid circular dependencies, we only import
 # IBug (which itself imports IBugSubscription) here, and assign it as
 # the value type for the `bug` reference.
-from lp.bugs.interfaces.bug import IBug # noqa: E402
+from lp.bugs.interfaces.bug import IBug  # noqa: E402
+
+
 patch_reference_property(IBugSubscription, 'bug', IBug)
diff --git a/lib/lp/bugs/interfaces/bugtasksearch.py b/lib/lp/bugs/interfaces/bugtasksearch.py
index 37b3b5b..1170091 100644
--- a/lib/lp/bugs/interfaces/bugtasksearch.py
+++ b/lib/lp/bugs/interfaces/bugtasksearch.py
@@ -248,8 +248,7 @@ class BugTaskSearchParams:
     def setSourcePackage(self, sourcepackage):
         """Set the sourcepackage context on which to filter the search."""
         # Import this here to avoid circular dependencies
-        from lp.registry.interfaces.sourcepackage import (
-            ISourcePackage)
+        from lp.registry.interfaces.sourcepackage import ISourcePackage
         if isinstance(sourcepackage, any):
             # Unwrap the source package.
             self.sourcepackagename = any(*[
@@ -300,15 +299,16 @@ class BugTaskSearchParams:
         """
         # Yay circular deps.
         from lp.registry.interfaces.distribution import IDistribution
+        from lp.registry.interfaces.distributionsourcepackage import (
+            IDistributionSourcePackage,
+            )
         from lp.registry.interfaces.distroseries import IDistroSeries
+        from lp.registry.interfaces.milestone import IMilestone
+        from lp.registry.interfaces.ociproject import IOCIProject
         from lp.registry.interfaces.product import IProduct
         from lp.registry.interfaces.productseries import IProductSeries
-        from lp.registry.interfaces.milestone import IMilestone
         from lp.registry.interfaces.projectgroup import IProjectGroup
         from lp.registry.interfaces.sourcepackage import ISourcePackage
-        from lp.registry.interfaces.distributionsourcepackage import \
-            IDistributionSourcePackage
-        from lp.registry.interfaces.ociproject import IOCIProject
         if isinstance(target, (any, all)):
             assert len(target.query_values), \
                 'cannot determine target with no targets'
@@ -389,8 +389,7 @@ class BugTaskSearchParams:
         search_params.ociproject = ociproject
         if has_patch:
             # Import this here to avoid circular imports
-            from lp.bugs.interfaces.bugattachment import (
-                BugAttachmentType)
+            from lp.bugs.interfaces.bugattachment import BugAttachmentType
             search_params.attachmenttype = BugAttachmentType.PATCH
         search_params.has_cve = has_cve
         if zope_isinstance(tags, (list, tuple)):
diff --git a/lib/lp/bugs/interfaces/externalbugtracker.py b/lib/lp/bugs/interfaces/externalbugtracker.py
index 80689b5..9f1eba0 100644
--- a/lib/lp/bugs/interfaces/externalbugtracker.py
+++ b/lib/lp/bugs/interfaces/externalbugtracker.py
@@ -18,6 +18,7 @@ __all__ = [
 
 from zope.interface import Interface
 
+
 # This is a text string which indicates that the remote status is
 # unknown for some reason.
 # XXX: Bjorn Tillenius 2006-04-06:
diff --git a/lib/lp/bugs/model/bugsubscriptionfilter.py b/lib/lp/bugs/model/bugsubscriptionfilter.py
index 3e83aa3..20f0982 100644
--- a/lib/lp/bugs/model/bugsubscriptionfilter.py
+++ b/lib/lp/bugs/model/bugsubscriptionfilter.py
@@ -228,7 +228,9 @@ class BugSubscriptionFilter(StormBase):
 
     @classmethod
     def deleteMultiple(cls, ids):
-        from lp.bugs.model.structuralsubscription import StructuralSubscription
+        from lp.bugs.model.structuralsubscription import (
+            StructuralSubscription,
+            )
         store = IStore(BugSubscriptionFilter)
         structsub_ids = list(
             store.find(
diff --git a/lib/lp/bugs/model/bugtask.py b/lib/lp/bugs/model/bugtask.py
index 7e88a9d..de2bcd1 100644
--- a/lib/lp/bugs/model/bugtask.py
+++ b/lib/lp/bugs/model/bugtask.py
@@ -1395,7 +1395,10 @@ class BugTaskSet:
     def getBugTaskTags(self, bugtasks):
         """See `IBugTaskSet`"""
         # Import locally to avoid circular imports.
-        from lp.bugs.model.bug import Bug, BugTag
+        from lp.bugs.model.bug import (
+            Bug,
+            BugTag,
+            )
         bugtask_ids = set(bugtask.id for bugtask in bugtasks)
         bug_ids = set(bugtask.bug_id for bugtask in bugtasks)
         tags = IStore(BugTag).find(
@@ -1511,12 +1514,12 @@ class BugTaskSet:
             claim they were inefficient and unwanted.
         """
         # Prevent circular import problems.
+        from lp.bugs.model.bug import Bug
+        from lp.bugs.model.bugtasksearch import search_bugs
         from lp.registry.model.distribution import Distribution
         from lp.registry.model.distroseries import DistroSeries
         from lp.registry.model.product import Product
         from lp.registry.model.productseries import ProductSeries
-        from lp.bugs.model.bug import Bug
-        from lp.bugs.model.bugtasksearch import search_bugs
         _noprejoins = kwargs.get('_noprejoins', False)
         if _noprejoins:
             eager_load = None
diff --git a/lib/lp/bugs/model/structuralsubscription.py b/lib/lp/bugs/model/structuralsubscription.py
index cc67326..36d516d 100644
--- a/lib/lp/bugs/model/structuralsubscription.py
+++ b/lib/lp/bugs/model/structuralsubscription.py
@@ -158,7 +158,8 @@ class StructuralSubscription(Storm):
             if self.sourcepackagename is not None:
                 # Circular imports.
                 from lp.registry.model.distributionsourcepackage import (
-                    DistributionSourcePackage)
+                    DistributionSourcePackage,
+                    )
                 return DistributionSourcePackage(
                     self.distribution, self.sourcepackagename)
             else:
@@ -707,6 +708,7 @@ def _get_structural_subscription_filter_id_query(
     """
     # Circular. :-(
     from lp.bugs.model.bugtasksearch import get_bug_bulk_privacy_filter_terms
+
     # We get the ids because we need to use group by in order to
     # look at the filters' tags in aggregate.  Once we have the ids,
     # we can get the full set of what we need in subsuming or
diff --git a/lib/lp/bugs/scripts/bugexport.py b/lib/lp/bugs/scripts/bugexport.py
index de9fb66..70e340c 100644
--- a/lib/lp/bugs/scripts/bugexport.py
+++ b/lib/lp/bugs/scripts/bugexport.py
@@ -10,6 +10,7 @@ __all__ = [
 import base64
 import sys
 
+
 try:
     import xml.etree.cElementTree as ET
 except ImportError:
diff --git a/lib/lp/bugs/scripts/bugtasktargetnamecaches.py b/lib/lp/bugs/scripts/bugtasktargetnamecaches.py
index 93a3855..cf0fd4f 100644
--- a/lib/lp/bugs/scripts/bugtasktargetnamecaches.py
+++ b/lib/lp/bugs/scripts/bugtasktargetnamecaches.py
@@ -30,6 +30,7 @@ from lp.services.looptuner import (
     LoopTuner,
     )
 
+
 # These two tuples must be in the same order. They specify the ID
 # columns to get from BugTask, and the classes that they correspond to.
 target_columns = (
diff --git a/lib/lp/bugs/scripts/checkwatches/base.py b/lib/lp/bugs/scripts/checkwatches/base.py
index a778b78..4bf74fb 100644
--- a/lib/lp/bugs/scripts/checkwatches/base.py
+++ b/lib/lp/bugs/scripts/checkwatches/base.py
@@ -35,6 +35,7 @@ from lp.services.webapp.errorlog import (
 from lp.services.webapp.interaction import setupInteraction
 from lp.services.webapp.interfaces import IPlacelessAuthUtility
 
+
 # For OOPS reporting keep up to this number of SQL statements.
 MAX_SQL_STATEMENTS_LOGGED = 10000
 
diff --git a/lib/lp/bugs/scripts/checkwatches/core.py b/lib/lp/bugs/scripts/checkwatches/core.py
index 166376c..8f6aa79 100644
--- a/lib/lp/bugs/scripts/checkwatches/core.py
+++ b/lib/lp/bugs/scripts/checkwatches/core.py
@@ -67,6 +67,7 @@ from lp.services.database.sqlbase import flush_database_updates
 from lp.services.scripts.base import LaunchpadCronScript
 from lp.services.scripts.logger import log as default_log
 
+
 # The login of the user to run as.
 LOGIN = 'bugwatch@xxxxxxxxxxxxxxxxxx'
 
diff --git a/lib/lp/bugs/scripts/checkwatches/scheduler.py b/lib/lp/bugs/scripts/checkwatches/scheduler.py
index 5980443..3bbd315 100644
--- a/lib/lp/bugs/scripts/checkwatches/scheduler.py
+++ b/lib/lp/bugs/scripts/checkwatches/scheduler.py
@@ -16,6 +16,7 @@ from lp.services.database.interfaces import IMasterStore
 from lp.services.database.sqlbase import sqlvalues
 from lp.services.looptuner import TunableLoop
 
+
 # The maximum additional delay in days that a watch may have placed upon
 # it.
 MAX_DELAY_DAYS = 6
diff --git a/lib/lp/buildmaster/model/buildfarmjob.py b/lib/lp/buildmaster/model/buildfarmjob.py
index 1343932..51e90af 100644
--- a/lib/lp/buildmaster/model/buildfarmjob.py
+++ b/lib/lp/buildmaster/model/buildfarmjob.py
@@ -284,7 +284,9 @@ class BuildFarmJobSet:
         """See `IBuildFarmJobSet`."""
         # Imported here to avoid circular imports.
         from lp.soyuz.model.archive import (
-            Archive, get_archive_privacy_filter)
+            Archive,
+            get_archive_privacy_filter,
+            )
 
         clauses = [
             BuildFarmJob.builder == builder_id,
diff --git a/lib/lp/code/adapters/branch.py b/lib/lp/code/adapters/branch.py
index 34cb1a7..c4f4404 100644
--- a/lib/lp/code/adapters/branch.py
+++ b/lib/lp/code/adapters/branch.py
@@ -24,6 +24,7 @@ from lp.code.interfaces.branch import (
     )
 from lp.code.interfaces.branchmergeproposal import IBranchMergeProposal
 
+
 # XXX: thumper 2006-12-20: This needs to be extended
 # to cover bugs and specs linked and unlinked, as
 # well as landing target when it is added to the UI
diff --git a/lib/lp/code/browser/tests/test_gitrepository.py b/lib/lp/code/browser/tests/test_gitrepository.py
index 94bf2ce..accb4b6 100644
--- a/lib/lp/code/browser/tests/test_gitrepository.py
+++ b/lib/lp/code/browser/tests/test_gitrepository.py
@@ -17,8 +17,8 @@ from fixtures import FakeLogger
 import pytz
 import soupmatchers
 from soupmatchers import (
-    Tag,
     HTMLContains,
+    Tag,
     )
 from storm.store import Store
 from testtools.matchers import (
diff --git a/lib/lp/code/bzr.py b/lib/lp/code/bzr.py
index 8e2e264..d1ed973 100644
--- a/lib/lp/code/bzr.py
+++ b/lib/lp/code/bzr.py
@@ -45,8 +45,8 @@ from breezy.bzr.knitrepo import (
     RepositoryFormatKnit4,
     )
 from breezy.errors import (
-    NotStacked,
     NoSuchRevision,
+    NotStacked,
     )
 from breezy.plugins.loom.branch import (
     BzrBranchLoomFormat1,
diff --git a/lib/lp/code/errors.py b/lib/lp/code/errors.py
index 213d112..c00d115 100644
--- a/lib/lp/code/errors.py
+++ b/lib/lp/code/errors.py
@@ -77,6 +77,7 @@ from lp.app.errors import (
     NotFoundError,
     )
 
+
 # Annotate the RecipeParseError's with a 400 webservice status.
 error_status(http_client.BAD_REQUEST)(RecipeParseError)
 
@@ -247,6 +248,7 @@ class BranchMergeProposalExists(InvalidBranchMergeProposal):
     def __init__(self, existing_proposal):
         # Circular import.
         from lp.code.interfaces.branch import IBranch
+
         # display_name is the newer style, but IBranch uses the older style.
         if IBranch.providedBy(existing_proposal.merge_source):
             display_name = "displayname"
diff --git a/lib/lp/code/interfaces/codehosting.py b/lib/lp/code/interfaces/codehosting.py
index b5adc52..e23822e 100644
--- a/lib/lp/code/interfaces/codehosting.py
+++ b/lib/lp/code/interfaces/codehosting.py
@@ -32,6 +32,7 @@ from lp.app.validators.name import valid_name
 from lp.services.config import config
 from lp.services.webapp.interfaces import ILaunchpadApplication
 
+
 # When LAUNCHPAD_SERVICES is provided as a login ID to XML-RPC methods, they
 # bypass the normal security checks and give read-only access to all branches.
 # This allows Launchpad services like the puller and branch scanner to access
diff --git a/lib/lp/code/mail/patches.py b/lib/lp/code/mail/patches.py
index 091dbc0..c2c33ab 100644
--- a/lib/lp/code/mail/patches.py
+++ b/lib/lp/code/mail/patches.py
@@ -18,14 +18,14 @@
 # along with this program; if not, write to the Free Software
 # Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
 
+import re
+
 from breezy.patches import (
     binary_files_re,
     hunk_from_header,
     parse_patch,
     )
 
-import re
-
 
 def iter_file_patch(iter_lines, allow_dirty=False, keep_dirty=False):
     '''
diff --git a/lib/lp/code/model/branch.py b/lib/lp/code/model/branch.py
index 4e63062..2ff7823 100644
--- a/lib/lp/code/model/branch.py
+++ b/lib/lp/code/model/branch.py
@@ -1265,7 +1265,10 @@ class Branch(SQLBase, WebhookTargetMixin, BzrIdentityMixin):
         there is work queued, for example when deciding whether to display
         in-progress UI indicators.
         """
-        from lp.code.model.branchjob import BranchJob, BranchJobType
+        from lp.code.model.branchjob import (
+            BranchJob,
+            BranchJobType,
+            )
         jobs = Store.of(self).find(
             BranchJob,
             BranchJob.branch == self,
@@ -1320,7 +1323,10 @@ class Branch(SQLBase, WebhookTargetMixin, BzrIdentityMixin):
         self.unscan(rescan=True)
 
     def getLatestScanJob(self):
-        from lp.code.model.branchjob import BranchJob, BranchScanJob
+        from lp.code.model.branchjob import (
+            BranchJob,
+            BranchScanJob,
+            )
         latest_job = IStore(BranchJob).find(
             BranchJob,
             BranchJob.branch == self,
@@ -1501,7 +1507,10 @@ class Branch(SQLBase, WebhookTargetMixin, BzrIdentityMixin):
     @property
     def upgrade_pending(self):
         """See `IBranch`."""
-        from lp.code.model.branchjob import BranchJob, BranchJobType
+        from lp.code.model.branchjob import (
+            BranchJob,
+            BranchJobType,
+            )
         store = Store.of(self)
         jobs = store.find(
             BranchJob,
diff --git a/lib/lp/code/model/branchjob.py b/lib/lp/code/model/branchjob.py
index e3c1c16..0010868 100644
--- a/lib/lp/code/model/branchjob.py
+++ b/lib/lp/code/model/branchjob.py
@@ -133,6 +133,7 @@ from lp.translations.interfaces.translations import (
 from lp.translations.model.approver import TranslationBranchApprover
 from lp.translations.utilities.translation_import import TranslationImporter
 
+
 # Use at most the first 100 characters of the commit message for the subject
 # the mail describing the revision.
 SUBJECT_COMMIT_MESSAGE_LENGTH = 100
diff --git a/lib/lp/code/model/branchmergeproposal.py b/lib/lp/code/model/branchmergeproposal.py
index 55a9197..a178017 100644
--- a/lib/lp/code/model/branchmergeproposal.py
+++ b/lib/lp/code/model/branchmergeproposal.py
@@ -349,7 +349,7 @@ class BranchMergeProposal(SQLBase, BugLinkTargetMixin):
         from lp.code.model.branchmergeproposaljob import (
             BranchMergeProposalJob,
             BranchMergeProposalJobType,
-        )
+            )
         jobs = Store.of(self).find(
             BranchMergeProposalJob,
             BranchMergeProposalJob.branch_merge_proposal == self,
@@ -472,6 +472,7 @@ class BranchMergeProposal(SQLBase, BugLinkTargetMixin):
     def _fetchRelatedBugIDsFromSource(self):
         """Fetch related bug IDs from the source branch."""
         from lp.bugs.model.bug import Bug
+
         # Only currently used for Git.
         assert self.source_git_ref is not None
         # XXX cjwatson 2016-06-11: This may return too many bugs in the case
@@ -499,6 +500,7 @@ class BranchMergeProposal(SQLBase, BugLinkTargetMixin):
     def updateRelatedBugsFromSource(self):
         """See `IBranchMergeProposal`."""
         from lp.bugs.model.bug import Bug
+
         # Only currently used for Git.
         assert self.source_git_ref is not None
         current_bug_ids_from_source = {
@@ -966,7 +968,9 @@ class BranchMergeProposal(SQLBase, BugLinkTargetMixin):
             comment.destroySelf()
         # Delete all jobs referring to the BranchMergeProposal, whether
         # or not they have completed.
-        from lp.code.model.branchmergeproposaljob import BranchMergeProposalJob
+        from lp.code.model.branchmergeproposaljob import (
+            BranchMergeProposalJob,
+            )
         for job in BranchMergeProposalJob.selectBy(
             branch_merge_proposal=self.id):
             job.destroySelf()
diff --git a/lib/lp/code/model/codereviewinlinecomment.py b/lib/lp/code/model/codereviewinlinecomment.py
index 2ac74b0..727c4d8 100644
--- a/lib/lp/code/model/codereviewinlinecomment.py
+++ b/lib/lp/code/model/codereviewinlinecomment.py
@@ -14,8 +14,8 @@ import six
 from storm.expr import LeftJoin
 from storm.locals import (
     Int,
-    Reference,
     JSON,
+    Reference,
     )
 from zope.component import getUtility
 from zope.interface import implementer
diff --git a/lib/lp/code/model/gitrepository.py b/lib/lp/code/model/gitrepository.py
index d9c351b..c4f69f0 100644
--- a/lib/lp/code/model/gitrepository.py
+++ b/lib/lp/code/model/gitrepository.py
@@ -899,7 +899,10 @@ class GitRepository(StormBase, WebhookTargetMixin, GitIdentityMixin):
 
     def getLatestScanJob(self):
         """See `IGitRepository`."""
-        from lp.code.model.gitjob import GitJob, GitRefScanJob
+        from lp.code.model.gitjob import (
+            GitJob,
+            GitRefScanJob,
+            )
         latest_job = IStore(GitJob).find(
             GitJob,
             GitJob.repository == self,
diff --git a/lib/lp/code/model/revision.py b/lib/lp/code/model/revision.py
index 5740579..807676a 100644
--- a/lib/lp/code/model/revision.py
+++ b/lib/lp/code/model/revision.py
@@ -461,8 +461,7 @@ class RevisionSet:
         # Here to stop circular imports.
         from lp.code.model.branch import Branch
         from lp.code.model.branchrevision import BranchRevision
-        from lp.registry.model.teammembership import (
-            TeamParticipation)
+        from lp.registry.model.teammembership import TeamParticipation
 
         store = Store.of(person)
 
@@ -495,8 +494,8 @@ class RevisionSet:
         """Helper method for Products and ProjectGroups."""
         # Here to stop circular imports.
         from lp.code.model.branch import Branch
-        from lp.registry.model.product import Product
         from lp.code.model.branchrevision import BranchRevision
+        from lp.registry.model.product import Product
 
         origin = [
             Revision,
diff --git a/lib/lp/code/model/sourcepackagerecipedata.py b/lib/lp/code/model/sourcepackagerecipedata.py
index 7dd3f9a..67be2e3 100644
--- a/lib/lp/code/model/sourcepackagerecipedata.py
+++ b/lib/lp/code/model/sourcepackagerecipedata.py
@@ -448,6 +448,7 @@ class SourcePackageRecipeData(Storm):
         # Circular imports.
         from lp.code.model.branchcollection import GenericBranchCollection
         from lp.code.model.gitcollection import GenericGitCollection
+
         # Load the related Branch, _SourcePackageRecipeDataInstruction.
         base_branches = load_related(
             Branch, sourcepackagerecipedatas, ['base_branch_id'])
diff --git a/lib/lp/code/vocabularies/tests/test_gitrepository_vocabularies.py b/lib/lp/code/vocabularies/tests/test_gitrepository_vocabularies.py
index c747f08..58f13cc 100644
--- a/lib/lp/code/vocabularies/tests/test_gitrepository_vocabularies.py
+++ b/lib/lp/code/vocabularies/tests/test_gitrepository_vocabularies.py
@@ -11,9 +11,9 @@ from lp.code.vocabularies.gitrepository import (
     GitRepositoryRestrictedOnProductVocabulary,
     GitRepositoryVocabulary,
     )
+from lp.registry.interfaces.product import IProductSet
 from lp.testing import TestCaseWithFactory
 from lp.testing.layers import DatabaseFunctionalLayer
-from lp.registry.interfaces.product import IProductSet
 
 
 class TestGitRepositoryVocabulary(TestCaseWithFactory):
diff --git a/lib/lp/code/xmlrpc/branch.py b/lib/lp/code/xmlrpc/branch.py
index d15a335..0c1861d 100644
--- a/lib/lp/code/xmlrpc/branch.py
+++ b/lib/lp/code/xmlrpc/branch.py
@@ -10,9 +10,8 @@ __all__ = [
     ]
 
 
-from six.moves.xmlrpc_client import Fault
-
 from breezy import urlutils
+from six.moves.xmlrpc_client import Fault
 from zope.component import getUtility
 from zope.interface import (
     implementer,
diff --git a/lib/lp/codehosting/__init__.py b/lib/lp/codehosting/__init__.py
index 09b1b64..0221031 100644
--- a/lib/lp/codehosting/__init__.py
+++ b/lib/lp/codehosting/__init__.py
@@ -82,6 +82,8 @@ def dont_wrap_class_and_subclasses(cls):
 
 # Don't wrap Branch or its subclasses in Zope security proxies.  Make sure
 # the various LoomBranch classes are present first.
-import breezy.plugins.loom.branch # noqa: E402
+import breezy.plugins.loom.branch  # noqa: E402
+
+
 breezy.plugins.loom.branch
 dont_wrap_class_and_subclasses(Branch)
diff --git a/lib/lp/codehosting/bzrutils.py b/lib/lp/codehosting/bzrutils.py
index ee7efd6..f255792 100644
--- a/lib/lp/codehosting/bzrutils.py
+++ b/lib/lp/codehosting/bzrutils.py
@@ -60,6 +60,7 @@ from lp.services.webapp.errorlog import (
     ScriptRequest,
     )
 
+
 # Exception classes which are not converted into OOPSes
 NOT_OOPS_EXCEPTIONS = (
     AppendRevisionsOnlyViolation, ConnectionTimeout,
diff --git a/lib/lp/codehosting/inmemory.py b/lib/lp/codehosting/inmemory.py
index 2ac0c58..6da751f 100644
--- a/lib/lp/codehosting/inmemory.py
+++ b/lib/lp/codehosting/inmemory.py
@@ -10,13 +10,13 @@ __all__ = [
     ]
 
 import operator
-from six.moves.xmlrpc_client import Fault
 
 from breezy.urlutils import (
     escape,
     unescape,
     )
 import six
+from six.moves.xmlrpc_client import Fault
 from twisted.internet import defer
 from zope.component import (
     adapter,
diff --git a/lib/lp/codehosting/puller/__init__.py b/lib/lp/codehosting/puller/__init__.py
index f904519..f301313 100644
--- a/lib/lp/codehosting/puller/__init__.py
+++ b/lib/lp/codehosting/puller/__init__.py
@@ -16,7 +16,8 @@ def get_lock_id_for_branch_id(branch_id):
     """
     return 'worker-for-branch-%s@supermirror' % (branch_id,)
 
-from lp.codehosting.puller.scheduler import LockError # noqa: E402
+from lp.codehosting.puller.scheduler import LockError  # noqa: E402
+
 
 UTC = pytz.timezone('UTC')
 
diff --git a/lib/lp/codehosting/puller/worker.py b/lib/lp/codehosting/puller/worker.py
index e3c23a6..b789294 100644
--- a/lib/lp/codehosting/puller/worker.py
+++ b/lib/lp/codehosting/puller/worker.py
@@ -6,6 +6,7 @@ __metaclass__ = type
 import socket
 import sys
 
+
 # FIRST Ensure correct plugins are loaded. Do not delete this comment or the
 # line below this comment.
 import lp.codehosting  # noqa: F401  # isort: split
diff --git a/lib/lp/codehosting/sshserver/daemon.py b/lib/lp/codehosting/sshserver/daemon.py
index 648c597..83d7114 100644
--- a/lib/lp/codehosting/sshserver/daemon.py
+++ b/lib/lp/codehosting/sshserver/daemon.py
@@ -35,6 +35,7 @@ from lp.codehosting import sftp
 from lp.codehosting.sshserver.session import launch_smart_server
 from lp.services.config import config
 
+
 # The names of the key files of the server itself. The directory itself is
 # given in config.codehosting.host_key_pair_path.
 PRIVATE_KEY_FILE = 'ssh_host_key_rsa'
diff --git a/lib/lp/codehosting/vfs/branchfs.py b/lib/lp/codehosting/vfs/branchfs.py
index 7af499f..b1c9849 100644
--- a/lib/lp/codehosting/vfs/branchfs.py
+++ b/lib/lp/codehosting/vfs/branchfs.py
@@ -112,6 +112,7 @@ from lp.services.twistedsupport.xmlrpc import (
 from lp.services.webapp import errorlog
 from lp.xmlrpc import faults
 
+
 # The directories allowed directly beneath a branch directory. These are the
 # directories that Bazaar creates as part of regular operation. We support
 # only two numbered backups to avoid indefinite space usage.
diff --git a/lib/lp/oci/browser/hasocirecipes.py b/lib/lp/oci/browser/hasocirecipes.py
index 64ed5c9..3fc01e6 100644
--- a/lib/lp/oci/browser/hasocirecipes.py
+++ b/lib/lp/oci/browser/hasocirecipes.py
@@ -8,9 +8,9 @@ __all__ = [
     'HasOCIRecipesMenuMixin',
     ]
 
-from lp.oci.interfaces.ocirecipe import IOCIRecipeSet
 from zope.component import getUtility
 
+from lp.oci.interfaces.ocirecipe import IOCIRecipeSet
 from lp.services.webapp import Link
 
 
diff --git a/lib/lp/oci/interfaces/webservice.py b/lib/lp/oci/interfaces/webservice.py
index 92e58ab..9945259 100644
--- a/lib/lp/oci/interfaces/webservice.py
+++ b/lib/lp/oci/interfaces/webservice.py
@@ -28,6 +28,7 @@ from lp.services.webservice.apihelpers import (
     patch_reference_property,
     )
 
+
 # IOCIProject
 patch_collection_property(IOCIProject, 'series', IOCIProjectSeries)
 patch_entry_return_type(IOCIProject, 'newRecipe', IOCIRecipe)
diff --git a/lib/lp/oci/model/ocirecipe.py b/lib/lp/oci/model/ocirecipe.py
index b033aed..adab5b9 100644
--- a/lib/lp/oci/model/ocirecipe.py
+++ b/lib/lp/oci/model/ocirecipe.py
@@ -83,9 +83,9 @@ from lp.oci.interfaces.ocirecipe import (
     NoSuchOCIRecipe,
     OCI_RECIPE_ALLOW_CREATE,
     OCI_RECIPE_BUILD_DISTRIBUTION,
+    OCIRecipeBranchHasInvalidFormat,
     OCIRecipeBuildAlreadyPending,
     OCIRecipeFeatureDisabled,
-    OCIRecipeBranchHasInvalidFormat,
     OCIRecipeNotOwner,
     OCIRecipePrivacyMismatch,
     UsingDistributionCredentials,
diff --git a/lib/lp/oci/tests/test_ocirecipejob.py b/lib/lp/oci/tests/test_ocirecipejob.py
index f61e90b..a348753 100644
--- a/lib/lp/oci/tests/test_ocirecipejob.py
+++ b/lib/lp/oci/tests/test_ocirecipejob.py
@@ -10,9 +10,7 @@ from zope.security.proxy import removeSecurityProxy
 
 from lp.buildmaster.enums import BuildStatus
 from lp.buildmaster.interfaces.processor import IProcessorSet
-from lp.oci.interfaces.ocirecipe import (
-    OCI_RECIPE_ALLOW_CREATE
-    )
+from lp.oci.interfaces.ocirecipe import OCI_RECIPE_ALLOW_CREATE
 from lp.oci.interfaces.ocirecipebuild import (
     OCIRecipeBuildSetRegistryUploadStatus,
     )
diff --git a/lib/lp/registry/browser/distroseries.py b/lib/lp/registry/browser/distroseries.py
index 75c0468..78604a1 100644
--- a/lib/lp/registry/browser/distroseries.py
+++ b/lib/lp/registry/browser/distroseries.py
@@ -122,6 +122,7 @@ from lp.translations.browser.distroseries import (
     check_distroseries_translations_viewable,
     )
 
+
 # DistroSeries statuses that benefit from mass package upgrade support.
 UPGRADABLE_SERIES_STATUSES = [
     SeriesStatus.FUTURE,
diff --git a/lib/lp/registry/browser/sourcepackage.py b/lib/lp/registry/browser/sourcepackage.py
index 50fa669..d3876ad 100644
--- a/lib/lp/registry/browser/sourcepackage.py
+++ b/lib/lp/registry/browser/sourcepackage.py
@@ -157,7 +157,8 @@ class SourcePackageNavigation(Navigation, BugTargetTraversalMixin):
         # source package.
         # If not, raise TranslationUnavailable.
         from lp.translations.browser.distroseries import (
-            check_distroseries_translations_viewable)
+            check_distroseries_translations_viewable,
+            )
         check_distroseries_translations_viewable(self.context.distroseries)
 
         return sourcepackage_pots
diff --git a/lib/lp/registry/browser/tests/test_person_webservice.py b/lib/lp/registry/browser/tests/test_person_webservice.py
index 67d2ae7..4e7e503 100644
--- a/lib/lp/registry/browser/tests/test_person_webservice.py
+++ b/lib/lp/registry/browser/tests/test_person_webservice.py
@@ -29,6 +29,7 @@ from lp.services.identity.interfaces.account import (
 from lp.services.openid.model.openididentifier import OpenIdIdentifier
 from lp.services.webapp import snapshot
 from lp.services.webapp.interfaces import OAuthPermission
+from lp.services.webapp.publisher import canonical_url
 from lp.testing import (
     admin_logged_in,
     api_url,
@@ -38,7 +39,6 @@ from lp.testing import (
     record_two_runs,
     TestCaseWithFactory,
     )
-from lp.services.webapp.publisher import canonical_url
 from lp.testing.layers import DatabaseFunctionalLayer
 from lp.testing.matchers import HasQueryCount
 from lp.testing.pages import (
diff --git a/lib/lp/registry/browser/widgets/ocicredentialswidget.py b/lib/lp/registry/browser/widgets/ocicredentialswidget.py
index 90105f6..42630ef 100644
--- a/lib/lp/registry/browser/widgets/ocicredentialswidget.py
+++ b/lib/lp/registry/browser/widgets/ocicredentialswidget.py
@@ -30,14 +30,12 @@ from zope.schema import (
 from lp.app.errors import UnexpectedFormData
 from lp.app.validators import LaunchpadValidationError
 from lp.app.validators.url import validate_url
-from lp.registry.interfaces.distribution import IDistribution
-from lp.services.webapp.interfaces import (
-    ISingleLineWidgetLayout,
-    )
 from lp.oci.interfaces.ociregistrycredentials import (
     IOCIRegistryCredentials,
     IOCIRegistryCredentialsSet,
     )
+from lp.registry.interfaces.distribution import IDistribution
+from lp.services.webapp.interfaces import ISingleLineWidgetLayout
 
 
 @implementer(ISingleLineWidgetLayout, IInputWidget)
diff --git a/lib/lp/registry/interfaces/distributionmirror.py b/lib/lp/registry/interfaces/distributionmirror.py
index 494fe6c..4457085 100644
--- a/lib/lp/registry/interfaces/distributionmirror.py
+++ b/lib/lp/registry/interfaces/distributionmirror.py
@@ -65,6 +65,7 @@ from lp.services.webapp.escaping import (
     )
 from lp.services.worlddata.interfaces.country import ICountry
 
+
 # The number of hours before we bother probing a mirror again
 PROBE_INTERVAL = 23
 
@@ -272,9 +273,10 @@ class DistroMirrorURIField(URIField):
 
     def _validate(self, value):
         # import here to avoid circular import
-        from lp.services.webapp import canonical_url
         from lazr.uri import URI
 
+        from lp.services.webapp import canonical_url
+
         super(DistroMirrorURIField, self)._validate(value)
         uri = URI(self.normalize(value))
 
diff --git a/lib/lp/registry/interfaces/distroseries.py b/lib/lp/registry/interfaces/distroseries.py
index 624c7ce..8586033 100644
--- a/lib/lp/registry/interfaces/distroseries.py
+++ b/lib/lp/registry/interfaces/distroseries.py
@@ -169,7 +169,10 @@ class DistroSeriesVersionField(UniqueField):
             raise LaunchpadValidationError(
                 "%s is not a valid version" % version)
         # Avoid circular import hell.
-        from lp.archivepublisher.debversion import Version, VersionError
+        from lp.archivepublisher.debversion import (
+            Version,
+            VersionError,
+            )
         try:
             # XXX sinzui 2009-07-25 bug=404613: DistributionMirror and buildd
             # have stricter version rules than the schema. The version must
diff --git a/lib/lp/registry/interfaces/milestone.py b/lib/lp/registry/interfaces/milestone.py
index 2ed580f..aab0935 100644
--- a/lib/lp/registry/interfaces/milestone.py
+++ b/lib/lp/registry/interfaces/milestone.py
@@ -84,9 +84,8 @@ class MilestoneNameField(ContentNameField):
         """Return the named milestone from the context."""
         # IProductSeries and IDistroSeries are imported here to
         # avoid an import loop.
-        from lp.registry.interfaces.productseries import (
-            IProductSeries)
         from lp.registry.interfaces.distroseries import IDistroSeries
+        from lp.registry.interfaces.productseries import IProductSeries
         if IMilestone.providedBy(self.context):
             milestone = self.context.target.getMilestone(name)
         elif IProductSeries.providedBy(self.context):
diff --git a/lib/lp/registry/interfaces/product.py b/lib/lp/registry/interfaces/product.py
index b770b13..f6557df 100644
--- a/lib/lp/registry/interfaces/product.py
+++ b/lib/lp/registry/interfaces/product.py
@@ -152,6 +152,7 @@ from lp.translations.interfaces.hastranslationimports import (
     )
 from lp.translations.interfaces.translationpolicy import ITranslationPolicy
 
+
 # This is based on the definition of <label> in RFC 1035, section
 # 2.3.1, which is what SourceForge project names are based on.
 re_valid_rfc1035_label = re.compile(
@@ -1184,8 +1185,11 @@ class InvalidProductName(LaunchpadValidationError):
 
 
 # Fix circular imports.
-from lp.registry.interfaces.distributionsourcepackage import ( # noqa: E402
-    IDistributionSourcePackage)
+from lp.registry.interfaces.distributionsourcepackage import (  # noqa: E402
+    IDistributionSourcePackage,
+    )
+
+
 patch_reference_property(
     IDistributionSourcePackage, 'upstream_product', IProduct)
 
diff --git a/lib/lp/registry/interfaces/productrelease.py b/lib/lp/registry/interfaces/productrelease.py
index ff55907..2cc1acc 100644
--- a/lib/lp/registry/interfaces/productrelease.py
+++ b/lib/lp/registry/interfaces/productrelease.py
@@ -156,8 +156,7 @@ class ProductReleaseVersionField(ContentNameField):
         `ContentFieldName`.
         """
         # Import locally to avoid circular imports.
-        from lp.registry.interfaces.productseries import (
-            IProductSeries)
+        from lp.registry.interfaces.productseries import IProductSeries
         if IProductSeries.providedBy(self.context):
             productseries = self.context
         else:
diff --git a/lib/lp/registry/interfaces/teammembership.py b/lib/lp/registry/interfaces/teammembership.py
index 3da9f23..d2bcf1d 100644
--- a/lib/lp/registry/interfaces/teammembership.py
+++ b/lib/lp/registry/interfaces/teammembership.py
@@ -45,6 +45,7 @@ from zope.schema import (
 
 from lp import _
 
+
 # One week before a membership expires we send a notification to the member,
 # either inviting them to renew their own membership or asking them to get a
 # team admin to do so, depending on the team's renewal policy.
diff --git a/lib/lp/registry/model/accesspolicy.py b/lib/lp/registry/model/accesspolicy.py
index 010e49e..f994833 100644
--- a/lib/lp/registry/model/accesspolicy.py
+++ b/lib/lp/registry/model/accesspolicy.py
@@ -119,8 +119,8 @@ class AccessArtifact(StormBase):
         from lp.bugs.interfaces.bug import IBug
         from lp.code.interfaces.branch import IBranch
         from lp.code.interfaces.gitrepository import IGitRepository
-        from lp.snappy.interfaces.snap import ISnap
         from lp.oci.interfaces.ocirecipe import IOCIRecipe
+        from lp.snappy.interfaces.snap import ISnap
         if IBug.providedBy(concrete_artifact):
             col = cls.bug
         elif IBranch.providedBy(concrete_artifact):
@@ -154,8 +154,8 @@ class AccessArtifact(StormBase):
         from lp.bugs.interfaces.bug import IBug
         from lp.code.interfaces.branch import IBranch
         from lp.code.interfaces.gitrepository import IGitRepository
-        from lp.snappy.interfaces.snap import ISnap
         from lp.oci.interfaces.ocirecipe import IOCIRecipe
+        from lp.snappy.interfaces.snap import ISnap
 
         existing = list(cls.find(concrete_artifacts))
         if len(existing) == len(concrete_artifacts):
diff --git a/lib/lp/registry/model/distribution.py b/lib/lp/registry/model/distribution.py
index f76d28b..56eff14 100644
--- a/lib/lp/registry/model/distribution.py
+++ b/lib/lp/registry/model/distribution.py
@@ -89,7 +89,9 @@ from lp.bugs.model.structuralsubscription import (
 from lp.code.interfaces.seriessourcepackagebranch import (
     IFindOfficialBranchLinks,
     )
-from lp.oci.interfaces.ociregistrycredentials import IOCIRegistryCredentialsSet
+from lp.oci.interfaces.ociregistrycredentials import (
+    IOCIRegistryCredentialsSet,
+    )
 from lp.registry.enums import (
     BranchSharingPolicy,
     BugSharingPolicy,
@@ -693,9 +695,12 @@ class Distribution(SQLBase, BugTargetBase, MakesAnnouncements,
     def getBranchTips(self, user=None, since=None):
         """See `IDistribution`."""
         from lp.code.model.branch import (
-            Branch, get_branch_privacy_filter)
+            Branch,
+            get_branch_privacy_filter,
+            )
         from lp.code.model.seriessourcepackagebranch import (
-            SeriesSourcePackageBranch)
+            SeriesSourcePackageBranch,
+            )
 
         # This method returns thousands of branch unique names in a
         # single call, so the query is perilous and awkwardly tuned to
@@ -1044,6 +1049,7 @@ class Distribution(SQLBase, BugTargetBase, MakesAnnouncements,
         from lp.soyuz.model.distributionsourcepackagecache import (
             DistributionSourcePackageCache,
             )
+
         # The query below tries exact matching on the source package
         # name as well; this is because source package names are
         # notoriously bad for fti matching -- they can contain dots, or
diff --git a/lib/lp/registry/model/mailinglist.py b/lib/lp/registry/model/mailinglist.py
index 86619a0..6161581 100644
--- a/lib/lp/registry/model/mailinglist.py
+++ b/lib/lp/registry/model/mailinglist.py
@@ -22,6 +22,7 @@ from lazr.lifecycle.event import ObjectCreatedEvent
 import pytz
 import six
 from storm.expr import Func
+from storm.info import ClassAlias
 from storm.locals import (
     And,
     DateTime,
@@ -32,7 +33,6 @@ from storm.locals import (
     Select,
     Unicode,
     )
-from storm.info import ClassAlias
 from storm.store import Store
 from zope.component import (
     getUtility,
@@ -724,6 +724,7 @@ class MailingListSet:
         """See `IMailingListSet`."""
         # Circular import.
         from lp.registry.model.person import Person
+
         # This is really an operation on EmailAddress rows, but it's so
         # specific to mailing lists that it seems better to keep it here.
         old_suffix = u"@" + old_hostname
diff --git a/lib/lp/registry/model/milestone.py b/lib/lp/registry/model/milestone.py
index aa80a20..452a3bf 100644
--- a/lib/lp/registry/model/milestone.py
+++ b/lib/lp/registry/model/milestone.py
@@ -167,7 +167,8 @@ class MilestoneData:
             get_specification_privacy_filter,
             )
         from lp.blueprints.model.specificationworkitem import (
-            SpecificationWorkItem)
+            SpecificationWorkItem,
+            )
         from lp.registry.model.person import Person
         origin = [Specification]
         product_origin, clauses = get_specification_active_product_filter(
@@ -335,7 +336,10 @@ class Milestone(SQLBase, MilestoneData, StructuralSubscriptionTargetMixin,
     def setTags(self, tags, user):
         """See IMilestone."""
         # Circular reference prevention.
-        from lp.registry.model.milestonetag import MilestoneTag, validate_tags
+        from lp.registry.model.milestonetag import (
+            MilestoneTag,
+            validate_tags,
+            )
         store = Store.of(self)
         if tags:
             if not validate_tags(tags):
diff --git a/lib/lp/registry/model/ociproject.py b/lib/lp/registry/model/ociproject.py
index 1f99135..8a88be6 100644
--- a/lib/lp/registry/model/ociproject.py
+++ b/lib/lp/registry/model/ociproject.py
@@ -268,9 +268,9 @@ class OCIProject(BugTargetBase, StructuralSubscriptionTargetMixin, StormBase):
     def getRecipes(self, visible_by_user=None):
         """See `IOCIProject`."""
         from lp.oci.model.ocirecipe import (
-            OCIRecipe,
             get_ocirecipe_privacy_filter,
-        )
+            OCIRecipe,
+            )
         rs = IStore(OCIRecipe).find(
             OCIRecipe,
             OCIRecipe.owner_id == Person.id,
@@ -417,8 +417,8 @@ class OCIProjectSet:
 
     def getByPillarAndName(self, pillar, name):
         """See `IOCIProjectSet`."""
-        from lp.registry.model.product import Product
         from lp.registry.model.distribution import Distribution
+        from lp.registry.model.product import Product
 
         # If pillar is not an string, we expect it to be either an
         # IDistribution or IProduct.
diff --git a/lib/lp/registry/model/person.py b/lib/lp/registry/model/person.py
index 70a7933..94153ed 100644
--- a/lib/lp/registry/model/person.py
+++ b/lib/lp/registry/model/person.py
@@ -826,6 +826,7 @@ class Person(
         from lp.blueprints.model.specificationsubscription import (
             SpecificationSubscription,
             )
+
         # Make a new copy of the filter, so that we do not mutate what we
         # were passed as a filter.
         if filter is None:
@@ -884,10 +885,10 @@ class Person(
     def getBugSubscriberPackages(self):
         """See `IPerson`."""
         # Avoid circular imports.
+        from lp.registry.model.distribution import Distribution
         from lp.registry.model.distributionsourcepackage import (
             DistributionSourcePackage,
             )
-        from lp.registry.model.distribution import Distribution
         origin = (
             StructuralSubscription,
             Join(
@@ -1006,11 +1007,11 @@ class Person(
         # We want this person's total karma on a given context (that is,
         # across all different categories) here; that's why we use a
         # "KarmaCache.category IS NULL" clause here.
+        from lp.registry.model.distribution import Distribution
         from lp.registry.model.product import (
             Product,
             ProductSet,
-        )
-        from lp.registry.model.distribution import Distribution
+            )
         tableset = Store.of(self).using(
             KarmaCache, LeftJoin(Product, Product.id == KarmaCache.productID),
             LeftJoin(Distribution, Distribution.id ==
@@ -1401,9 +1402,9 @@ class Person(
 
     def getAssignedSpecificationWorkItemsDueBefore(self, date, user):
         """See `IPerson`."""
+        from lp.registry.model.distribution import Distribution
         from lp.registry.model.person import Person
         from lp.registry.model.product import Product
-        from lp.registry.model.distribution import Distribution
         store = Store.of(self)
 
         # Since a workitem's assignee defaults to its specification's
@@ -1816,6 +1817,7 @@ class Person(
         from lp.bugs.model.bug import Bug
         from lp.bugs.model.bugsubscription import BugSubscription
         from lp.bugs.model.bugtask import BugTask
+
         # The team cannot be open if it is subscribed to or assigned to
         # private bugs.
         private_bugs_involved = IStore(Bug).execute(Union(
diff --git a/lib/lp/registry/model/pillar.py b/lib/lp/registry/model/pillar.py
index c591925..87d58fd 100644
--- a/lib/lp/registry/model/pillar.py
+++ b/lib/lp/registry/model/pillar.py
@@ -164,9 +164,12 @@ class PillarNameSet:
         :returns: Storm ResultSet object
         """
         # These classes are imported in this method to prevent an import loop.
-        from lp.registry.model.product import Product, ProductSet
-        from lp.registry.model.projectgroup import ProjectGroup
         from lp.registry.model.distribution import Distribution
+        from lp.registry.model.product import (
+            Product,
+            ProductSet,
+            )
+        from lp.registry.model.projectgroup import ProjectGroup
         OtherPillarName = ClassAlias(PillarName)
         origin = [
             PillarName,
diff --git a/lib/lp/registry/model/product.py b/lib/lp/registry/model/product.py
index 9f53c70..bcda063 100644
--- a/lib/lp/registry/model/product.py
+++ b/lib/lp/registry/model/product.py
@@ -1117,7 +1117,8 @@ class Product(SQLBase, BugTargetBase, MakesAnnouncements,
     @cachedproperty
     def distrosourcepackages(self):
         from lp.registry.model.distributionsourcepackage import (
-            DistributionSourcePackage)
+            DistributionSourcePackage,
+            )
         dsp_info = get_distro_sourcepackages([self])
         return [
             DistributionSourcePackage(
diff --git a/lib/lp/registry/scripts/distributionmirror_prober.py b/lib/lp/registry/scripts/distributionmirror_prober.py
index 7620cc7..13cff94 100644
--- a/lib/lp/registry/scripts/distributionmirror_prober.py
+++ b/lib/lp/registry/scripts/distributionmirror_prober.py
@@ -62,6 +62,7 @@ from lp.services.timeout import urlfetch
 from lp.services.webapp import canonical_url
 from lp.soyuz.interfaces.distroarchseries import IDistroArchSeries
 
+
 # The requests/timeouts ratio has to be at least 3 for us to keep issuing
 # requests on a given host. (This ratio is per run, rather than held long
 # term)
diff --git a/lib/lp/registry/tests/test_mailinglistapi.py b/lib/lp/registry/tests/test_mailinglistapi.py
index c52fef0..256bbfa 100644
--- a/lib/lp/registry/tests/test_mailinglistapi.py
+++ b/lib/lp/registry/tests/test_mailinglistapi.py
@@ -9,12 +9,12 @@ __all__ = []
 from email import message_from_string
 from textwrap import dedent
 
+from six.moves import xmlrpc_client
 from testtools.matchers import (
     Equals,
     MatchesDict,
     MatchesSetwise,
     )
-from six.moves import xmlrpc_client
 import transaction
 from zope.component import getUtility
 from zope.security.proxy import removeSecurityProxy
diff --git a/lib/lp/registry/xmlrpc/mailinglist.py b/lib/lp/registry/xmlrpc/mailinglist.py
index d22dfc2..f14d8cd 100644
--- a/lib/lp/registry/xmlrpc/mailinglist.py
+++ b/lib/lp/registry/xmlrpc/mailinglist.py
@@ -39,6 +39,7 @@ from lp.services.messages.interfaces.message import IMessageSet
 from lp.services.webapp import LaunchpadXMLRPCView
 from lp.xmlrpc import faults
 
+
 # These constants must match those defined in Mailman.MemberAdaptor.
 ENABLED = 0
 BYUSER = 2
diff --git a/lib/lp/scripts/harness.py b/lib/lp/scripts/harness.py
index c94d382..7d2e397 100644
--- a/lib/lp/scripts/harness.py
+++ b/lib/lp/scripts/harness.py
@@ -43,6 +43,7 @@ from lp.services.scripts import execute_zcml_for_scripts
 from lp.services.webapp import canonical_url
 from lp.testing.factory import LaunchpadObjectFactory
 
+
 # Silence unused name warnings
 (utc, transaction, verifyObject, removeSecurityProxy, canonical_url,
  getUtility, rlcompleter)
diff --git a/lib/lp/scripts/utilities/importpedant.py b/lib/lp/scripts/utilities/importpedant.py
index 71e636c..5bf143e 100644
--- a/lib/lp/scripts/utilities/importpedant.py
+++ b/lib/lp/scripts/utilities/importpedant.py
@@ -10,6 +10,7 @@ import warnings
 import six
 from six.moves import builtins
 
+
 # Silence bogus warnings from Hardy's python-pkg-resources package.
 warnings.filterwarnings('ignore', category=UserWarning, append=True,
                         message=r'Module .*? is being added to sys.path')
diff --git a/lib/lp/scripts/utilities/test.py b/lib/lp/scripts/utilities/test.py
index 0f1c9ac..375d70c 100755
--- a/lib/lp/scripts/utilities/test.py
+++ b/lib/lp/scripts/utilities/test.py
@@ -148,6 +148,7 @@ class LaunchpadWarnings(Feature):
 
 def install_fake_pgsql_connect():
     from lp.testing import pgsql
+
     # If this is removed, make sure lp.testing.pgsql is updated
     # because the test harness there relies on the Connection wrapper being
     # installed.
@@ -205,11 +206,11 @@ def main():
     # The imports at the top of this file must avoid anything that reads
     # from Launchpad config. Now that we've set the correct config instance,
     # we can safely import the rest.
+    from lp.services.testing import profiled
     from lp.services.testing.customresult import (
         filter_tests,
         patch_find_tests,
         )
-    from lp.services.testing import profiled
 
     # Extract arguments so we can see them too. We need to strip
     # --resume-layer and --default stuff if found as get_options can't
diff --git a/lib/lp/scripts/utilities/warninghandler.py b/lib/lp/scripts/utilities/warninghandler.py
index 88827e6..423ba6f 100644
--- a/lib/lp/scripts/utilities/warninghandler.py
+++ b/lib/lp/scripts/utilities/warninghandler.py
@@ -6,24 +6,20 @@
 __metaclass__ = type
 
 import inspect
-import six
 import sys
 import warnings
 
+import six
 # ViewPageTemplateFile has .filename.
 from zope.browserpage import ViewPageTemplateFile
-
-# PythonExpr has .text, the text of the expression.
-from zope.tales.pythonexpr import PythonExpr
-
+from zope.browserpage.simpleviewclass import simple
 # TrustedZopeContext has self.contexts, a dict with template, view, context,
 # request, etc.
 from zope.pagetemplate.engine import TrustedZopeContext
-
 # TALInterpreter has self.sourceFile, a filename of a page template.
 from zope.tal.talinterpreter import TALInterpreter
-
-from zope.browserpage.simpleviewclass import simple
+# PythonExpr has .text, the text of the expression.
+from zope.tales.pythonexpr import PythonExpr
 
 
 class WarningReport:
diff --git a/lib/lp/services/compat.py b/lib/lp/services/compat.py
index 280de97..4d8ee9d 100644
--- a/lib/lp/services/compat.py
+++ b/lib/lp/services/compat.py
@@ -26,6 +26,7 @@ except ImportError:
 
 import io
 
+
 try:
     import mock
 except ImportError:
diff --git a/lib/lp/services/config/tests/test_config.py b/lib/lp/services/config/tests/test_config.py
index ff81da8..519d634 100644
--- a/lib/lp/services/config/tests/test_config.py
+++ b/lib/lp/services/config/tests/test_config.py
@@ -24,6 +24,7 @@ import testtools
 import lp.services.config
 from lp.services.config.fixture import ConfigUseFixture
 
+
 # Configs that shouldn't be tested.
 EXCLUDED_CONFIGS = ['lpnet-template']
 
diff --git a/lib/lp/services/daemons/tests/okay.tac b/lib/lp/services/daemons/tests/okay.tac
index 31ef5da..9009ebd 100644
--- a/lib/lp/services/daemons/tests/okay.tac
+++ b/lib/lp/services/daemons/tests/okay.tac
@@ -11,12 +11,12 @@ __metaclass__ = type
 from twisted.application import service
 from zope.component import getUtility
 
+from lp.services.daemons import readyservice
 from lp.services.database.interfaces import (
     DEFAULT_FLAVOR,
     IStoreSelector,
     MAIN_STORE,
     )
-from lp.services.daemons import readyservice
 from lp.services.scripts import execute_zcml_for_scripts
 
 
diff --git a/lib/lp/services/database/nl_search.py b/lib/lp/services/database/nl_search.py
index d0226bb..be9a9dd 100644
--- a/lib/lp/services/database/nl_search.py
+++ b/lib/lp/services/database/nl_search.py
@@ -28,6 +28,7 @@ from lp.services.database.interfaces import (
     )
 from lp.services.database.stormexpr import fti_search
 
+
 # Regular expression to extract terms from the printout of a ts_query
 TS_QUERY_TERM_RE = re.compile(r"'([^']+)'")
 
diff --git a/lib/lp/services/database/sqlbase.py b/lib/lp/services/database/sqlbase.py
index 96a5c62..7757749 100644
--- a/lib/lp/services/database/sqlbase.py
+++ b/lib/lp/services/database/sqlbase.py
@@ -69,6 +69,7 @@ from lp.services.database.interfaces import (
     )
 from lp.services.propertycache import clear_property_cache
 
+
 # Default we want for scripts, and the PostgreSQL default. Note psycopg1 will
 # use SERIALIZABLE unless we override, but psycopg2 will not.
 ISOLATION_LEVEL_DEFAULT = ISOLATION_LEVEL_READ_COMMITTED
diff --git a/lib/lp/services/database/tests/script_isolation.py b/lib/lp/services/database/tests/script_isolation.py
index a3385c1..dd02ff0 100644
--- a/lib/lp/services/database/tests/script_isolation.py
+++ b/lib/lp/services/database/tests/script_isolation.py
@@ -17,6 +17,7 @@ from lp.services.database.sqlbase import (
     )
 from lp.services.scripts import execute_zcml_for_scripts
 
+
 execute_zcml_for_scripts()
 
 
diff --git a/lib/lp/services/features/browser/info.py b/lib/lp/services/features/browser/info.py
index aacb6af..2a6f84b 100644
--- a/lib/lp/services/features/browser/info.py
+++ b/lib/lp/services/features/browser/info.py
@@ -23,6 +23,7 @@ from lp.services.features.scopes import (
 from lp.services.utils import docstring_dedent
 from lp.services.webapp.publisher import LaunchpadView
 
+
 # Named tuples to use when passing flag and scope data to the template.
 Flag = namedtuple(
     'Flag', ('name', 'domain', 'description', 'default', 'title', 'link'))
diff --git a/lib/lp/services/features/rulesource.py b/lib/lp/services/features/rulesource.py
index 6f8310f..9db8727 100644
--- a/lib/lp/services/features/rulesource.py
+++ b/lib/lp/services/features/rulesource.py
@@ -28,6 +28,7 @@ from lp.services.features.model import (
     )
 from lp.services.webapp import adapter
 
+
 # A convenient mapping for a feature flag rule in the database.
 Rule = namedtuple("Rule", "flag scope priority value")
 
diff --git a/lib/lp/services/fields/__init__.py b/lib/lp/services/fields/__init__.py
index 87806e4..9d29346 100644
--- a/lib/lp/services/fields/__init__.py
+++ b/lib/lp/services/fields/__init__.py
@@ -108,6 +108,7 @@ from lp.registry.enums import (
 from lp.registry.interfaces.pillar import IPillarNameSet
 from lp.services.webapp.interfaces import ILaunchBag
 
+
 # Marker object to tell BaseImageUpload to keep the existing image.
 KEEP_SAME_IMAGE = object()
 # Regexp for detecting milestone headers in work items text.
@@ -524,9 +525,9 @@ class PillarAliases(TextLine):
         not identical to the pillar's existing name.
         """
         context = self.context
+        from lp.registry.interfaces.distribution import IDistribution
         from lp.registry.interfaces.product import IProduct
         from lp.registry.interfaces.projectgroup import IProjectGroup
-        from lp.registry.interfaces.distribution import IDistribution
         if IProduct.providedBy(context):
             name_field = IProduct['name']
         elif IProjectGroup.providedBy(context):
diff --git a/lib/lp/services/geoip/helpers.py b/lib/lp/services/geoip/helpers.py
index 993bd77..7ec9df1 100644
--- a/lib/lp/services/geoip/helpers.py
+++ b/lib/lp/services/geoip/helpers.py
@@ -4,6 +4,7 @@
 __metaclass__ = type
 
 import ipaddress
+
 import six
 from zope.component import getUtility
 
diff --git a/lib/lp/services/identity/interfaces/webservice.py b/lib/lp/services/identity/interfaces/webservice.py
index 049e8f9..4b8c529 100644
--- a/lib/lp/services/identity/interfaces/webservice.py
+++ b/lib/lp/services/identity/interfaces/webservice.py
@@ -17,5 +17,6 @@ __all__ = [
 from lp.services.identity.interfaces.emailaddress import IEmailAddress
 from lp.services.webservice.apihelpers import patch_entry_explicit_version
 
+
 # IEmailAddress
 patch_entry_explicit_version(IEmailAddress, 'beta')
diff --git a/lib/lp/services/identity/model/emailaddress.py b/lib/lp/services/identity/model/emailaddress.py
index c9c9a4e..3d52a67 100644
--- a/lib/lp/services/identity/model/emailaddress.py
+++ b/lib/lp/services/identity/model/emailaddress.py
@@ -68,8 +68,7 @@ class EmailAddress(SQLBase, HasOwnerMixin):
         """See `IEmailAddress`."""
         # Import this here to avoid circular references.
         from lp.registry.interfaces.mailinglist import MailingListStatus
-        from lp.registry.model.mailinglist import (
-            MailingListSubscription)
+        from lp.registry.model.mailinglist import MailingListSubscription
 
         if self.status == EmailAddressStatus.PREFERRED:
             raise UndeletableEmailAddress(
diff --git a/lib/lp/services/job/celeryconfig.py b/lib/lp/services/job/celeryconfig.py
index e218c6a..06612b0 100644
--- a/lib/lp/services/job/celeryconfig.py
+++ b/lib/lp/services/job/celeryconfig.py
@@ -1,11 +1,10 @@
 # Copyright 2012-2019 Canonical Ltd.  This software is licensed under the
 # GNU Affero General Public License version 3 (see the file LICENSE).
 
+import argparse
 from datetime import timedelta
 import sys
 
-import argparse
-
 from lp.services.config import config
 
 
diff --git a/lib/lp/services/job/celeryjob.py b/lib/lp/services/job/celeryjob.py
index 7d9e8b6..7d0163b 100644
--- a/lib/lp/services/job/celeryjob.py
+++ b/lib/lp/services/job/celeryjob.py
@@ -30,19 +30,20 @@ import transaction
 
 from lp.code.model.branchjob import BranchScanJob
 from lp.scripts.helpers import TransactionFreeOperation
+from lp.services import scripts
 from lp.services.config import dbconfig
 from lp.services.database.sqlbase import disconnect_stores
 from lp.services.features import (
     install_feature_controller,
     make_script_feature_controller,
     )
-from lp.services.mail.sendmail import set_immediate_mail_delivery
 from lp.services.job.model.job import UniversalJobSource
 from lp.services.job.runner import (
     BaseJobRunner,
     celery_enabled,
     )
-from lp.services import scripts
+from lp.services.mail.sendmail import set_immediate_mail_delivery
+
 
 os.environ.setdefault('CELERY_CONFIG_MODULE', 'lp.services.job.celeryconfig')
 
diff --git a/lib/lp/services/job/tests/__init__.py b/lib/lp/services/job/tests/__init__.py
index 1fc3c1c..655bab8 100644
--- a/lib/lp/services/job/tests/__init__.py
+++ b/lib/lp/services/job/tests/__init__.py
@@ -29,6 +29,7 @@ def celery_worker(queue, cwd=None):
     currently-configured BROKER_URL, and able to run CeleryRunJob tasks.
     """
     from lp.services.job.celeryjob import celery_app
+
     # convert config params to a URL, so they can be passed as --broker.
     with celery_app.broker_connection() as connection:
         broker_uri = connection.as_uri(include_password=True)
@@ -89,6 +90,7 @@ def block_on_job(test_case=None):
 
 def drain_celery_queues():
     from lazr.jobrunner.celerytask import drain_queues
+
     from lp.services.job.celeryjob import celery_app
     drain_queues(celery_app, celery_app.conf.CELERY_QUEUES.keys())
 
diff --git a/lib/lp/services/job/tests/celery_helpers.py b/lib/lp/services/job/tests/celery_helpers.py
index c378b6f..0f3ca73 100644
--- a/lib/lp/services/job/tests/celery_helpers.py
+++ b/lib/lp/services/job/tests/celery_helpers.py
@@ -13,6 +13,7 @@ from celery.task import task
 # Force the correct celeryconfig to be used.
 import lp.services.job.celeryjob
 
+
 # Quiet lint unused import warning.
 lp.services.job.celeryjob
 
diff --git a/lib/lp/services/librarian/client.py b/lib/lp/services/librarian/client.py
index a26e39f..1955a0a 100644
--- a/lib/lp/services/librarian/client.py
+++ b/lib/lp/services/librarian/client.py
@@ -17,8 +17,8 @@ import hashlib
 import select
 import socket
 from socket import (
-    SOCK_STREAM,
     AF_INET,
+    SOCK_STREAM,
     )
 import threading
 import time
@@ -172,8 +172,10 @@ class FileUploadClient:
         name = six.ensure_binary(name)
 
         # Import in this method to avoid a circular import
-        from lp.services.librarian.model import LibraryFileContent
-        from lp.services.librarian.model import LibraryFileAlias
+        from lp.services.librarian.model import (
+            LibraryFileAlias,
+            LibraryFileContent,
+            )
 
         self._connect()
         try:
diff --git a/lib/lp/services/librarian/interfaces/__init__.py b/lib/lp/services/librarian/interfaces/__init__.py
index f0ed67d..3796ba4 100644
--- a/lib/lp/services/librarian/interfaces/__init__.py
+++ b/lib/lp/services/librarian/interfaces/__init__.py
@@ -36,6 +36,7 @@ from lp.services.librarian.interfaces.client import (
     LIBRARIAN_SERVER_DEFAULT_TIMEOUT,
     )
 
+
 # Set the expires attribute to this constant to flag a file that
 # should never be removed from the Librarian.
 NEVER_EXPIRES = datetime(2038, 1, 1, 0, 0, 0, tzinfo=utc)
diff --git a/lib/lp/services/log/loglevels.py b/lib/lp/services/log/loglevels.py
index 71d4a70..fca11d1 100644
--- a/lib/lp/services/log/loglevels.py
+++ b/lib/lp/services/log/loglevels.py
@@ -28,6 +28,7 @@ __all__ = [
 
 import logging
 
+
 # Reexport standard log levels.
 DEBUG = logging.DEBUG
 INFO = logging.INFO
diff --git a/lib/lp/services/mail/helpers.py b/lib/lp/services/mail/helpers.py
index 4ed4b95..4f9153a 100644
--- a/lib/lp/services/mail/helpers.py
+++ b/lib/lp/services/mail/helpers.py
@@ -280,6 +280,7 @@ def get_contact_email_addresses(person):
     # Need to remove the security proxy of the email address because the
     # logged in user may not have permission to see it.
     from zope.security.proxy import removeSecurityProxy
+
     # Circular imports force this import.
     from lp.registry.model.person import get_recipients
     return set(
diff --git a/lib/lp/services/mail/incoming.py b/lib/lp/services/mail/incoming.py
index 92ca11c..4901078 100644
--- a/lib/lp/services/mail/incoming.py
+++ b/lib/lp/services/mail/incoming.py
@@ -65,6 +65,7 @@ from lp.services.webapp.interfaces import (
     IPlacelessAuthUtility,
     )
 
+
 # Match '\n' and '\r' line endings. That is, all '\r' that are not
 # followed by a '\n', and all '\n' that are not preceded by a '\r'.
 non_canonicalised_line_endings = re.compile(br'((?<!\r)\n)|(\r(?!\n))')
diff --git a/lib/lp/services/mail/mailbox.py b/lib/lp/services/mail/mailbox.py
index 7bc3c4b..5ec49fe 100644
--- a/lib/lp/services/mail/mailbox.py
+++ b/lib/lp/services/mail/mailbox.py
@@ -24,6 +24,7 @@ from zope.interface import (
 
 from lp.services.mail import stub
 
+
 # XXX wgrant 2015-09-21: A Python 2.7 security update set the line
 # length limit to 2048 bytes, which real POP3 servers often exceed for
 # various reasons. http://bugs.python.org/issue23906
diff --git a/lib/lp/services/mail/sendmail.py b/lib/lp/services/mail/sendmail.py
index f1ab3c6..133b423 100644
--- a/lib/lp/services/mail/sendmail.py
+++ b/lib/lp/services/mail/sendmail.py
@@ -61,6 +61,7 @@ from lp.services.encoding import is_ascii_only
 from lp.services.mail.stub import TestMailer
 from lp.services.timeline.requesttimeline import get_request_timeline
 
+
 # email package by default ends up encoding UTF-8 messages using base64,
 # which sucks as they look like spam to stupid spam filters. We define
 # our own custom charset definition to force quoted printable.
@@ -329,6 +330,7 @@ def simple_sendmail_from_person(
     From header is properly encoded.
     """
     from zope.security.proxy import removeSecurityProxy
+
     # Bypass zope's security because IEmailAddress.email is not public.
     naked_email = removeSecurityProxy(person.preferredemail)
     from_addr = format_address(person.displayname, naked_email.email)
diff --git a/lib/lp/services/mail/tests/test_dkim.py b/lib/lp/services/mail/tests/test_dkim.py
index 3100f67..c03f186 100644
--- a/lib/lp/services/mail/tests/test_dkim.py
+++ b/lib/lp/services/mail/tests/test_dkim.py
@@ -24,6 +24,7 @@ from lp.services.mail.signedmessage import signed_message_from_bytes
 from lp.testing import TestCaseWithFactory
 from lp.testing.layers import DatabaseFunctionalLayer
 
+
 # sample private key made with 'openssl genrsa' and public key using 'openssl
 # rsa -pubout'.  Not really the key for canonical.com ;-)
 sample_privkey = b"""\
diff --git a/lib/lp/services/messages/model/messagerevision.py b/lib/lp/services/messages/model/messagerevision.py
index c289352..6c60639 100644
--- a/lib/lp/services/messages/model/messagerevision.py
+++ b/lib/lp/services/messages/model/messagerevision.py
@@ -58,9 +58,9 @@ class MessageRevision(StormBase):
 
     @property
     def message_implementation(self):
+        from lp.answers.model.questionmessage import QuestionMessage
         from lp.bugs.model.bugmessage import BugMessage
         from lp.code.model.codereviewcomment import CodeReviewComment
-        from lp.answers.model.questionmessage import QuestionMessage
 
         store = IStore(self)
         (identifier, ) = store.execute("""
diff --git a/lib/lp/services/messages/tests/scenarios.py b/lib/lp/services/messages/tests/scenarios.py
index f366574..7d37893 100644
--- a/lib/lp/services/messages/tests/scenarios.py
+++ b/lib/lp/services/messages/tests/scenarios.py
@@ -8,9 +8,7 @@ from zope.security.proxy import ProxyFactory
 
 from lp.bugs.model.bugmessage import BugMessage
 from lp.services.database.interfaces import IStore
-from lp.testing import (
-    login_person,
-    )
+from lp.testing import login_person
 
 
 class MessageTypeScenariosMixin(WithScenarios):
diff --git a/lib/lp/services/messaging/tests/test_rabbit.py b/lib/lp/services/messaging/tests/test_rabbit.py
index dfd48af..d7cee8b 100644
--- a/lib/lp/services/messaging/tests/test_rabbit.py
+++ b/lib/lp/services/messaging/tests/test_rabbit.py
@@ -47,6 +47,7 @@ from lp.testing.layers import (
     )
 from lp.testing.matchers import Provides
 
+
 # RabbitMQ is not (yet) torn down or reset between tests, so here are sources
 # of distinct names.
 queue_names = ("queue.%d" % num for num in count(1))
diff --git a/lib/lp/services/oauth/interfaces.py b/lib/lp/services/oauth/interfaces.py
index 48e5c41..a908690 100644
--- a/lib/lp/services/oauth/interfaces.py
+++ b/lib/lp/services/oauth/interfaces.py
@@ -38,6 +38,7 @@ from lp.services.webapp.interfaces import (
     OAuthPermission,
     )
 
+
 # The challenge included in responses with a 401 status.
 OAUTH_REALM = 'https://api.launchpad.net'
 OAUTH_CHALLENGE = 'OAuth realm="%s"' % OAUTH_REALM
diff --git a/lib/lp/services/oauth/model.py b/lib/lp/services/oauth/model.py
index a49e34d..2d9ec38 100644
--- a/lib/lp/services/oauth/model.py
+++ b/lib/lp/services/oauth/model.py
@@ -52,6 +52,7 @@ from lp.services.webapp.interfaces import (
     OAuthPermission,
     )
 
+
 # How many hours should a request token be valid for?
 REQUEST_TOKEN_VALIDITY = 2
 
diff --git a/lib/lp/services/openid/extensions/tests/test_macaroon.py b/lib/lp/services/openid/extensions/tests/test_macaroon.py
index bcbc8a8..7cc6e5f 100644
--- a/lib/lp/services/openid/extensions/tests/test_macaroon.py
+++ b/lib/lp/services/openid/extensions/tests/test_macaroon.py
@@ -9,11 +9,11 @@ from openid.server.server import Server
 from zope.component import getUtility
 
 from lp.services.openid.extensions.macaroon import (
+    get_macaroon_ns,
     MACAROON_NS,
     MacaroonNamespaceError,
     MacaroonRequest,
     MacaroonResponse,
-    get_macaroon_ns,
     )
 from lp.services.openid.interfaces.openidconsumer import IOpenIDConsumerStore
 from lp.testing import (
diff --git a/lib/lp/services/profile/__init__.py b/lib/lp/services/profile/__init__.py
index 895dcdc..2f1b999 100644
--- a/lib/lp/services/profile/__init__.py
+++ b/lib/lp/services/profile/__init__.py
@@ -16,5 +16,6 @@ from lp.services.profile.profile import (
     stop,
     )
 
+
 # Quiet the linter.
 (profiling, start, stop)
diff --git a/lib/lp/services/profile/profile.py b/lib/lp/services/profile/profile.py
index e98f17f..ddcc018 100644
--- a/lib/lp/services/profile/profile.py
+++ b/lib/lp/services/profile/profile.py
@@ -22,8 +22,8 @@ import sys
 import threading
 
 from breezy import lsprof
-import six
 import oops_datedir_repo.serializer_rfc822
+import six
 from zope.component import (
     adapter,
     getUtility,
diff --git a/lib/lp/services/scripts/__init__.py b/lib/lp/services/scripts/__init__.py
index 42a6f2a..be7059e 100644
--- a/lib/lp/services/scripts/__init__.py
+++ b/lib/lp/services/scripts/__init__.py
@@ -57,7 +57,10 @@ def execute_zcml_for_scripts(use_web_security=False):
     # the conditional block.
     if 'lp.testing.layers' in sys.modules:
         from lp.testing.layers import (
-                FunctionalLayer, BaseLayer, ZopelessLayer)
+            BaseLayer,
+            FunctionalLayer,
+            ZopelessLayer,
+            )
         assert not FunctionalLayer.isSetUp, \
                 'Setting up Zopeless CA when Zopefull CA is already running'
         assert not BaseLayer.isSetUp or ZopelessLayer.isSetUp, """
diff --git a/lib/lp/services/scripts/logger.py b/lib/lp/services/scripts/logger.py
index f5e3242..51cd125 100644
--- a/lib/lp/services/scripts/logger.py
+++ b/lib/lp/services/scripts/logger.py
@@ -46,6 +46,7 @@ from lp.services.webapp.errorlog import (
     ScriptRequest,
     )
 
+
 # Reexport our custom loglevels for old callsites. These callsites
 # should be importing the symbols from lp.services.log.loglevels
 DEBUG2 = loglevels.DEBUG2
diff --git a/lib/lp/services/tarfile_helpers.py b/lib/lp/services/tarfile_helpers.py
index 2978459..36a676e 100644
--- a/lib/lp/services/tarfile_helpers.py
+++ b/lib/lp/services/tarfile_helpers.py
@@ -15,6 +15,7 @@ import tarfile
 import tempfile
 import time
 
+
 # A note about tarballs, BytesIO and unicode. SQLObject returns unicode
 # values for columns which are declared as StringCol. We have to be careful
 # not to pass unicode instances to the tarfile module, because when the
diff --git a/lib/lp/services/temporaryblobstorage/webservice.py b/lib/lp/services/temporaryblobstorage/webservice.py
index 544c9ae..746bae0 100644
--- a/lib/lp/services/temporaryblobstorage/webservice.py
+++ b/lib/lp/services/temporaryblobstorage/webservice.py
@@ -23,6 +23,7 @@ from lp.services.webservice.apihelpers import (
     patch_operations_explicit_version,
     )
 
+
 # ITemporaryBlobStorage
 patch_operations_explicit_version(
     ITemporaryBlobStorage, 'beta', "getProcessedData", "hasBeenProcessed")
diff --git a/lib/lp/services/tests/test_stacktrace.py b/lib/lp/services/tests/test_stacktrace.py
index dedbf77..af1c326 100644
--- a/lib/lp/services/tests/test_stacktrace.py
+++ b/lib/lp/services/tests/test_stacktrace.py
@@ -14,6 +14,7 @@ from lp.services import stacktrace
 from lp.testing import TestCase
 from lp.testing.layers import BaseLayer
 
+
 # This constant must always be equal to the line number on which it lives for
 # the tests to pass.
 MY_LINE_NUMBER = 19
diff --git a/lib/lp/services/webapp/adapter.py b/lib/lp/services/webapp/adapter.py
index 58ae078..740257b 100644
--- a/lib/lp/services/webapp/adapter.py
+++ b/lib/lp/services/webapp/adapter.py
@@ -241,8 +241,7 @@ def summarize_requests():
     secs = get_request_duration()
     request = get_current_browser_request()
     timeline = get_request_timeline(request)
-    from lp.services.webapp.errorlog import (
-        maybe_record_user_requested_oops)
+    from lp.services.webapp.errorlog import maybe_record_user_requested_oops
     maybe_record_user_requested_oops()
     if request.oopsid is None:
         oops_str = ""
diff --git a/lib/lp/services/webapp/batching.py b/lib/lp/services/webapp/batching.py
index 4ce5f0c..3fa427f 100644
--- a/lib/lp/services/webapp/batching.py
+++ b/lib/lp/services/webapp/batching.py
@@ -611,6 +611,7 @@ class StormRangeFactory:
     def rough_length(self):
         """See `IRangeFactory."""
         from lp.services.librarian.model import LibraryFileAlias
+
         # get_select_expr() requires at least one column as a parameter.
         # getorderBy() already knows about columns that can appear
         # in the result set, so let's use them. Moreover, for SELECT
diff --git a/lib/lp/services/webapp/haproxy.py b/lib/lp/services/webapp/haproxy.py
index b945d09..9adeb89 100644
--- a/lib/lp/services/webapp/haproxy.py
+++ b/lib/lp/services/webapp/haproxy.py
@@ -13,6 +13,7 @@ __all__ = [
 
 from lp.services.config import config
 
+
 # This is the global flag, when this is True, the HAProxy view
 # will return 500, it returns 200 otherwise.
 going_down_flag = False
diff --git a/lib/lp/services/webapp/publisher.py b/lib/lp/services/webapp/publisher.py
index 9fb9659..168b22e 100644
--- a/lib/lp/services/webapp/publisher.py
+++ b/lib/lp/services/webapp/publisher.py
@@ -95,6 +95,7 @@ from lp.services.webapp.interfaces import (
 from lp.services.webapp.url import urlappend
 from lp.services.webapp.vhosts import allvhosts
 
+
 # Monkeypatch NotFound to always avoid generating OOPS
 # from NotFound in web service calls.
 error_status(http_client.NOT_FOUND)(NotFound)
@@ -727,9 +728,9 @@ def canonical_url(
         if current_request is not None:
             if WebServiceLayer.providedBy(current_request):
                 from lp.services.webapp.publication import (
-                    LaunchpadBrowserPublication)
-                from lp.services.webapp.servers import (
-                    LaunchpadBrowserRequest)
+                    LaunchpadBrowserPublication,
+                    )
+                from lp.services.webapp.servers import LaunchpadBrowserRequest
                 current_request = LaunchpadBrowserRequest(
                     current_request.bodyStream.getCacheStream(),
                     dict(current_request.environment))
diff --git a/lib/lp/services/webapp/url.py b/lib/lp/services/webapp/url.py
index 60e413c..e438fd9 100644
--- a/lib/lp/services/webapp/url.py
+++ b/lib/lp/services/webapp/url.py
@@ -7,12 +7,12 @@ __metaclass__ = type
 __all__ = ['urlappend', 'urlparse', 'urlsplit']
 
 import six
+import six.moves.urllib.parse as urlparse_module
 from six.moves.urllib.parse import (
     urljoin,
     urlparse as original_urlparse,
     urlsplit as original_urlsplit,
     )
-import six.moves.urllib.parse as urlparse_module
 
 
 def _enable_sftp_in_urlparse():
diff --git a/lib/lp/services/webhooks/model.py b/lib/lp/services/webhooks/model.py
index f26fa73..7c6c4c6 100644
--- a/lib/lp/services/webhooks/model.py
+++ b/lib/lp/services/webhooks/model.py
@@ -14,10 +14,10 @@ from datetime import (
     datetime,
     timedelta,
     )
+import ipaddress
 import re
 import socket
 
-import ipaddress
 import iso8601
 from lazr.delegates import delegate_to
 from lazr.enum import (
diff --git a/lib/lp/services/worlddata/vocabularies.py b/lib/lp/services/worlddata/vocabularies.py
index 59a51ff..8fa3691 100644
--- a/lib/lp/services/worlddata/vocabularies.py
+++ b/lib/lp/services/worlddata/vocabularies.py
@@ -27,6 +27,7 @@ from lp.services.worlddata.interfaces.timezone import ITimezoneNameVocabulary
 from lp.services.worlddata.model.country import Country
 from lp.services.worlddata.model.language import Language
 
+
 # create a sorted list of the common time zone names, with UTC at the start
 _values = sorted(six.ensure_text(tz) for tz in pytz.common_timezones)
 _values.remove('UTC')
diff --git a/lib/lp/services/xmlrpc.py b/lib/lp/services/xmlrpc.py
index 12b01ea..85f9727 100644
--- a/lib/lp/services/xmlrpc.py
+++ b/lib/lp/services/xmlrpc.py
@@ -14,6 +14,7 @@ import socket
 from defusedxml.xmlrpc import monkey_patch
 from six.moves import xmlrpc_client
 
+
 # Protect against various XML parsing vulnerabilities.
 monkey_patch()
 
diff --git a/lib/lp/soyuz/enums.py b/lib/lp/soyuz/enums.py
index 641df6b..4296f1a 100644
--- a/lib/lp/soyuz/enums.py
+++ b/lib/lp/soyuz/enums.py
@@ -36,6 +36,7 @@ from lazr.enum import (
     DBItem,
     )
 
+
 # Regexes that match bug numbers for closing in change logs.
 re_closes = re.compile(
     r"closes:\s*(?:bug)?\#?\s?\d+(?:,\s*(?:bug)?\#?\s?\d+)*", re.I)
diff --git a/lib/lp/soyuz/interfaces/publishing.py b/lib/lp/soyuz/interfaces/publishing.py
index eae5343..cc3cdd5 100644
--- a/lib/lp/soyuz/interfaces/publishing.py
+++ b/lib/lp/soyuz/interfaces/publishing.py
@@ -67,6 +67,7 @@ from lp.soyuz.interfaces.binarypackagerelease import (
     IBinaryPackageReleaseDownloadCount,
     )
 
+
 #
 # Exceptions
 #
diff --git a/lib/lp/soyuz/model/archive.py b/lib/lp/soyuz/model/archive.py
index b549c13..fed398b 100644
--- a/lib/lp/soyuz/model/archive.py
+++ b/lib/lp/soyuz/model/archive.py
@@ -1035,7 +1035,9 @@ class Archive(SQLBase):
             DistributionSourcePackageCache,
             )
         from lp.soyuz.model.distroseriespackagecache import (
-            DistroSeriesPackageCache)
+            DistroSeriesPackageCache,
+            )
+
         # Compiled regexp to remove puntication.
         clean_text = re.compile(r'(,|;|:|\.|\?|!)')
 
@@ -2380,9 +2382,7 @@ class Archive(SQLBase):
 
     def _getExistingOverrideSequence(self, archive, distroseries, pocket,
                                      phased_update_percentage):
-        from lp.soyuz.adapters.overrides import (
-            FromExistingOverridePolicy,
-            )
+        from lp.soyuz.adapters.overrides import FromExistingOverridePolicy
         return [
             FromExistingOverridePolicy(
                 archive, distroseries, None,
@@ -2788,6 +2788,7 @@ class ArchiveSet:
     def getPPAsForUser(self, user):
         """See `IArchiveSet`."""
         from lp.registry.model.person import Person
+
         # If there's no user logged in, then there are no archives.
         if user is None:
             return EmptyResultSet()
@@ -2803,6 +2804,7 @@ class ArchiveSet:
     def getPPADistributionsForUser(self, user):
         """See `IArchiveSet`."""
         from lp.registry.model.distribution import Distribution
+
         # If there's no user logged in, then there are no archives.
         if user is None:
             return EmptyResultSet()
diff --git a/lib/lp/soyuz/model/binarypackagebuild.py b/lib/lp/soyuz/model/binarypackagebuild.py
index 322ff6c..3554ec3 100644
--- a/lib/lp/soyuz/model/binarypackagebuild.py
+++ b/lib/lp/soyuz/model/binarypackagebuild.py
@@ -382,9 +382,9 @@ class BinaryPackageBuild(PackageBuildMixin, SQLBase):
     @property
     def distributionsourcepackagerelease(self):
         """See `IBuild`."""
-        from lp.soyuz.model.distributionsourcepackagerelease \
-             import (
-            DistributionSourcePackageRelease)
+        from lp.soyuz.model.distributionsourcepackagerelease import (
+            DistributionSourcePackageRelease,
+            )
 
         return DistributionSourcePackageRelease(
             distribution=self.distribution,
@@ -468,7 +468,8 @@ class BinaryPackageBuild(PackageBuildMixin, SQLBase):
         """See `IBuild`."""
         # Avoid circular import by importing locally.
         from lp.soyuz.model.distroarchseriesbinarypackagerelease import (
-            DistroArchSeriesBinaryPackageRelease)
+            DistroArchSeriesBinaryPackageRelease,
+            )
         return [DistroArchSeriesBinaryPackageRelease(
             self.distro_arch_series, bp)
             for bp in self.binarypackages]
@@ -866,11 +867,11 @@ class BinaryPackageBuildSet(SpecificBuildFarmJobSourceMixin):
 
     def preloadBuildsData(self, builds):
         # Circular imports.
-        from lp.soyuz.model.distroarchseries import DistroArchSeries
-        from lp.registry.model.distroseries import DistroSeries
         from lp.registry.model.distribution import Distribution
-        from lp.soyuz.model.archive import Archive
+        from lp.registry.model.distroseries import DistroSeries
         from lp.registry.model.person import Person
+        from lp.soyuz.model.archive import Archive
+        from lp.soyuz.model.distroarchseries import DistroArchSeries
         self._prefetchBuildData(builds)
         das = load_related(DistroArchSeries, builds, ['distro_arch_series_id'])
         archives = load_related(Archive, builds, ['archive_id'])
@@ -959,7 +960,9 @@ class BinaryPackageBuildSet(SpecificBuildFarmJobSourceMixin):
         """See `IBinaryPackageBuildSet`."""
         # Circular. :(
         from lp.soyuz.model.archive import (
-            Archive, get_archive_privacy_filter)
+            Archive,
+            get_archive_privacy_filter,
+            )
 
         clauses = [
             BinaryPackageBuild.archive_id == Archive.id,
@@ -1188,10 +1191,8 @@ class BinaryPackageBuildSet(SpecificBuildFarmJobSourceMixin):
         LibraryFileContent respectively) as well as builders related to the
         Builds at hand.
         """
-        from lp.registry.model.sourcepackagename import (
-            SourcePackageName)
-        from lp.soyuz.model.sourcepackagerelease import (
-            SourcePackageRelease)
+        from lp.registry.model.sourcepackagename import SourcePackageName
+        from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
 
         # Prefetching is not needed if the original result set is empty.
         if len(results) == 0:
diff --git a/lib/lp/soyuz/model/distributionsourcepackagecache.py b/lib/lp/soyuz/model/distributionsourcepackagecache.py
index c68f71f..5285eb4 100644
--- a/lib/lp/soyuz/model/distributionsourcepackagecache.py
+++ b/lib/lp/soyuz/model/distributionsourcepackagecache.py
@@ -60,7 +60,8 @@ class DistributionSourcePackageCache(SQLBase):
 
         # import here to avoid circular imports
         from lp.registry.model.distributionsourcepackage import (
-            DistributionSourcePackage)
+            DistributionSourcePackage,
+            )
 
         return DistributionSourcePackage(self.distribution,
             self.sourcepackagename)
diff --git a/lib/lp/soyuz/model/distributionsourcepackagerelease.py b/lib/lp/soyuz/model/distributionsourcepackagerelease.py
index 12b67b9..11fbcdf 100644
--- a/lib/lp/soyuz/model/distributionsourcepackagerelease.py
+++ b/lib/lp/soyuz/model/distributionsourcepackagerelease.py
@@ -140,7 +140,8 @@ class DistributionSourcePackageRelease:
         from lp.registry.model.distroseries import DistroSeries
         from lp.soyuz.model.distroarchseries import DistroArchSeries
         from lp.soyuz.model.distroseriespackagecache import (
-            DistroSeriesPackageCache)
+            DistroSeriesPackageCache,
+            )
         archive_ids = list(self.distribution.all_distro_archive_ids)
         result_row = (
             SQL('DISTINCT ON(BinaryPackageName.name) 0 AS ignore'),
diff --git a/lib/lp/soyuz/model/distroarchseries.py b/lib/lp/soyuz/model/distroarchseries.py
index 0bee6c1..14751a1 100644
--- a/lib/lp/soyuz/model/distroarchseries.py
+++ b/lib/lp/soyuz/model/distroarchseries.py
@@ -298,7 +298,8 @@ class DistroArchSeries(SQLBase):
 
         # import here to avoid circular import problems
         from lp.soyuz.model.distroarchseriesbinarypackagerelease import (
-            DistroArchSeriesBinaryPackageRelease)
+            DistroArchSeriesBinaryPackageRelease,
+            )
 
         # Create a function that will decorate the results, converting
         # them from the find_spec above into DASBPRs.
diff --git a/lib/lp/soyuz/model/distroarchseriesbinarypackage.py b/lib/lp/soyuz/model/distroarchseriesbinarypackage.py
index a2a92f5..679543e 100644
--- a/lib/lp/soyuz/model/distroarchseriesbinarypackage.py
+++ b/lib/lp/soyuz/model/distroarchseriesbinarypackage.py
@@ -74,7 +74,8 @@ class DistroArchSeriesBinaryPackage:
     def cache(self):
         """See IDistroArchSeriesBinaryPackage."""
         from lp.soyuz.model.distroseriespackagecache import (
-            DistroSeriesPackageCache)
+            DistroSeriesPackageCache,
+            )
         query = """
             distroseries = %s AND
             archive IN %s AND
diff --git a/lib/lp/soyuz/model/distroseriesbinarypackage.py b/lib/lp/soyuz/model/distroseriesbinarypackage.py
index 5667c50..2c53cbc 100644
--- a/lib/lp/soyuz/model/distroseriesbinarypackage.py
+++ b/lib/lp/soyuz/model/distroseriesbinarypackage.py
@@ -61,7 +61,8 @@ class DistroSeriesBinaryPackage:
     def cache(self):
         """See IDistroSeriesBinaryPackage."""
         from lp.soyuz.model.distroseriespackagecache import (
-            DistroSeriesPackageCache)
+            DistroSeriesPackageCache,
+            )
         store = Store.of(self.distroseries)
         archive_ids = (
             self.distroseries.distribution.all_distro_archive_ids)
@@ -98,8 +99,7 @@ class DistroSeriesBinaryPackage:
     @property
     def _current_publishings(self):
         # Import here so as to avoid circular import.
-        from lp.soyuz.model.distroarchseries import (
-            DistroArchSeries)
+        from lp.soyuz.model.distroarchseries import DistroArchSeries
         return Store.of(self.distroseries).find(
             BinaryPackagePublishingHistory,
             BinaryPackagePublishingHistory.distroarchseries ==
diff --git a/lib/lp/soyuz/model/publishing.py b/lib/lp/soyuz/model/publishing.py
index 3890bb0..399cc9b 100644
--- a/lib/lp/soyuz/model/publishing.py
+++ b/lib/lp/soyuz/model/publishing.py
@@ -674,7 +674,8 @@ class BinaryPackagePublishingHistory(SQLBase, ArchivePublisherBase):
         """See `IBinaryPackagePublishingHistory`."""
         # Import here to avoid circular import.
         from lp.soyuz.model.distroarchseriesbinarypackagerelease import (
-            DistroArchSeriesBinaryPackageRelease)
+            DistroArchSeriesBinaryPackageRelease,
+            )
 
         return DistroArchSeriesBinaryPackageRelease(
             self.distroarchseries,
@@ -1516,7 +1517,10 @@ class PublishingSet:
     def getChangesFilesForSources(self, one_or_more_source_publications):
         """See `IPublishingSet`."""
         # Avoid circular imports.
-        from lp.soyuz.model.queue import PackageUpload, PackageUploadSource
+        from lp.soyuz.model.queue import (
+            PackageUpload,
+            PackageUploadSource,
+            )
 
         source_publication_ids = self._extractIDs(
             one_or_more_source_publications)
@@ -1544,7 +1548,10 @@ class PublishingSet:
     def getChangesFileLFA(self, spr):
         """See `IPublishingSet`."""
         # Avoid circular imports.
-        from lp.soyuz.model.queue import PackageUpload, PackageUploadSource
+        from lp.soyuz.model.queue import (
+            PackageUpload,
+            PackageUploadSource,
+            )
 
         return IStore(SourcePackagePublishingHistory).find(
             LibraryFileAlias,
diff --git a/lib/lp/soyuz/model/queue.py b/lib/lp/soyuz/model/queue.py
index 712acfb..781d93c 100644
--- a/lib/lp/soyuz/model/queue.py
+++ b/lib/lp/soyuz/model/queue.py
@@ -270,7 +270,8 @@ class PackageUpload(SQLBase):
     def getSourceBuild(self):
         #avoid circular import
         from lp.code.model.sourcepackagerecipebuild import (
-            SourcePackageRecipeBuild)
+            SourcePackageRecipeBuild,
+            )
         from lp.soyuz.model.sourcepackagerelease import SourcePackageRelease
         return Store.of(self).find(
             SourcePackageRecipeBuild,
diff --git a/lib/lp/soyuz/scripts/expire_archive_files.py b/lib/lp/soyuz/scripts/expire_archive_files.py
index de58d19..8602bc5 100755
--- a/lib/lp/soyuz/scripts/expire_archive_files.py
+++ b/lib/lp/soyuz/scripts/expire_archive_files.py
@@ -32,6 +32,7 @@ from lp.soyuz.model.publishing import (
     SourcePackagePublishingHistory,
     )
 
+
 # PPA owners or particular PPAs that we never want to expire.
 NEVER_EXPIRE_PPAS = """
 bzr
diff --git a/lib/lp/soyuz/scripts/gina/packages.py b/lib/lp/soyuz/scripts/gina/packages.py
index d659399..5feb27c 100644
--- a/lib/lp/soyuz/scripts/gina/packages.py
+++ b/lib/lp/soyuz/scripts/gina/packages.py
@@ -50,6 +50,7 @@ from lp.soyuz.scripts.gina import (
     )
 from lp.soyuz.scripts.gina.changelog import parse_changelog
 
+
 #
 # Data setup
 #
diff --git a/lib/lp/soyuz/tests/test_doc.py b/lib/lp/soyuz/tests/test_doc.py
index b1f15dc..122017e 100644
--- a/lib/lp/soyuz/tests/test_doc.py
+++ b/lib/lp/soyuz/tests/test_doc.py
@@ -47,8 +47,10 @@ def lobotomize_stevea():
     code that did not use the ValidPersonOrTeamCache to determine
     validity.
     """
+    from lp.services.identity.interfaces.emailaddress import (
+        EmailAddressStatus,
+        )
     from lp.services.identity.model.emailaddress import EmailAddress
-    from lp.services.identity.interfaces.emailaddress import EmailAddressStatus
     stevea_emailaddress = EmailAddress.byEmail(
             'steve.alexander@xxxxxxxxxxxxxxx')
     stevea_emailaddress.status = EmailAddressStatus.NEW
diff --git a/lib/lp/soyuz/tests/test_packageupload.py b/lib/lp/soyuz/tests/test_packageupload.py
index 9850667..9bd9a66 100644
--- a/lib/lp/soyuz/tests/test_packageupload.py
+++ b/lib/lp/soyuz/tests/test_packageupload.py
@@ -13,12 +13,12 @@ from lazr.restfulclient.errors import (
     BadRequest,
     Unauthorized,
     )
+from six.moves.urllib.request import urlopen
 from testtools.matchers import (
     Equals,
     MatchesListwise,
     MatchesStructure,
     )
-from six.moves.urllib.request import urlopen
 import transaction
 from zope.component import (
     getUtility,
diff --git a/lib/lp/testing/__init__.py b/lib/lp/testing/__init__.py
index 583c569..8fbd261 100644
--- a/lib/lp/testing/__init__.py
+++ b/lib/lp/testing/__init__.py
@@ -177,6 +177,7 @@ from lp.testing.fixture import (
 from lp.testing.karma import KarmaRecorder
 from lp.testing.mail_helpers import pop_notifications
 
+
 # The following names have been imported for the purpose of being
 # exported. They are referred to here to silence lint warnings.
 admin_logged_in
@@ -231,8 +232,8 @@ def reset_logging():
     logging._handlers.clear()
 
     # Reset the setup
-    from zope.testrunner.runner import Runner
     from zope.testrunner.logsupport import Logging
+    from zope.testrunner.runner import Runner
     Logging(Runner()).global_setup()
     lp_sitecustomize.customize_logger()
 
diff --git a/lib/lp/testing/fixture.py b/lib/lp/testing/fixture.py
index a066ebc..418cc52 100644
--- a/lib/lp/testing/fixture.py
+++ b/lib/lp/testing/fixture.py
@@ -118,8 +118,8 @@ class PGBouncerFixture(pgbouncer.fixture.PGBouncerFixture):
         connections.
         """
         from lp.testing.layers import (
-            reconnect_stores,
             is_ca_available,
+            reconnect_stores,
             )
         if is_ca_available():
             reconnect_stores()
diff --git a/lib/lp/testing/html5browser.py b/lib/lp/testing/html5browser.py
index 7dd3a37..81b426f 100644
--- a/lib/lp/testing/html5browser.py
+++ b/lib/lp/testing/html5browser.py
@@ -31,10 +31,11 @@ __all__ = [
 
 import gi
 
+
 gi.require_version('Gtk', '3.0')
 gi.require_version('WebKit', '3.0')
 
-from gi.repository import ( # noqa: E402
+from gi.repository import (  # noqa: E402
     GLib,
     Gtk,
     WebKit,
diff --git a/lib/lp/testing/keyserver/testkeyserver.tac b/lib/lp/testing/keyserver/testkeyserver.tac
index 6ed7fe2..e308e8e 100644
--- a/lib/lp/testing/keyserver/testkeyserver.tac
+++ b/lib/lp/testing/keyserver/testkeyserver.tac
@@ -15,6 +15,7 @@ from lp.services.daemons import readyservice
 from lp.services.scripts import execute_zcml_for_scripts
 from lp.testing.keyserver.web import KeyServerResource
 
+
 # Needed for using IGPGHandler for processing key submit.
 execute_zcml_for_scripts()
 
diff --git a/lib/lp/testing/layers.py b/lib/lp/testing/layers.py
index f6e931b..385d126 100644
--- a/lib/lp/testing/layers.py
+++ b/lib/lp/testing/layers.py
@@ -1285,8 +1285,12 @@ class TwistedLayer(BaseLayer):
     @profiled
     def testSetUp(cls):
         TwistedLayer._save_signals()
-        from twisted.internet import interfaces, reactor
+        from twisted.internet import (
+            interfaces,
+            reactor,
+            )
         from twisted.python import threadpool
+
         # zope.exception demands more of frame objects than
         # twisted.python.failure provides in its fake frames.  This is enough
         # to make it work with them as of 2009-09-16.  See
@@ -1309,7 +1313,10 @@ class TwistedLayer(BaseLayer):
     def testTearDown(cls):
         # Shutdown and obliterate the Twisted threadpool, to plug up leaking
         # threads.
-        from twisted.internet import interfaces, reactor
+        from twisted.internet import (
+            interfaces,
+            reactor,
+            )
         if interfaces.IReactorThreads.providedBy(reactor):
             reactor.suggestThreadPoolSize(0)
             pool = getattr(reactor, 'threadpool', None)
diff --git a/lib/lp/testing/swift/fakeswift.tac b/lib/lp/testing/swift/fakeswift.tac
index c5c95b8..32cf494 100644
--- a/lib/lp/testing/swift/fakeswift.tac
+++ b/lib/lp/testing/swift/fakeswift.tac
@@ -7,13 +7,18 @@
 __metaclass__ = type
 __all__ = []
 
-import os.path
 import logging
+import os.path
 
+from twisted.application import (
+    internet,
+    service,
+    )
 import twisted.web.server
-from twisted.application import internet, service
+
 from lp.testing.swift.fakeswift import Root
 
+
 logging.basicConfig()
 
 storedir = os.environ['SWIFT_ROOT']
diff --git a/lib/lp/testing/tests/test_html5browser.py b/lib/lp/testing/tests/test_html5browser.py
index a512329..bd64569 100644
--- a/lib/lp/testing/tests/test_html5browser.py
+++ b/lib/lp/testing/tests/test_html5browser.py
@@ -25,8 +25,8 @@ from tempfile import NamedTemporaryFile
 
 from lp.testing import TestCase
 from lp.testing.html5browser import (
-    Command,
     Browser,
+    Command,
     )
 
 
diff --git a/lib/lp/testing/tests/test_inlinetests.py b/lib/lp/testing/tests/test_inlinetests.py
index fced9ec..ff47357 100644
--- a/lib/lp/testing/tests/test_inlinetests.py
+++ b/lib/lp/testing/tests/test_inlinetests.py
@@ -5,8 +5,8 @@
 
 import doctest
 from doctest import (
-    NORMALIZE_WHITESPACE,
     ELLIPSIS,
+    NORMALIZE_WHITESPACE,
     )
 
 from lp import testing
diff --git a/lib/lp/testing/tests/test_standard_yuixhr_test_template.py b/lib/lp/testing/tests/test_standard_yuixhr_test_template.py
index dedd3f8..5697c1f 100644
--- a/lib/lp/testing/tests/test_standard_yuixhr_test_template.py
+++ b/lib/lp/testing/tests/test_standard_yuixhr_test_template.py
@@ -15,6 +15,7 @@ from lp.testing.yuixhr import (
     setup,
     )
 
+
 # This is one half of a YUI app test.  The other half is a .js test of
 # exactly the same name as your Python file, just with different file
 # extensions.
diff --git a/lib/lp/testing/tests/test_yuixhr_fixture.py b/lib/lp/testing/tests/test_yuixhr_fixture.py
index d383d80..e4bb87a 100644
--- a/lib/lp/testing/tests/test_yuixhr_fixture.py
+++ b/lib/lp/testing/tests/test_yuixhr_fixture.py
@@ -17,6 +17,7 @@ from lp.testing.yuixhr import (
     setup,
     )
 
+
 # The following are the fixtures needed by the tests.
 
 # We use this variable for test results.
diff --git a/lib/lp/translations/browser/customlanguagecode.py b/lib/lp/translations/browser/customlanguagecode.py
index 480d7fd..bce684d 100644
--- a/lib/lp/translations/browser/customlanguagecode.py
+++ b/lib/lp/translations/browser/customlanguagecode.py
@@ -36,6 +36,7 @@ from lp.translations.interfaces.customlanguagecode import (
     IHasCustomLanguageCodes,
     )
 
+
 # Regex for allowable custom language codes.
 CODE_PATTERN = "[a-zA-Z0-9_-]+$"
 
diff --git a/lib/lp/translations/model/customlanguagecode.py b/lib/lp/translations/model/customlanguagecode.py
index d6f5965..c3db356 100644
--- a/lib/lp/translations/model/customlanguagecode.py
+++ b/lib/lp/translations/model/customlanguagecode.py
@@ -72,7 +72,8 @@ class CustomLanguageCode(StormBase):
         """See `ICustomLanguageCode`."""
         # Avoid circular imports
         from lp.registry.model.distributionsourcepackage import (
-            DistributionSourcePackage)
+            DistributionSourcePackage,
+            )
         if self.product:
             return self.product
         else:
diff --git a/lib/lp/translations/model/pofile.py b/lib/lp/translations/model/pofile.py
index e7d2809..7f28828 100644
--- a/lib/lp/translations/model/pofile.py
+++ b/lib/lp/translations/model/pofile.py
@@ -1503,9 +1503,9 @@ class POFileSet:
     def getPOFilesTouchedSince(self, date):
         """See `IPOFileSet`."""
         # Avoid circular imports.
-        from lp.translations.model.potemplate import POTemplate
         from lp.registry.model.distroseries import DistroSeries
         from lp.registry.model.productseries import ProductSeries
+        from lp.translations.model.potemplate import POTemplate
 
         store = IMasterStore(POTemplate)
 
diff --git a/lib/lp/translations/model/potmsgset.py b/lib/lp/translations/model/potmsgset.py
index 456dc8d..4cc6085 100644
--- a/lib/lp/translations/model/potmsgset.py
+++ b/lib/lp/translations/model/potmsgset.py
@@ -87,6 +87,7 @@ from lp.translations.model.translationtemplateitem import (
     )
 from lp.translations.utilities.validate import validate_translation
 
+
 # Msgids that indicate translation credit messages, and their
 # contexts and type.
 credits_message_info = {
diff --git a/lib/lp/translations/model/translationimportqueue.py b/lib/lp/translations/model/translationimportqueue.py
index bdb55ff..1e01cc2 100644
--- a/lib/lp/translations/model/translationimportqueue.py
+++ b/lib/lp/translations/model/translationimportqueue.py
@@ -13,11 +13,11 @@ from io import BytesIO
 import logging
 from operator import attrgetter
 import os.path
+import posixpath
 import re
 import tarfile
 from textwrap import dedent
 
-import posixpath
 import pytz
 import six
 from storm.expr import (
@@ -862,7 +862,10 @@ def list_product_request_targets(user, status_condition):
     :return: A list of `Product`, distinct and ordered by name.
     """
     # Avoid circular imports.
-    from lp.registry.model.product import Product, ProductSet
+    from lp.registry.model.product import (
+        Product,
+        ProductSet,
+        )
     from lp.registry.model.productseries import ProductSeries
 
     privacy_filter = ProductSet.getProductPrivacyFilter(user)
diff --git a/lib/lp/translations/model/translationtemplatesbuild.py b/lib/lp/translations/model/translationtemplatesbuild.py
index ea6009c..0e5709c 100644
--- a/lib/lp/translations/model/translationtemplatesbuild.py
+++ b/lib/lp/translations/model/translationtemplatesbuild.py
@@ -222,6 +222,7 @@ class TranslationTemplatesBuild(SpecificBuildFarmJobSourceMixin,
     def preloadBuildsData(cls, builds):
         # Circular imports.
         from lp.services.librarian.model import LibraryFileAlias
+
         # Load the related branches.
         branches = load_related(
             Branch, builds, ['branch_id'])
diff --git a/lib/lp/translations/scripts/reupload_translations.py b/lib/lp/translations/scripts/reupload_translations.py
index 56644ca..b5170c0 100644
--- a/lib/lp/translations/scripts/reupload_translations.py
+++ b/lib/lp/translations/scripts/reupload_translations.py
@@ -94,7 +94,8 @@ class ReuploadPackageTranslations(LaunchpadScript):
         """Get translations for `package` re-uploaded."""
         # Avoid circular imports.
         from lp.soyuz.model.packagetranslationsuploadjob import (
-            _filter_ubuntu_translation_file)
+            _filter_ubuntu_translation_file,
+            )
 
         self.logger.info("Processing %s" % package.displayname)
         tarball_aliases = package.getLatestTranslationsUploads()
diff --git a/lib/lp/translations/scripts/translations_to_branch.py b/lib/lp/translations/scripts/translations_to_branch.py
index f07abd5..189d82a 100644
--- a/lib/lp/translations/scripts/translations_to_branch.py
+++ b/lib/lp/translations/scripts/translations_to_branch.py
@@ -13,6 +13,7 @@ from datetime import (
     )
 import os.path
 
+
 # FIRST Ensure correct plugins are loaded. Do not delete this comment or the
 # line below this comment.
 import lp.codehosting  # noqa: F401  # isort: split
diff --git a/lib/lp/translations/tests/test_setcurrenttranslation.py b/lib/lp/translations/tests/test_setcurrenttranslation.py
index edbfdc8..e348ddc 100644
--- a/lib/lp/translations/tests/test_setcurrenttranslation.py
+++ b/lib/lp/translations/tests/test_setcurrenttranslation.py
@@ -16,6 +16,7 @@ from lp.translations.tests.helpers import (
     summarize_current_translations,
     )
 
+
 # This test is based on the matrix described on:
 #  https://dev.launchpad.net/Translations/Specs
 #     /UpstreamImportIntoUbuntu/FixingIsImported
diff --git a/lib/lp/translations/tests/test_translationpermission.py b/lib/lp/translations/tests/test_translationpermission.py
index 6a12ef9..42114bc 100644
--- a/lib/lp/translations/tests/test_translationpermission.py
+++ b/lib/lp/translations/tests/test_translationpermission.py
@@ -12,6 +12,7 @@ from lp.testing.layers import ZopelessDatabaseLayer
 from lp.translations.interfaces.translationgroup import TranslationPermission
 from lp.translations.interfaces.translator import ITranslatorSet
 
+
 # A user can be translating either a translation that's not covered by a
 # translation team ("untended"), or one that is ("tended"), or one whose
 # translation team the user is a member of ("member").
diff --git a/lib/lp/translations/utilities/translation_import.py b/lib/lp/translations/utilities/translation_import.py
index f931b82..e7a4729 100644
--- a/lib/lp/translations/utilities/translation_import.py
+++ b/lib/lp/translations/utilities/translation_import.py
@@ -11,8 +11,8 @@ __all__ = [
 
 import datetime
 from operator import attrgetter
-
 import posixpath
+
 import pytz
 import six
 from storm.exceptions import TimeoutError
diff --git a/lib/lp/translations/utilities/translationmerger.py b/lib/lp/translations/utilities/translationmerger.py
index 7164395..93dbbb4 100644
--- a/lib/lp/translations/utilities/translationmerger.py
+++ b/lib/lp/translations/utilities/translationmerger.py
@@ -62,7 +62,8 @@ def merge_pofiletranslators(from_template, to_template):
     """
     # Import here to avoid circular import.
     from lp.translations.interfaces.pofiletranslator import (
-        IPOFileTranslatorSet)
+        IPOFileTranslatorSet,
+        )
 
     pofiletranslatorset = getUtility(IPOFileTranslatorSet)
     affected_rows = pofiletranslatorset.getForTemplate(from_template)
diff --git a/lib/lp_sitecustomize.py b/lib/lp_sitecustomize.py
index a374bf3..1325c1d 100644
--- a/lib/lp_sitecustomize.py
+++ b/lib/lp_sitecustomize.py
@@ -31,7 +31,10 @@ def add_custom_loglevels():
     # override. BLATHER is between INFO and DEBUG, so we can leave it.
     # TRACE conflicts with DEBUG6, and since we are not using ZEO, we
     # just overwrite the level string by calling addLevelName.
-    from ZODB.loglevels import BLATHER, TRACE
+    from ZODB.loglevels import (
+        BLATHER,
+        TRACE,
+        )
 
     # Confirm our above assumptions, and silence lint at the same time.
     assert BLATHER == 15
diff --git a/scripts/memcached-stats.py b/scripts/memcached-stats.py
index c3e4883..02b63b3 100755
--- a/scripts/memcached-stats.py
+++ b/scripts/memcached-stats.py
@@ -20,6 +20,7 @@ from zope.component import getUtility
 from lp.services.memcache.interfaces import IMemcacheClient
 from lp.services.scripts import execute_zcml_for_scripts
 
+
 # The interesting bits we pull from the memcached stats.
 INTERESTING_KEYS = [
     'cmd_set', # Number of sets.
diff --git a/scripts/rosetta/merge-existing-packagings.py b/scripts/rosetta/merge-existing-packagings.py
index 9c0178b..5befd28 100755
--- a/scripts/rosetta/merge-existing-packagings.py
+++ b/scripts/rosetta/merge-existing-packagings.py
@@ -7,7 +7,9 @@ __metaclass__ = type
 
 import _pythonpath  # noqa: F401
 
-from lp.translations.utilities.translationmerger import MergeExistingPackagings
+from lp.translations.utilities.translationmerger import (
+    MergeExistingPackagings,
+    )
 
 
 if __name__ == '__main__':
diff --git a/scripts/rosetta/message-sharing-merge.py b/scripts/rosetta/message-sharing-merge.py
index c4804b6..cd71c36 100755
--- a/scripts/rosetta/message-sharing-merge.py
+++ b/scripts/rosetta/message-sharing-merge.py
@@ -9,6 +9,7 @@ import _pythonpath  # noqa: F401
 
 from lp.translations.utilities.translationmerger import MessageSharingMerge
 
+
 # This script merges POTMsgSets for sharing POTemplates.  This involves
 # deleting records that we'd never delete otherwise.  So before running,
 # make sure rosettaadmin has the privileges to delete POTMsgSets and
diff --git a/scripts/wsgi-archive-auth.py b/scripts/wsgi-archive-auth.py
index 30c3096..3438c1b 100755
--- a/scripts/wsgi-archive-auth.py
+++ b/scripts/wsgi-archive-auth.py
@@ -22,6 +22,7 @@ __all__ = [
 import os.path
 import sys
 
+
 scripts_dir = os.path.dirname(os.path.abspath(os.path.realpath(__file__)))
 if scripts_dir not in sys.path:
     sys.path.insert(0, scripts_dir)
@@ -34,7 +35,7 @@ sys.modules.pop("sitecustomize", None)
 
 import _pythonpath  # noqa: F401,E402
 
-from lp.soyuz.wsgi.archiveauth import check_password # noqa: E402
+from lp.soyuz.wsgi.archiveauth import check_password  # noqa: E402
 
 
 def main():
diff --git a/test_on_merge.py b/test_on_merge.py
index 4cc7898..56aa4bc 100755
--- a/test_on_merge.py
+++ b/test_on_merge.py
@@ -28,6 +28,7 @@ import psycopg2
 
 from lp.services.database import activity_cols
 
+
 # The TIMEOUT setting (expressed in seconds) affects how long a test will run
 # before it is deemed to be hung, and then appropriately terminated.
 # It's principal use is preventing a PQM job from hanging indefinitely and
diff --git a/utilities/community-contributions.py b/utilities/community-contributions.py
index 662d374..7ca2e41 100755
--- a/utilities/community-contributions.py
+++ b/utilities/community-contributions.py
@@ -39,7 +39,10 @@ Options:
 # For understanding the code, you may find it helpful to see
 # bzrlib/log.py and http://bazaar-vcs.org/Integrating_with_Bazaar.
 
-from __future__ import absolute_import, print_function
+from __future__ import (
+    absolute_import,
+    print_function,
+    )
 
 import getopt
 import re
diff --git a/utilities/format-imports b/utilities/format-imports
index 257b773..5498f4a 100755
--- a/utilities/format-imports
+++ b/utilities/format-imports
@@ -133,8 +133,10 @@ import re
 import sys
 from textwrap import dedent
 
+
 sys.path[0:0] = [os.path.dirname(__file__)]
-from python_standard_libs import python_standard_libs # noqa: E402
+from python_standard_libs import python_standard_libs  # noqa: E402
+
 
 # python_standard_libs is only used for membership tests.
 python_standard_libs = frozenset(python_standard_libs)
diff --git a/utilities/list-pages b/utilities/list-pages
index 47ea394..2f584ab 100755
--- a/utilities/list-pages
+++ b/utilities/list-pages
@@ -50,8 +50,14 @@ import os
 import six
 from zope.app.wsgi.testlayer import BrowserLayer
 from zope.browserpage.simpleviewclass import simple
-from zope.component import adapter, getGlobalSiteManager
-from zope.interface import directlyProvides, implementer
+from zope.component import (
+    adapter,
+    getGlobalSiteManager,
+    )
+from zope.interface import (
+    directlyProvides,
+    implementer,
+    )
 from zope.publisher.interfaces.browser import IDefaultBrowserLayer
 
 from lp.services.config import config
diff --git a/utilities/paste b/utilities/paste
index abc27b8..2787a3a 100755
--- a/utilities/paste
+++ b/utilities/paste
@@ -16,6 +16,7 @@ from six.moves.http_cookiejar import Cookie
 from six.moves.urllib.parse import urljoin
 from zope.testbrowser.browser import Browser
 
+
 # Should we be able to override any of these?
 AUTH_FILE = '~/.lp_auth_cookie'
 PRIVATE_PASTE_HOST = 'pastebin.canonical.com'
diff --git a/utilities/python_standard_libs.py b/utilities/python_standard_libs.py
index 9fd706e..6588d0c 100644
--- a/utilities/python_standard_libs.py
+++ b/utilities/python_standard_libs.py
@@ -13,8 +13,12 @@ updated from time to time.
 
 # Run this to generate a new module list.
 if __name__ == '__main__':
+    from sys import (
+        stdout,
+        version_info,
+        )
+
     from lxml import html
-    from sys import version_info, stdout
     modindex_url = (
         "http://docs.python.org/release/";
         "{0}.{1}.{2}/modindex.html").format(*version_info)
diff --git a/utilities/update-copyright b/utilities/update-copyright
index b0729c6..7af85ef 100755
--- a/utilities/update-copyright
+++ b/utilities/update-copyright
@@ -19,6 +19,7 @@ from subprocess import (
     )
 import sys
 
+
 # This script lives in the 'utilites' directory.
 UTILITIES_DIR = os.path.dirname(__file__)
 CURRENT_YEAR = date.today().year
diff --git a/utilities/update-sourcecode b/utilities/update-sourcecode
index 107460a..df0dac7 100755
--- a/utilities/update-sourcecode
+++ b/utilities/update-sourcecode
@@ -12,7 +12,7 @@ import sys
 sys.path.insert(0,
     os.path.join(os.path.dirname(os.path.dirname(__file__)), 'lib'))
 
-from devscripts import sourcecode # noqa: E402
+from devscripts import sourcecode  # noqa: E402
 
 
 if __name__ == '__main__':