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
1diff --git a/lib/lp/app/__init__.py b/lib/lp/app/__init__.py
2index e79d7bd..7006d36 100644
3--- a/lib/lp/app/__init__.py
4+++ b/lib/lp/app/__init__.py
5@@ -15,10 +15,8 @@ __all__ = []
6 # values, but they kindly left this global variable for you to monkey patch if
7 # you want the old behaviour, just like we do.
8 from zope.formlib import itemswidgets
9-
10-
11-itemswidgets.EXPLICIT_EMPTY_SELECTION = False
12-
13 # Load versioninfo.py so that we get errors on start-up rather than waiting
14 # for first page load.
15 import lp.app.versioninfo # noqa: F401
16+
17+itemswidgets.EXPLICIT_EMPTY_SELECTION = False
18diff --git a/lib/lp/bugs/interfaces/bug.py b/lib/lp/bugs/interfaces/bug.py
19index 4c14118..5fde710 100644
20--- a/lib/lp/bugs/interfaces/bug.py
21+++ b/lib/lp/bugs/interfaces/bug.py
22@@ -1029,7 +1029,7 @@ patch_collection_property(ICve, 'bugs', IBug)
23 # In order to avoid circular dependencies, we only import
24 # IBugSubscription (which itself imports IBug) here, and assign it as
25 # the value type for the `subscriptions` collection.
26-from lp.bugs.interfaces.bugsubscription import IBugSubscription
27+from lp.bugs.interfaces.bugsubscription import IBugSubscription # noqa: E402
28 patch_collection_property(IBug, 'subscriptions', IBugSubscription)
29
30
31diff --git a/lib/lp/bugs/interfaces/bugsubscription.py b/lib/lp/bugs/interfaces/bugsubscription.py
32index f0241d4..3913944 100644
33--- a/lib/lp/bugs/interfaces/bugsubscription.py
34+++ b/lib/lp/bugs/interfaces/bugsubscription.py
35@@ -86,5 +86,5 @@ class IBugSubscription(Interface):
36 # In order to avoid circular dependencies, we only import
37 # IBug (which itself imports IBugSubscription) here, and assign it as
38 # the value type for the `bug` reference.
39-from lp.bugs.interfaces.bug import IBug
40+from lp.bugs.interfaces.bug import IBug # noqa: E402
41 patch_reference_property(IBugSubscription, 'bug', IBug)
42diff --git a/lib/lp/bugs/model/bug.py b/lib/lp/bugs/model/bug.py
43index c1cc4c8..4f4ea06 100644
44--- a/lib/lp/bugs/model/bug.py
45+++ b/lib/lp/bugs/model/bug.py
46@@ -75,6 +75,7 @@ from zope.component import getUtility
47 from zope.contenttype import guess_content_type
48 from zope.event import notify
49 from zope.interface import implementer
50+from zope.security import checker
51 from zope.security.interfaces import Unauthorized
52 from zope.security.proxy import (
53 ProxyFactory,
54@@ -2385,7 +2386,6 @@ class StructuralSubscriptionSet(FrozenSetBasedSet):
55 # writing ZCML tedious, so I've opted for registering custom checkers (see
56 # lp_sitecustomize for some other jiggery pokery in the same vein) while I
57 # seek a better solution.
58-from zope.security import checker
59 checker_for_frozen_set = checker.getCheckerForInstancesOf(frozenset)
60 checker_for_subscriber_set = checker.NamesChecker(["sorted"])
61 checker_for_subscription_set = checker.NamesChecker(["sorted", "subscribers"])
62diff --git a/lib/lp/code/bzr.py b/lib/lp/code/bzr.py
63index 88d7abb..e823fc2 100644
64--- a/lib/lp/code/bzr.py
65+++ b/lib/lp/code/bzr.py
66@@ -19,10 +19,7 @@ __all__ = [
67
68 # FIRST Ensure correct plugins are loaded. Do not delete this comment or the
69 # line below this comment.
70-import lp.codehosting
71-
72-# Silence lint warning.
73-lp.codehosting
74+import lp.codehosting # noqa: F401
75
76 from breezy.branch import UnstackableBranchFormat
77 from breezy.bzr.branch import (
78diff --git a/lib/lp/codehosting/__init__.py b/lib/lp/codehosting/__init__.py
79index c194128..09b1b64 100644
80--- a/lib/lp/codehosting/__init__.py
81+++ b/lib/lp/codehosting/__init__.py
82@@ -82,6 +82,6 @@ def dont_wrap_class_and_subclasses(cls):
83
84 # Don't wrap Branch or its subclasses in Zope security proxies. Make sure
85 # the various LoomBranch classes are present first.
86-import breezy.plugins.loom.branch
87+import breezy.plugins.loom.branch # noqa: E402
88 breezy.plugins.loom.branch
89 dont_wrap_class_and_subclasses(Branch)
90diff --git a/lib/lp/codehosting/puller/__init__.py b/lib/lp/codehosting/puller/__init__.py
91index 48ec941..e1582ed 100644
92--- a/lib/lp/codehosting/puller/__init__.py
93+++ b/lib/lp/codehosting/puller/__init__.py
94@@ -10,14 +10,13 @@ import datetime
95 import pytz
96 from twisted.internet import defer
97
98+from lp.codehosting.puller.scheduler import LockError
99
100 def get_lock_id_for_branch_id(branch_id):
101 """Return the lock id that should be used for a branch with the passed id.
102 """
103 return 'worker-for-branch-%s@supermirror' % (branch_id,)
104
105-from lp.codehosting.puller.scheduler import LockError
106-
107 UTC = pytz.timezone('UTC')
108
109
110diff --git a/lib/lp/registry/interfaces/product.py b/lib/lp/registry/interfaces/product.py
111index e5ac436..b770b13 100644
112--- a/lib/lp/registry/interfaces/product.py
113+++ b/lib/lp/registry/interfaces/product.py
114@@ -1184,7 +1184,7 @@ class InvalidProductName(LaunchpadValidationError):
115
116
117 # Fix circular imports.
118-from lp.registry.interfaces.distributionsourcepackage import (
119+from lp.registry.interfaces.distributionsourcepackage import ( # noqa: E402
120 IDistributionSourcePackage)
121 patch_reference_property(
122 IDistributionSourcePackage, 'upstream_product', IProduct)
123diff --git a/lib/lp/scripts/utilities/importpedant.py b/lib/lp/scripts/utilities/importpedant.py
124index dc837e5..160af05 100644
125--- a/lib/lp/scripts/utilities/importpedant.py
126+++ b/lib/lp/scripts/utilities/importpedant.py
127@@ -5,20 +5,19 @@ import atexit
128 import itertools
129 from operator import attrgetter
130 import types
131+import warnings
132
133 import six
134 from six.moves import builtins
135
136-
137-original_import = builtins.__import__
138-naughty_imports = set()
139-
140 # Silence bogus warnings from Hardy's python-pkg-resources package.
141-import warnings
142 warnings.filterwarnings('ignore', category=UserWarning, append=True,
143 message=r'Module .*? is being added to sys.path')
144
145
146+original_import = builtins.__import__
147+naughty_imports = set()
148+
149 # Sometimes, third-party modules don't export all of their public APIs through
150 # __all__. The following dict maps from such modules to a list of attributes
151 # that are allowed to be imported, whether or not they are in __all__.
152diff --git a/lib/lp/scripts/utilities/warninghandler.py b/lib/lp/scripts/utilities/warninghandler.py
153index 3620a1c..88827e6 100644
154--- a/lib/lp/scripts/utilities/warninghandler.py
155+++ b/lib/lp/scripts/utilities/warninghandler.py
156@@ -6,10 +6,24 @@
157 __metaclass__ = type
158
159 import inspect
160+import six
161 import sys
162 import warnings
163
164-import six
165+# ViewPageTemplateFile has .filename.
166+from zope.browserpage import ViewPageTemplateFile
167+
168+# PythonExpr has .text, the text of the expression.
169+from zope.tales.pythonexpr import PythonExpr
170+
171+# TrustedZopeContext has self.contexts, a dict with template, view, context,
172+# request, etc.
173+from zope.pagetemplate.engine import TrustedZopeContext
174+
175+# TALInterpreter has self.sourceFile, a filename of a page template.
176+from zope.tal.talinterpreter import TALInterpreter
177+
178+from zope.browserpage.simpleviewclass import simple
179
180
181 class WarningReport:
182@@ -58,21 +72,6 @@ class ImportantInfo:
183 L.append('request url: %s' % self.requesturl)
184 return '\n'.join(L)
185
186-# ViewPageTemplateFile has .filename.
187-from zope.browserpage import ViewPageTemplateFile
188-
189-# PythonExpr has .text, the text of the expression.
190-from zope.tales.pythonexpr import PythonExpr
191-
192-# TrustedZopeContext has self.contexts, a dict with template, view, context,
193-# request, etc.
194-from zope.pagetemplate.engine import TrustedZopeContext
195-
196-# TALInterpreter has self.sourceFile, a filename of a page template.
197-from zope.tal.talinterpreter import TALInterpreter
198-
199-from zope.browserpage.simpleviewclass import simple
200-
201
202 def find_important_info():
203 stack = inspect.stack()
204diff --git a/lib/lp/services/job/celeryjob.py b/lib/lp/services/job/celeryjob.py
205index b4ae220..7d9e8b6 100644
206--- a/lib/lp/services/job/celeryjob.py
207+++ b/lib/lp/services/job/celeryjob.py
208@@ -21,8 +21,6 @@ from logging import info
209 import os
210 from uuid import uuid4
211
212-
213-os.environ.setdefault('CELERY_CONFIG_MODULE', 'lp.services.job.celeryconfig')
214 from celery import (
215 Celery,
216 Task,
217@@ -46,6 +44,7 @@ from lp.services.job.runner import (
218 )
219 from lp.services import scripts
220
221+os.environ.setdefault('CELERY_CONFIG_MODULE', 'lp.services.job.celeryconfig')
222
223 celery_app = Celery()
224
225diff --git a/lib/lp/services/job/tests/celery_helpers.py b/lib/lp/services/job/tests/celery_helpers.py
226index b0d5ba4..c378b6f 100644
227--- a/lib/lp/services/job/tests/celery_helpers.py
228+++ b/lib/lp/services/job/tests/celery_helpers.py
229@@ -8,14 +8,14 @@ __all__ = [
230 'pop_notifications'
231 ]
232
233+from celery.task import task
234+
235 # Force the correct celeryconfig to be used.
236 import lp.services.job.celeryjob
237
238 # Quiet lint unused import warning.
239 lp.services.job.celeryjob
240
241-from celery.task import task
242-
243
244 @task
245 def pop_notifications():
246diff --git a/lib/lp/services/scripts/tests/loglevels.py b/lib/lp/services/scripts/tests/loglevels.py
247index 3849fc4..0e91e44 100644
248--- a/lib/lp/services/scripts/tests/loglevels.py
249+++ b/lib/lp/services/scripts/tests/loglevels.py
250@@ -9,22 +9,21 @@ Used by test_logger.txt.
251 __metaclass__ = type
252 __all__ = []
253
254-# Monkey patch time.gmtime to make our tests easier to read.
255+from optparse import OptionParser
256 import time
257
258+from lp.services.scripts.logger import (
259+ logger,
260+ logger_options,
261+ )
262+
263
264+# Monkey patch time.gmtime to make our tests easier to read.
265 def fake_gmtime(ignored_seconds):
266 # 1985-12-21 13:45:55
267 return (1985, 12, 21, 13, 45, 55, 5, 355, 0)
268 time.gmtime = fake_gmtime
269
270-from optparse import OptionParser
271-
272-from lp.services.scripts.logger import (
273- logger,
274- logger_options,
275- )
276-
277 parser = OptionParser()
278 logger_options(parser)
279
280diff --git a/lib/lp/testing/html5browser.py b/lib/lp/testing/html5browser.py
281index b314667..7dd3a37 100644
282--- a/lib/lp/testing/html5browser.py
283+++ b/lib/lp/testing/html5browser.py
284@@ -34,7 +34,7 @@ import gi
285 gi.require_version('Gtk', '3.0')
286 gi.require_version('WebKit', '3.0')
287
288-from gi.repository import (
289+from gi.repository import ( # noqa: E402
290 GLib,
291 Gtk,
292 WebKit,
293diff --git a/lib/lp/testing/swift/fakeswift.tac b/lib/lp/testing/swift/fakeswift.tac
294index 742658d..c5c95b8 100644
295--- a/lib/lp/testing/swift/fakeswift.tac
296+++ b/lib/lp/testing/swift/fakeswift.tac
297@@ -12,11 +12,10 @@ import logging
298
299 import twisted.web.server
300 from twisted.application import internet, service
301+from lp.testing.swift.fakeswift import Root
302
303 logging.basicConfig()
304
305-from lp.testing.swift.fakeswift import Root
306-
307 storedir = os.environ['SWIFT_ROOT']
308 assert os.path.exists(storedir)
309
310diff --git a/scripts/wsgi-archive-auth.py b/scripts/wsgi-archive-auth.py
311index b5490ee..30c3096 100755
312--- a/scripts/wsgi-archive-auth.py
313+++ b/scripts/wsgi-archive-auth.py
314@@ -32,9 +32,9 @@ top = os.path.dirname(scripts_dir)
315 sys.modules.pop("site", None)
316 sys.modules.pop("sitecustomize", None)
317
318-import _pythonpath # noqa: F401
319+import _pythonpath # noqa: F401,E402
320
321-from lp.soyuz.wsgi.archiveauth import check_password
322+from lp.soyuz.wsgi.archiveauth import check_password # noqa: E402
323
324
325 def main():
326diff --git a/utilities/format-imports b/utilities/format-imports
327index 5e93624..39ecf52 100755
328--- a/utilities/format-imports
329+++ b/utilities/format-imports
330@@ -134,7 +134,7 @@ import sys
331 from textwrap import dedent
332
333 sys.path[0:0] = [os.path.dirname(__file__)]
334-from python_standard_libs import python_standard_libs
335+from python_standard_libs import python_standard_libs # noqa: E402
336
337 # python_standard_libs is only used for membership tests.
338 python_standard_libs = frozenset(python_standard_libs)
339diff --git a/utilities/update-sourcecode b/utilities/update-sourcecode
340index a10eb01..107460a 100755
341--- a/utilities/update-sourcecode
342+++ b/utilities/update-sourcecode
343@@ -12,7 +12,7 @@ import sys
344 sys.path.insert(0,
345 os.path.join(os.path.dirname(os.path.dirname(__file__)), 'lib'))
346
347-from devscripts import sourcecode
348+from devscripts import sourcecode # noqa: E402
349
350
351 if __name__ == '__main__':

Subscribers

People subscribed via source and target branches

to status/vote changes: