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

Proposed by Cristian Gonzalez
Status: Merged
Approved by: Cristian Gonzalez
Approved revision: 9721b47f6edc29e87610b29cbd6116cecd6d4bfd
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cristiangsp/launchpad:linting-e402
Merge into: launchpad:master
Diff against target: 351 lines (+44/-55)
18 files modified
lib/lp/app/__init__.py (+2/-4)
lib/lp/bugs/interfaces/bug.py (+1/-1)
lib/lp/bugs/interfaces/bugsubscription.py (+1/-1)
lib/lp/bugs/model/bug.py (+1/-1)
lib/lp/code/bzr.py (+1/-4)
lib/lp/codehosting/__init__.py (+1/-1)
lib/lp/codehosting/puller/__init__.py (+1/-2)
lib/lp/registry/interfaces/product.py (+1/-1)
lib/lp/scripts/utilities/importpedant.py (+4/-5)
lib/lp/scripts/utilities/warninghandler.py (+15/-16)
lib/lp/services/job/celeryjob.py (+1/-2)
lib/lp/services/job/tests/celery_helpers.py (+2/-2)
lib/lp/services/scripts/tests/loglevels.py (+7/-8)
lib/lp/testing/html5browser.py (+1/-1)
lib/lp/testing/swift/fakeswift.tac (+1/-2)
scripts/wsgi-archive-auth.py (+2/-2)
utilities/format-imports (+1/-1)
utilities/update-sourcecode (+1/-1)
Reviewer Review Type Date Requested Status
Colin Watson (community) Approve
Review via email: mp+406632@code.launchpad.net

Commit message

Fixing E402 linting errors

Description of the change

Fixing E402 linting errors

To post a comment you must log in.
Revision history for this message
Colin Watson (cjwatson) :
review: Approve
Revision history for this message
Colin Watson (cjwatson) :
review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
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__ = []
15# values, but they kindly left this global variable for you to monkey patch if15# values, but they kindly left this global variable for you to monkey patch if
16# you want the old behaviour, just like we do.16# you want the old behaviour, just like we do.
17from zope.formlib import itemswidgets17from zope.formlib import itemswidgets
18
19
20itemswidgets.EXPLICIT_EMPTY_SELECTION = False
21
22# Load versioninfo.py so that we get errors on start-up rather than waiting18# Load versioninfo.py so that we get errors on start-up rather than waiting
23# for first page load.19# for first page load.
24import lp.app.versioninfo # noqa: F40120import lp.app.versioninfo # noqa: F401
21
22itemswidgets.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)
1029# In order to avoid circular dependencies, we only import1029# In order to avoid circular dependencies, we only import
1030# IBugSubscription (which itself imports IBug) here, and assign it as1030# IBugSubscription (which itself imports IBug) here, and assign it as
1031# the value type for the `subscriptions` collection.1031# the value type for the `subscriptions` collection.
1032from lp.bugs.interfaces.bugsubscription import IBugSubscription1032from lp.bugs.interfaces.bugsubscription import IBugSubscription # noqa: E402
1033patch_collection_property(IBug, 'subscriptions', IBugSubscription)1033patch_collection_property(IBug, 'subscriptions', IBugSubscription)
10341034
10351035
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):
86# In order to avoid circular dependencies, we only import86# In order to avoid circular dependencies, we only import
87# IBug (which itself imports IBugSubscription) here, and assign it as87# IBug (which itself imports IBugSubscription) here, and assign it as
88# the value type for the `bug` reference.88# the value type for the `bug` reference.
89from lp.bugs.interfaces.bug import IBug89from lp.bugs.interfaces.bug import IBug # noqa: E402
90patch_reference_property(IBugSubscription, 'bug', IBug)90patch_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
75from zope.contenttype import guess_content_type75from zope.contenttype import guess_content_type
76from zope.event import notify76from zope.event import notify
77from zope.interface import implementer77from zope.interface import implementer
78from zope.security import checker
78from zope.security.interfaces import Unauthorized79from zope.security.interfaces import Unauthorized
79from zope.security.proxy import (80from zope.security.proxy import (
80 ProxyFactory,81 ProxyFactory,
@@ -2385,7 +2386,6 @@ class StructuralSubscriptionSet(FrozenSetBasedSet):
2385# writing ZCML tedious, so I've opted for registering custom checkers (see2386# writing ZCML tedious, so I've opted for registering custom checkers (see
2386# lp_sitecustomize for some other jiggery pokery in the same vein) while I2387# lp_sitecustomize for some other jiggery pokery in the same vein) while I
2387# seek a better solution.2388# seek a better solution.
2388from zope.security import checker
2389checker_for_frozen_set = checker.getCheckerForInstancesOf(frozenset)2389checker_for_frozen_set = checker.getCheckerForInstancesOf(frozenset)
2390checker_for_subscriber_set = checker.NamesChecker(["sorted"])2390checker_for_subscriber_set = checker.NamesChecker(["sorted"])
2391checker_for_subscription_set = checker.NamesChecker(["sorted", "subscribers"])2391checker_for_subscription_set = checker.NamesChecker(["sorted", "subscribers"])
diff --git a/lib/lp/code/bzr.py b/lib/lp/code/bzr.py
index 88d7abb..e823fc2 100644
--- a/lib/lp/code/bzr.py
+++ b/lib/lp/code/bzr.py
@@ -19,10 +19,7 @@ __all__ = [
1919
20# FIRST Ensure correct plugins are loaded. Do not delete this comment or the20# FIRST Ensure correct plugins are loaded. Do not delete this comment or the
21# line below this comment.21# line below this comment.
22import lp.codehosting22import lp.codehosting # noqa: F401
23
24# Silence lint warning.
25lp.codehosting
2623
27from breezy.branch import UnstackableBranchFormat24from breezy.branch import UnstackableBranchFormat
28from breezy.bzr.branch import (25from breezy.bzr.branch import (
diff --git a/lib/lp/codehosting/__init__.py b/lib/lp/codehosting/__init__.py
index c194128..09b1b64 100644
--- a/lib/lp/codehosting/__init__.py
+++ b/lib/lp/codehosting/__init__.py
@@ -82,6 +82,6 @@ def dont_wrap_class_and_subclasses(cls):
8282
83# Don't wrap Branch or its subclasses in Zope security proxies. Make sure83# Don't wrap Branch or its subclasses in Zope security proxies. Make sure
84# the various LoomBranch classes are present first.84# the various LoomBranch classes are present first.
85import breezy.plugins.loom.branch85import breezy.plugins.loom.branch # noqa: E402
86breezy.plugins.loom.branch86breezy.plugins.loom.branch
87dont_wrap_class_and_subclasses(Branch)87dont_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
10import pytz10import pytz
11from twisted.internet import defer11from twisted.internet import defer
1212
13from lp.codehosting.puller.scheduler import LockError
1314
14def get_lock_id_for_branch_id(branch_id):15def get_lock_id_for_branch_id(branch_id):
15 """Return the lock id that should be used for a branch with the passed id.16 """Return the lock id that should be used for a branch with the passed id.
16 """17 """
17 return 'worker-for-branch-%s@supermirror' % (branch_id,)18 return 'worker-for-branch-%s@supermirror' % (branch_id,)
1819
19from lp.codehosting.puller.scheduler import LockError
20
21UTC = pytz.timezone('UTC')20UTC = pytz.timezone('UTC')
2221
2322
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):
11841184
11851185
1186# Fix circular imports.1186# Fix circular imports.
1187from lp.registry.interfaces.distributionsourcepackage import (1187from lp.registry.interfaces.distributionsourcepackage import ( # noqa: E402
1188 IDistributionSourcePackage)1188 IDistributionSourcePackage)
1189patch_reference_property(1189patch_reference_property(
1190 IDistributionSourcePackage, 'upstream_product', IProduct)1190 IDistributionSourcePackage, 'upstream_product', IProduct)
diff --git a/lib/lp/scripts/utilities/importpedant.py b/lib/lp/scripts/utilities/importpedant.py
index dc837e5..160af05 100644
--- a/lib/lp/scripts/utilities/importpedant.py
+++ b/lib/lp/scripts/utilities/importpedant.py
@@ -5,20 +5,19 @@ import atexit
5import itertools5import itertools
6from operator import attrgetter6from operator import attrgetter
7import types7import types
8import warnings
89
9import six10import six
10from six.moves import builtins11from six.moves import builtins
1112
12
13original_import = builtins.__import__
14naughty_imports = set()
15
16# Silence bogus warnings from Hardy's python-pkg-resources package.13# Silence bogus warnings from Hardy's python-pkg-resources package.
17import warnings
18warnings.filterwarnings('ignore', category=UserWarning, append=True,14warnings.filterwarnings('ignore', category=UserWarning, append=True,
19 message=r'Module .*? is being added to sys.path')15 message=r'Module .*? is being added to sys.path')
2016
2117
18original_import = builtins.__import__
19naughty_imports = set()
20
22# Sometimes, third-party modules don't export all of their public APIs through21# Sometimes, third-party modules don't export all of their public APIs through
23# __all__. The following dict maps from such modules to a list of attributes22# __all__. The following dict maps from such modules to a list of attributes
24# that are allowed to be imported, whether or not they are in __all__.23# 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 @@
6__metaclass__ = type6__metaclass__ = type
77
8import inspect8import inspect
9import six
9import sys10import sys
10import warnings11import warnings
1112
12import six13# ViewPageTemplateFile has .filename.
14from zope.browserpage import ViewPageTemplateFile
15
16# PythonExpr has .text, the text of the expression.
17from zope.tales.pythonexpr import PythonExpr
18
19# TrustedZopeContext has self.contexts, a dict with template, view, context,
20# request, etc.
21from zope.pagetemplate.engine import TrustedZopeContext
22
23# TALInterpreter has self.sourceFile, a filename of a page template.
24from zope.tal.talinterpreter import TALInterpreter
25
26from zope.browserpage.simpleviewclass import simple
1327
1428
15class WarningReport:29class WarningReport:
@@ -58,21 +72,6 @@ class ImportantInfo:
58 L.append('request url: %s' % self.requesturl)72 L.append('request url: %s' % self.requesturl)
59 return '\n'.join(L)73 return '\n'.join(L)
6074
61# ViewPageTemplateFile has .filename.
62from zope.browserpage import ViewPageTemplateFile
63
64# PythonExpr has .text, the text of the expression.
65from zope.tales.pythonexpr import PythonExpr
66
67# TrustedZopeContext has self.contexts, a dict with template, view, context,
68# request, etc.
69from zope.pagetemplate.engine import TrustedZopeContext
70
71# TALInterpreter has self.sourceFile, a filename of a page template.
72from zope.tal.talinterpreter import TALInterpreter
73
74from zope.browserpage.simpleviewclass import simple
75
7675
77def find_important_info():76def find_important_info():
78 stack = inspect.stack()77 stack = inspect.stack()
diff --git a/lib/lp/services/job/celeryjob.py b/lib/lp/services/job/celeryjob.py
index b4ae220..7d9e8b6 100644
--- a/lib/lp/services/job/celeryjob.py
+++ b/lib/lp/services/job/celeryjob.py
@@ -21,8 +21,6 @@ from logging import info
21import os21import os
22from uuid import uuid422from uuid import uuid4
2323
24
25os.environ.setdefault('CELERY_CONFIG_MODULE', 'lp.services.job.celeryconfig')
26from celery import (24from celery import (
27 Celery,25 Celery,
28 Task,26 Task,
@@ -46,6 +44,7 @@ from lp.services.job.runner import (
46 )44 )
47from lp.services import scripts45from lp.services import scripts
4846
47os.environ.setdefault('CELERY_CONFIG_MODULE', 'lp.services.job.celeryconfig')
4948
50celery_app = Celery()49celery_app = Celery()
5150
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__ = [
8 'pop_notifications'8 'pop_notifications'
9 ]9 ]
1010
11from celery.task import task
12
11# Force the correct celeryconfig to be used.13# Force the correct celeryconfig to be used.
12import lp.services.job.celeryjob14import lp.services.job.celeryjob
1315
14# Quiet lint unused import warning.16# Quiet lint unused import warning.
15lp.services.job.celeryjob17lp.services.job.celeryjob
1618
17from celery.task import task
18
1919
20@task20@task
21def pop_notifications():21def pop_notifications():
diff --git a/lib/lp/services/scripts/tests/loglevels.py b/lib/lp/services/scripts/tests/loglevels.py
index 3849fc4..0e91e44 100644
--- a/lib/lp/services/scripts/tests/loglevels.py
+++ b/lib/lp/services/scripts/tests/loglevels.py
@@ -9,22 +9,21 @@ Used by test_logger.txt.
9__metaclass__ = type9__metaclass__ = type
10__all__ = []10__all__ = []
1111
12# Monkey patch time.gmtime to make our tests easier to read.12from optparse import OptionParser
13import time13import time
1414
15from lp.services.scripts.logger import (
16 logger,
17 logger_options,
18 )
19
1520
21# Monkey patch time.gmtime to make our tests easier to read.
16def fake_gmtime(ignored_seconds):22def fake_gmtime(ignored_seconds):
17 # 1985-12-21 13:45:5523 # 1985-12-21 13:45:55
18 return (1985, 12, 21, 13, 45, 55, 5, 355, 0)24 return (1985, 12, 21, 13, 45, 55, 5, 355, 0)
19time.gmtime = fake_gmtime25time.gmtime = fake_gmtime
2026
21from optparse import OptionParser
22
23from lp.services.scripts.logger import (
24 logger,
25 logger_options,
26 )
27
28parser = OptionParser()27parser = OptionParser()
29logger_options(parser)28logger_options(parser)
3029
diff --git a/lib/lp/testing/html5browser.py b/lib/lp/testing/html5browser.py
index b314667..7dd3a37 100644
--- a/lib/lp/testing/html5browser.py
+++ b/lib/lp/testing/html5browser.py
@@ -34,7 +34,7 @@ import gi
34gi.require_version('Gtk', '3.0')34gi.require_version('Gtk', '3.0')
35gi.require_version('WebKit', '3.0')35gi.require_version('WebKit', '3.0')
3636
37from gi.repository import (37from gi.repository import ( # noqa: E402
38 GLib,38 GLib,
39 Gtk,39 Gtk,
40 WebKit,40 WebKit,
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
1212
13import twisted.web.server13import twisted.web.server
14from twisted.application import internet, service14from twisted.application import internet, service
15from lp.testing.swift.fakeswift import Root
1516
16logging.basicConfig()17logging.basicConfig()
1718
18from lp.testing.swift.fakeswift import Root
19
20storedir = os.environ['SWIFT_ROOT']19storedir = os.environ['SWIFT_ROOT']
21assert os.path.exists(storedir)20assert os.path.exists(storedir)
2221
diff --git a/scripts/wsgi-archive-auth.py b/scripts/wsgi-archive-auth.py
index b5490ee..30c3096 100755
--- a/scripts/wsgi-archive-auth.py
+++ b/scripts/wsgi-archive-auth.py
@@ -32,9 +32,9 @@ top = os.path.dirname(scripts_dir)
32sys.modules.pop("site", None)32sys.modules.pop("site", None)
33sys.modules.pop("sitecustomize", None)33sys.modules.pop("sitecustomize", None)
3434
35import _pythonpath # noqa: F40135import _pythonpath # noqa: F401,E402
3636
37from lp.soyuz.wsgi.archiveauth import check_password37from lp.soyuz.wsgi.archiveauth import check_password # noqa: E402
3838
3939
40def main():40def main():
diff --git a/utilities/format-imports b/utilities/format-imports
index 5e93624..39ecf52 100755
--- a/utilities/format-imports
+++ b/utilities/format-imports
@@ -134,7 +134,7 @@ import sys
134from textwrap import dedent134from textwrap import dedent
135135
136sys.path[0:0] = [os.path.dirname(__file__)]136sys.path[0:0] = [os.path.dirname(__file__)]
137from python_standard_libs import python_standard_libs137from python_standard_libs import python_standard_libs # noqa: E402
138138
139# python_standard_libs is only used for membership tests.139# python_standard_libs is only used for membership tests.
140python_standard_libs = frozenset(python_standard_libs)140python_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
12sys.path.insert(0,12sys.path.insert(0,
13 os.path.join(os.path.dirname(os.path.dirname(__file__)), 'lib'))13 os.path.join(os.path.dirname(os.path.dirname(__file__)), 'lib'))
1414
15from devscripts import sourcecode15from devscripts import sourcecode # noqa: E402
1616
1717
18if __name__ == '__main__':18if __name__ == '__main__':

Subscribers

People subscribed via source and target branches

to status/vote changes: