← Back to team overview

launchpad-reviewers team mailing list archive

[Merge] ~cristiangsp/launchpad:linting-e402 into launchpad:master

 

Cristian Gonzalez has proposed merging ~cristiangsp/launchpad:linting-e402 into launchpad:master.

Commit message:
Fixing E402 linting errors

Requested reviews:
  Launchpad code reviewers (launchpad-reviewers)

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

Fixing E402 linting errors
-- 
Your team Launchpad code reviewers is requested to review the proposed merge of ~cristiangsp/launchpad:linting-e402 into launchpad:master.
diff --git a/lib/lp/app/__init__.py b/lib/lp/app/__init__.py
index e79d7bd..7006d36 100644
--- a/lib/lp/app/__init__.py
+++ b/lib/lp/app/__init__.py
@@ -15,10 +15,8 @@ __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
-
-
-itemswidgets.EXPLICIT_EMPTY_SELECTION = False
-
 # 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/bugs/interfaces/bug.py b/lib/lp/bugs/interfaces/bug.py
index 4c14118..5fde710 100644
--- a/lib/lp/bugs/interfaces/bug.py
+++ b/lib/lp/bugs/interfaces/bug.py
@@ -1029,7 +1029,7 @@ 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
+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 f0241d4..3913944 100644
--- a/lib/lp/bugs/interfaces/bugsubscription.py
+++ b/lib/lp/bugs/interfaces/bugsubscription.py
@@ -86,5 +86,5 @@ 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
+from lp.bugs.interfaces.bug import IBug # noqa: E402
 patch_reference_property(IBugSubscription, 'bug', IBug)
diff --git a/lib/lp/bugs/model/bug.py b/lib/lp/bugs/model/bug.py
index c1cc4c8..4f4ea06 100644
--- a/lib/lp/bugs/model/bug.py
+++ b/lib/lp/bugs/model/bug.py
@@ -75,6 +75,7 @@ from zope.component import getUtility
 from zope.contenttype import guess_content_type
 from zope.event import notify
 from zope.interface import implementer
+from zope.security import checker
 from zope.security.interfaces import Unauthorized
 from zope.security.proxy import (
     ProxyFactory,
@@ -2385,7 +2386,6 @@ class StructuralSubscriptionSet(FrozenSetBasedSet):
 # writing ZCML tedious, so I've opted for registering custom checkers (see
 # lp_sitecustomize for some other jiggery pokery in the same vein) while I
 # seek a better solution.
-from zope.security import checker
 checker_for_frozen_set = checker.getCheckerForInstancesOf(frozenset)
 checker_for_subscriber_set = checker.NamesChecker(["sorted"])
 checker_for_subscription_set = checker.NamesChecker(["sorted", "subscribers"])
diff --git a/lib/lp/code/bzr.py b/lib/lp/code/bzr.py
index 88d7abb..bac9976 100644
--- a/lib/lp/code/bzr.py
+++ b/lib/lp/code/bzr.py
@@ -21,9 +21,6 @@ __all__ = [
 # line below this comment.
 import lp.codehosting
 
-# Silence lint warning.
-lp.codehosting
-
 from breezy.branch import UnstackableBranchFormat
 from breezy.bzr.branch import (
     BranchReferenceFormat,
@@ -77,6 +74,8 @@ from lazr.enum import (
     )
 import six
 
+# Silence lint warning.
+lp.codehosting
 
 def _format_enum(num, format, format_string=None, description=None):
     instance = format()
diff --git a/lib/lp/codehosting/__init__.py b/lib/lp/codehosting/__init__.py
index c194128..eff84a0 100644
--- a/lib/lp/codehosting/__init__.py
+++ b/lib/lp/codehosting/__init__.py
@@ -20,6 +20,7 @@ from breezy import ui as brz_ui
 from breezy.branch import Branch
 from breezy.library_state import BzrLibraryState as BrzLibraryState
 from breezy.plugin import load_plugins as brz_load_plugins
+import breezy.plugins.loom.branch
 # This import is needed so that brz's logger gets registered.
 import breezy.trace
 from zope.security import checker
@@ -82,6 +83,5 @@ 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
 breezy.plugins.loom.branch
 dont_wrap_class_and_subclasses(Branch)
diff --git a/lib/lp/codehosting/puller/__init__.py b/lib/lp/codehosting/puller/__init__.py
index 48ec941..e1582ed 100644
--- a/lib/lp/codehosting/puller/__init__.py
+++ b/lib/lp/codehosting/puller/__init__.py
@@ -10,14 +10,13 @@ import datetime
 import pytz
 from twisted.internet import defer
 
+from lp.codehosting.puller.scheduler import LockError
 
 def get_lock_id_for_branch_id(branch_id):
     """Return the lock id that should be used for a branch with the passed id.
     """
     return 'worker-for-branch-%s@supermirror' % (branch_id,)
 
-from lp.codehosting.puller.scheduler import LockError
-
 UTC = pytz.timezone('UTC')
 
 
diff --git a/lib/lp/registry/interfaces/product.py b/lib/lp/registry/interfaces/product.py
index e5ac436..b770b13 100644
--- a/lib/lp/registry/interfaces/product.py
+++ b/lib/lp/registry/interfaces/product.py
@@ -1184,7 +1184,7 @@ class InvalidProductName(LaunchpadValidationError):
 
 
 # Fix circular imports.
-from lp.registry.interfaces.distributionsourcepackage import (
+from lp.registry.interfaces.distributionsourcepackage import ( # noqa: E402
     IDistributionSourcePackage)
 patch_reference_property(
     IDistributionSourcePackage, 'upstream_product', IProduct)
diff --git a/lib/lp/scripts/utilities/importpedant.py b/lib/lp/scripts/utilities/importpedant.py
index dc837e5..36d819b 100644
--- a/lib/lp/scripts/utilities/importpedant.py
+++ b/lib/lp/scripts/utilities/importpedant.py
@@ -9,16 +9,15 @@ import types
 import six
 from six.moves import builtins
 
-
-original_import = builtins.__import__
-naughty_imports = set()
-
 # Silence bogus warnings from Hardy's python-pkg-resources package.
 import warnings
 warnings.filterwarnings('ignore', category=UserWarning, append=True,
                         message=r'Module .*? is being added to sys.path')
 
 
+original_import = builtins.__import__
+naughty_imports = set()
+
 # Sometimes, third-party modules don't export all of their public APIs through
 # __all__. The following dict maps from such modules to a list of attributes
 # that are allowed to be imported, whether or not they are in __all__.
diff --git a/lib/lp/scripts/utilities/warninghandler.py b/lib/lp/scripts/utilities/warninghandler.py
index 3620a1c..88827e6 100644
--- a/lib/lp/scripts/utilities/warninghandler.py
+++ b/lib/lp/scripts/utilities/warninghandler.py
@@ -6,10 +6,24 @@
 __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
+
+# 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
 
 
 class WarningReport:
@@ -58,21 +72,6 @@ class ImportantInfo:
             L.append('request url: %s' % self.requesturl)
         return '\n'.join(L)
 
-# ViewPageTemplateFile has .filename.
-from zope.browserpage import ViewPageTemplateFile
-
-# PythonExpr has .text, the text of the expression.
-from zope.tales.pythonexpr import PythonExpr
-
-# 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
-
 
 def find_important_info():
     stack = inspect.stack()
diff --git a/lib/lp/services/job/celeryjob.py b/lib/lp/services/job/celeryjob.py
index b4ae220..cc374c3 100644
--- a/lib/lp/services/job/celeryjob.py
+++ b/lib/lp/services/job/celeryjob.py
@@ -6,23 +6,6 @@
 Because celery sets up configuration at import time, code that is not designed
 to use Celery may break if this is used.
 """
-
-__metaclass__ = type
-
-__all__ = [
-    'celery_app',
-    'celery_run_job',
-    'celery_run_job_ignore_result',
-    'find_missing_ready',
-    'run_missing_ready',
-    ]
-
-from logging import info
-import os
-from uuid import uuid4
-
-
-os.environ.setdefault('CELERY_CONFIG_MODULE', 'lp.services.job.celeryconfig')
 from celery import (
     Celery,
     Task,
@@ -46,9 +29,24 @@ from lp.services.job.runner import (
     )
 from lp.services import scripts
 
+__metaclass__ = type
 
-celery_app = Celery()
+__all__ = [
+    'celery_app',
+    'celery_run_job',
+    'celery_run_job_ignore_result',
+    'find_missing_ready',
+    'run_missing_ready',
+    ]
 
+from logging import info
+import os
+from uuid import uuid4
+
+
+os.environ.setdefault('CELERY_CONFIG_MODULE', 'lp.services.job.celeryconfig')
+
+celery_app = Celery()
 
 class CeleryRunJob(RunJob):
     """The Celery Task that runs a job."""
diff --git a/lib/lp/services/job/tests/celery_helpers.py b/lib/lp/services/job/tests/celery_helpers.py
index b0d5ba4..c378b6f 100644
--- a/lib/lp/services/job/tests/celery_helpers.py
+++ b/lib/lp/services/job/tests/celery_helpers.py
@@ -8,14 +8,14 @@ __all__ = [
     'pop_notifications'
     ]
 
+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
 
-from celery.task import task
-
 
 @task
 def pop_notifications():
diff --git a/lib/lp/services/scripts/tests/loglevels.py b/lib/lp/services/scripts/tests/loglevels.py
index 3849fc4..edf50ca 100644
--- a/lib/lp/services/scripts/tests/loglevels.py
+++ b/lib/lp/services/scripts/tests/loglevels.py
@@ -9,6 +9,13 @@ Used by test_logger.txt.
 __metaclass__ = type
 __all__ = []
 
+from optparse import OptionParser
+
+from lp.services.scripts.logger import (
+    logger,
+    logger_options,
+    )
+
 # Monkey patch time.gmtime to make our tests easier to read.
 import time
 
@@ -18,13 +25,6 @@ def fake_gmtime(ignored_seconds):
     return (1985, 12, 21, 13, 45, 55, 5, 355, 0)
 time.gmtime = fake_gmtime
 
-from optparse import OptionParser
-
-from lp.services.scripts.logger import (
-    logger,
-    logger_options,
-    )
-
 parser = OptionParser()
 logger_options(parser)
 
diff --git a/lib/lp/testing/html5browser.py b/lib/lp/testing/html5browser.py
index b314667..ceee93c 100644
--- a/lib/lp/testing/html5browser.py
+++ b/lib/lp/testing/html5browser.py
@@ -31,9 +31,6 @@ __all__ = [
 
 import gi
 
-gi.require_version('Gtk', '3.0')
-gi.require_version('WebKit', '3.0')
-
 from gi.repository import (
     GLib,
     Gtk,
@@ -41,6 +38,10 @@ from gi.repository import (
     )
 
 
+gi.require_version('Gtk', '3.0')
+gi.require_version('WebKit', '3.0')
+
+
 class Command:
     """A representation of the status and result of a command."""
     STATUS_RUNNING = object()
diff --git a/lib/lp/testing/swift/fakeswift.tac b/lib/lp/testing/swift/fakeswift.tac
index 742658d..c5c95b8 100644
--- a/lib/lp/testing/swift/fakeswift.tac
+++ b/lib/lp/testing/swift/fakeswift.tac
@@ -12,11 +12,10 @@ import logging
 
 import twisted.web.server
 from twisted.application import internet, service
+from lp.testing.swift.fakeswift import Root
 
 logging.basicConfig()
 
-from lp.testing.swift.fakeswift import Root
-
 storedir = os.environ['SWIFT_ROOT']
 assert os.path.exists(storedir)
 
diff --git a/scripts/wsgi-archive-auth.py b/scripts/wsgi-archive-auth.py
index b5490ee..c872c4c 100755
--- a/scripts/wsgi-archive-auth.py
+++ b/scripts/wsgi-archive-auth.py
@@ -32,9 +32,9 @@ top = os.path.dirname(scripts_dir)
 sys.modules.pop("site", None)
 sys.modules.pop("sitecustomize", None)
 
-import _pythonpath  # noqa: F401
+import _pythonpath  # noqa: F401 E402
 
-from lp.soyuz.wsgi.archiveauth import check_password
+from lp.soyuz.wsgi.archiveauth import check_password # noqa: E402
 
 
 def main():
diff --git a/utilities/format-imports b/utilities/format-imports
index 1606a8a..89cc047 100755
--- a/utilities/format-imports
+++ b/utilities/format-imports
@@ -134,7 +134,7 @@ import sys
 from textwrap import dedent
 
 sys.path[0:0] = [os.path.dirname(__file__)]
-from python_standard_libs import python_standard_libs
+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/update-sourcecode b/utilities/update-sourcecode
index a10eb01..107460a 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
+from devscripts import sourcecode # noqa: E402
 
 
 if __name__ == '__main__':