Merge ~cjwatson/launchpad:deconfuse-isort into launchpad:master
- Git
- lp:~cjwatson/launchpad
- deconfuse-isort
- Merge into master
Proposed by
Colin Watson
Status: | Merged |
---|---|
Approved by: | Colin Watson |
Approved revision: | 0e00bf0f88a3faa22d5e2cb4f7e0f15ba9ce42a5 |
Merge reported by: | Otto Co-Pilot |
Merged at revision: | not available |
Proposed branch: | ~cjwatson/launchpad:deconfuse-isort |
Merge into: | launchpad:master |
Diff against target: |
529 lines (+59/-94) 15 files modified
lib/contrib/glock.py (+0/-1) lib/lp/app/browser/tests/test_vocabulary.py (+1/-3) lib/lp/code/browser/tests/test_codeimport.py (+15/-15) lib/lp/code/bzr.py (+1/-1) lib/lp/code/interfaces/branch.py (+1/-1) lib/lp/code/interfaces/webservice.py (+3/-6) lib/lp/codehosting/puller/worker.py (+1/-1) lib/lp/registry/tests/test_prf_filter.py (+8/-18) lib/lp/registry/tests/test_prf_hose.py (+8/-25) lib/lp/registry/tests/test_prf_log.py (+8/-14) lib/lp/services/librarian/client.py (+2/-1) lib/lp/services/mail/notificationrecipientset.py (+6/-3) lib/lp/testing/layers.py (+2/-3) lib/lp/translations/scripts/translations_to_branch.py (+1/-1) lib/sqlobject/__init__.py (+2/-1) |
Related bugs: |
Reviewer | Review Type | Date Requested | Status |
---|---|---|---|
Cristian Gonzalez (community) | Approve | ||
Review via email: mp+406753@code.launchpad.net |
Commit message
Adjust various imports to confuse isort a little less
Description of the change
Move non-circular imports to their usual place near the top of the file. Avoid `cimport` as a local variable because `isort` gets that confused with the Cython keyword. Add `# isort: split` in a few cases where we need to stop `isort` moving things around.
To post a comment you must log in.
Preview Diff
[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
1 | diff --git a/lib/contrib/glock.py b/lib/contrib/glock.py |
2 | index de39d12..69def87 100644 |
3 | --- a/lib/contrib/glock.py |
4 | +++ b/lib/contrib/glock.py |
5 | @@ -29,7 +29,6 @@ __doc__ += '\n@author: %s (U{%s})\n@version: %s' % (__author__[0], |
6 | __author__[1], __version__) |
7 | __all__ = ['GlobalLock', 'GlobalLockError', 'LockAlreadyAcquired', 'NotOwner'] |
8 | |
9 | -# Imports: |
10 | import sys, string, os, errno, re |
11 | |
12 | # System-dependent imports for locking implementation: |
13 | diff --git a/lib/lp/app/browser/tests/test_vocabulary.py b/lib/lp/app/browser/tests/test_vocabulary.py |
14 | index 2904d8c..7265281 100644 |
15 | --- a/lib/lp/app/browser/tests/test_vocabulary.py |
16 | +++ b/lib/lp/app/browser/tests/test_vocabulary.py |
17 | @@ -328,9 +328,7 @@ class TestProductPickerEntrySourceAdapter(TestCaseWithFactory): |
18 | def test_provides_commercial_subscription_expired(self): |
19 | product = self.factory.makeProduct(name='fnord') |
20 | self.factory.makeCommercialSubscription(product) |
21 | - import datetime |
22 | - import pytz |
23 | - then = datetime.datetime(2005, 6, 15, 0, 0, 0, 0, pytz.UTC) |
24 | + then = datetime(2005, 6, 15, 0, 0, 0, 0, pytz.UTC) |
25 | with celebrity_logged_in('admin'): |
26 | product.commercial_subscription.date_expires = then |
27 | self.assertEqual( |
28 | diff --git a/lib/lp/code/browser/tests/test_codeimport.py b/lib/lp/code/browser/tests/test_codeimport.py |
29 | index f8b1470..0dd76c6 100644 |
30 | --- a/lib/lp/code/browser/tests/test_codeimport.py |
31 | +++ b/lib/lp/code/browser/tests/test_codeimport.py |
32 | @@ -94,48 +94,48 @@ class TestImportDetails(TestCaseWithFactory): |
33 | |
34 | def test_other_users_are_forbidden_to_change_codeimport(self): |
35 | # Unauthorized users are forbidden to edit an import. |
36 | - cimport = self.factory.makeCodeImport() |
37 | + code_import = self.factory.makeCodeImport() |
38 | another_person = self.factory.makePerson() |
39 | with person_logged_in(another_person): |
40 | self.assertRaises( |
41 | - Unauthorized, create_initialized_view, cimport.branch, |
42 | + Unauthorized, create_initialized_view, code_import.branch, |
43 | '+edit-import') |
44 | |
45 | def test_branch_owner_of_import_can_edit_it(self): |
46 | # Owners are allowed to edit code import. |
47 | - cimport = self.factory.makeCodeImport() |
48 | - with person_logged_in(cimport.branch.owner): |
49 | + code_import = self.factory.makeCodeImport() |
50 | + with person_logged_in(code_import.branch.owner): |
51 | view = create_initialized_view( |
52 | - cimport.branch, '+edit-import', form={ |
53 | + code_import.branch, '+edit-import', form={ |
54 | "field.actions.update": "update", |
55 | "field.url": "http://foo.test" |
56 | }) |
57 | self.assertEqual([], view.errors) |
58 | - self.assertEqual('http://foo.test', cimport.url) |
59 | + self.assertEqual('http://foo.test', code_import.url) |
60 | |
61 | def test_branch_owner_of_import_cannot_change_status(self): |
62 | # Owners are allowed to edit code import. |
63 | - cimport = self.factory.makeCodeImport() |
64 | - original_url = cimport.url |
65 | - with person_logged_in(cimport.branch.owner): |
66 | + code_import = self.factory.makeCodeImport() |
67 | + original_url = code_import.url |
68 | + with person_logged_in(code_import.branch.owner): |
69 | view = create_initialized_view( |
70 | - cimport.branch, '+edit-import', form={ |
71 | + code_import.branch, '+edit-import', form={ |
72 | "field.actions.suspend": "Suspend", |
73 | "field.url": "http://foo.test" |
74 | }) |
75 | self.assertEqual([], view.errors) |
76 | - self.assertEqual(original_url, cimport.url) |
77 | + self.assertEqual(original_url, code_import.url) |
78 | |
79 | def test_admin_can_change_code_import_status(self): |
80 | # Owners are allowed to edit code import. |
81 | - cimport = self.factory.makeCodeImport() |
82 | + code_import = self.factory.makeCodeImport() |
83 | with admin_logged_in(): |
84 | view = create_initialized_view( |
85 | - cimport.branch, '+edit-import', form={ |
86 | + code_import.branch, '+edit-import', form={ |
87 | "field.actions.suspend": "Suspend", |
88 | "field.url": "http://foo.test" |
89 | }) |
90 | self.assertEqual([], view.errors) |
91 | - self.assertEqual("http://foo.test", cimport.url) |
92 | + self.assertEqual("http://foo.test", code_import.url) |
93 | self.assertEqual( |
94 | - CodeImportReviewStatus.SUSPENDED, cimport.review_status) |
95 | + CodeImportReviewStatus.SUSPENDED, code_import.review_status) |
96 | diff --git a/lib/lp/code/bzr.py b/lib/lp/code/bzr.py |
97 | index e823fc2..8e2e264 100644 |
98 | --- a/lib/lp/code/bzr.py |
99 | +++ b/lib/lp/code/bzr.py |
100 | @@ -19,7 +19,7 @@ __all__ = [ |
101 | |
102 | # FIRST Ensure correct plugins are loaded. Do not delete this comment or the |
103 | # line below this comment. |
104 | -import lp.codehosting # noqa: F401 |
105 | +import lp.codehosting # noqa: F401 # isort: split |
106 | |
107 | from breezy.branch import UnstackableBranchFormat |
108 | from breezy.bzr.branch import ( |
109 | diff --git a/lib/lp/code/interfaces/branch.py b/lib/lp/code/interfaces/branch.py |
110 | index 45c8086..b8d52e5 100644 |
111 | --- a/lib/lp/code/interfaces/branch.py |
112 | +++ b/lib/lp/code/interfaces/branch.py |
113 | @@ -50,6 +50,7 @@ from lazr.restful.fields import ( |
114 | ReferenceChoice, |
115 | ) |
116 | from lazr.restful.interface import copy_field |
117 | +from lazr.uri import URI |
118 | from six.moves import http_client |
119 | from zope.component import getUtility |
120 | from zope.interface import ( |
121 | @@ -157,7 +158,6 @@ class BranchURIField(URIField): |
122 | def _validate(self, value): |
123 | # import here to avoid circular import |
124 | from lp.services.webapp import canonical_url |
125 | - from lazr.uri import URI |
126 | |
127 | # Can't use super-- this derives from an old-style class |
128 | URIField._validate(self, value) |
129 | diff --git a/lib/lp/code/interfaces/webservice.py b/lib/lp/code/interfaces/webservice.py |
130 | index 428c998..02546e9 100644 |
131 | --- a/lib/lp/code/interfaces/webservice.py |
132 | +++ b/lib/lp/code/interfaces/webservice.py |
133 | @@ -35,6 +35,9 @@ __all__ = [ |
134 | 'ISourcePackageRecipeBuild', |
135 | ] |
136 | |
137 | +# XXX: JonathanLange 2010-11-09 bug=673083: Legacy work-around for circular |
138 | +# import bugs. Break this up into a per-package thing. |
139 | +from lp import _schema_circular_imports # noqa: F401 |
140 | # The exceptions are imported so that they can produce the special |
141 | # status code defined by error_status when they are raised. |
142 | from lp.code.errors import ( |
143 | @@ -70,9 +73,3 @@ from lp.code.interfaces.sourcepackagerecipe import ISourcePackageRecipe |
144 | from lp.code.interfaces.sourcepackagerecipebuild import ( |
145 | ISourcePackageRecipeBuild, |
146 | ) |
147 | - |
148 | - |
149 | -# XXX: JonathanLange 2010-11-09 bug=673083: Legacy work-around for circular |
150 | -# import bugs. Break this up into a per-package thing. |
151 | -from lp import _schema_circular_imports |
152 | -_schema_circular_imports |
153 | diff --git a/lib/lp/codehosting/puller/worker.py b/lib/lp/codehosting/puller/worker.py |
154 | index 4ccfcbe..e3c23a6 100644 |
155 | --- a/lib/lp/codehosting/puller/worker.py |
156 | +++ b/lib/lp/codehosting/puller/worker.py |
157 | @@ -8,7 +8,7 @@ import sys |
158 | |
159 | # FIRST Ensure correct plugins are loaded. Do not delete this comment or the |
160 | # line below this comment. |
161 | -import lp.codehosting # noqa: F401 |
162 | +import lp.codehosting # noqa: F401 # isort: split |
163 | |
164 | from breezy import ( |
165 | errors, |
166 | diff --git a/lib/lp/registry/tests/test_prf_filter.py b/lib/lp/registry/tests/test_prf_filter.py |
167 | index 1dc0d24..093dc79 100644 |
168 | --- a/lib/lp/registry/tests/test_prf_filter.py |
169 | +++ b/lib/lp/registry/tests/test_prf_filter.py |
170 | @@ -3,24 +3,24 @@ |
171 | |
172 | """Tests for lp.registry.scripts.productreleasefinder.filter.""" |
173 | |
174 | +import logging |
175 | import unittest |
176 | |
177 | +from lp.registry.scripts.productreleasefinder.filter import ( |
178 | + Filter, |
179 | + FilterPattern, |
180 | + ) |
181 | + |
182 | |
183 | class Filter_Logging(unittest.TestCase): |
184 | def testCreatesDefaultLogger(self): |
185 | """Filter creates a default logger.""" |
186 | - from lp.registry.scripts.productreleasefinder.filter import ( |
187 | - Filter) |
188 | - from logging import Logger |
189 | f = Filter() |
190 | - self.assertTrue(isinstance(f.log, Logger)) |
191 | + self.assertTrue(isinstance(f.log, logging.Logger)) |
192 | |
193 | def testCreatesChildLogger(self): |
194 | """Filter creates a child logger if given a parent.""" |
195 | - from lp.registry.scripts.productreleasefinder.filter import ( |
196 | - Filter) |
197 | - from logging import getLogger |
198 | - parent = getLogger("foo") |
199 | + parent = logging.getLogger("foo") |
200 | f = Filter(log_parent=parent) |
201 | self.assertEqual(f.log.parent, parent) |
202 | |
203 | @@ -28,15 +28,11 @@ class Filter_Logging(unittest.TestCase): |
204 | class Filter_Init(unittest.TestCase): |
205 | def testDefaultFiltersProperty(self): |
206 | """Filter constructor initializes filters property to empty dict.""" |
207 | - from lp.registry.scripts.productreleasefinder.filter import ( |
208 | - Filter) |
209 | f = Filter() |
210 | self.assertEqual(f.filters, []) |
211 | |
212 | def testFiltersPropertyGiven(self): |
213 | """Filter constructor accepts argument to set filters property.""" |
214 | - from lp.registry.scripts.productreleasefinder.filter import ( |
215 | - Filter) |
216 | f = Filter(["wibble"]) |
217 | self.assertEqual(len(f.filters), 1) |
218 | self.assertEqual(f.filters[0], "wibble") |
219 | @@ -45,14 +41,10 @@ class Filter_Init(unittest.TestCase): |
220 | class Filter_CheckUrl(unittest.TestCase): |
221 | def testNoFilters(self): |
222 | """Filter.check returns None if there are no filters.""" |
223 | - from lp.registry.scripts.productreleasefinder.filter import ( |
224 | - Filter) |
225 | f = Filter() |
226 | self.assertEqual(f.check("file:///subdir/file"), None) |
227 | |
228 | def makeFilter(self, key, urlglob): |
229 | - from lp.registry.scripts.productreleasefinder.filter import ( |
230 | - Filter, FilterPattern) |
231 | pattern = FilterPattern(key, urlglob) |
232 | return Filter([pattern]) |
233 | |
234 | @@ -85,8 +77,6 @@ class Filter_CheckUrl(unittest.TestCase): |
235 | class Filter_IsPossibleParentUrl(unittest.TestCase): |
236 | |
237 | def makeFilter(self, key, urlglob): |
238 | - from lp.registry.scripts.productreleasefinder.filter import ( |
239 | - Filter, FilterPattern) |
240 | pattern = FilterPattern(key, urlglob) |
241 | return Filter([pattern]) |
242 | |
243 | diff --git a/lib/lp/registry/tests/test_prf_hose.py b/lib/lp/registry/tests/test_prf_hose.py |
244 | index c679cc8..f56eb57 100644 |
245 | --- a/lib/lp/registry/tests/test_prf_hose.py |
246 | +++ b/lib/lp/registry/tests/test_prf_hose.py |
247 | @@ -3,11 +3,17 @@ |
248 | |
249 | """Tests for lp.registry.scripts.productreleasefinder.hose.""" |
250 | |
251 | +import logging |
252 | import os |
253 | import shutil |
254 | import tempfile |
255 | import unittest |
256 | |
257 | +from lp.registry.scripts.productreleasefinder.filter import ( |
258 | + Filter, |
259 | + FilterPattern, |
260 | + ) |
261 | +from lp.registry.scripts.productreleasefinder.hose import Hose |
262 | from lp.testing import reset_logging |
263 | |
264 | |
265 | @@ -68,16 +74,12 @@ class InstrumentedMethodObserver: |
266 | class Hose_Logging(unittest.TestCase): |
267 | def testCreatesDefaultLogger(self): |
268 | """Hose creates a default logger.""" |
269 | - from lp.registry.scripts.productreleasefinder.hose import Hose |
270 | - from logging import Logger |
271 | h = Hose() |
272 | - self.assertTrue(isinstance(h.log, Logger)) |
273 | + self.assertTrue(isinstance(h.log, logging.Logger)) |
274 | |
275 | def testCreatesChildLogger(self): |
276 | """Hose creates a child logger if given a parent.""" |
277 | - from lp.registry.scripts.productreleasefinder.hose import Hose |
278 | - from logging import getLogger |
279 | - parent = getLogger("foo") |
280 | + parent = logging.getLogger("foo") |
281 | h = Hose(log_parent=parent) |
282 | self.assertEqual(h.log.parent, parent) |
283 | |
284 | @@ -85,23 +87,16 @@ class Hose_Logging(unittest.TestCase): |
285 | class Hose_Filter(unittest.TestCase): |
286 | def testCreatesFilterObject(self): |
287 | """Hose creates a Filter object.""" |
288 | - from lp.registry.scripts.productreleasefinder.hose import Hose |
289 | - from lp.registry.scripts.productreleasefinder.filter import ( |
290 | - Filter) |
291 | h = Hose() |
292 | self.assertTrue(isinstance(h.filter, Filter)) |
293 | |
294 | def testDefaultsFiltersToEmptyDict(self): |
295 | """Hose creates Filter object with empty dictionary.""" |
296 | - from lp.registry.scripts.productreleasefinder.hose import Hose |
297 | h = Hose() |
298 | self.assertEqual(h.filter.filters, []) |
299 | |
300 | def testCreatesFiltersWithGiven(self): |
301 | """Hose creates Filter object with dictionary given.""" |
302 | - from lp.registry.scripts.productreleasefinder.hose import Hose |
303 | - from lp.registry.scripts.productreleasefinder.filter import ( |
304 | - FilterPattern) |
305 | pattern = FilterPattern("foo", "http:e*") |
306 | h = Hose([pattern]) |
307 | self.assertEqual(len(h.filter.filters), 1) |
308 | @@ -111,7 +106,6 @@ class Hose_Filter(unittest.TestCase): |
309 | class Hose_Urls(unittest.TestCase): |
310 | def testCallsReduceWork(self): |
311 | """Hose constructor calls reduceWork function.""" |
312 | - from lp.registry.scripts.productreleasefinder.hose import Hose |
313 | h = Hose.__new__(Hose) |
314 | |
315 | class Observer(InstrumentedMethodObserver): |
316 | @@ -128,9 +122,6 @@ class Hose_Urls(unittest.TestCase): |
317 | |
318 | def testPassesUrlList(self): |
319 | """Hose constructor passes url list to reduceWork.""" |
320 | - from lp.registry.scripts.productreleasefinder.hose import Hose |
321 | - from lp.registry.scripts.productreleasefinder.filter import ( |
322 | - FilterPattern) |
323 | pattern = FilterPattern("foo", "http://archive.ubuntu.com/e*") |
324 | h = Hose.__new__(Hose) |
325 | |
326 | @@ -148,8 +139,6 @@ class Hose_Urls(unittest.TestCase): |
327 | |
328 | def testSetsUrlProperty(self): |
329 | """Hose constructor sets urls property to reduceWork return value.""" |
330 | - from lp.registry.scripts.productreleasefinder.hose import Hose |
331 | - |
332 | class TestHose(Hose): |
333 | def reduceWork(self, url_list): |
334 | return "wibble" |
335 | @@ -161,20 +150,17 @@ class Hose_Urls(unittest.TestCase): |
336 | class Hose_ReduceWork(unittest.TestCase): |
337 | def testEmptyList(self): |
338 | """Hose.reduceWork returns empty list when given one.""" |
339 | - from lp.registry.scripts.productreleasefinder.hose import Hose |
340 | h = Hose() |
341 | self.assertEqual(h.reduceWork([]), []) |
342 | |
343 | def testReducedList(self): |
344 | """Hose.reduceWork returns same list when nothing to do.""" |
345 | - from lp.registry.scripts.productreleasefinder.hose import Hose |
346 | h = Hose() |
347 | self.assertEqual(h.reduceWork(["http://localhost/", "file:///usr/"]), |
348 | ["http://localhost/", "file:///usr/"]) |
349 | |
350 | def testReducesList(self): |
351 | """Hose.reduceWork removes children elements from list.""" |
352 | - from lp.registry.scripts.productreleasefinder.hose import Hose |
353 | h = Hose() |
354 | self.assertEqual(h.reduceWork(["http://localhost/", |
355 | "http://localhost/foo/bar/", |
356 | @@ -219,9 +205,6 @@ class Hose_LimitWalk(unittest.TestCase): |
357 | fp.close() |
358 | |
359 | # Run the hose over the test data |
360 | - from lp.registry.scripts.productreleasefinder.hose import Hose |
361 | - from lp.registry.scripts.productreleasefinder.filter import ( |
362 | - FilterPattern) |
363 | pattern = FilterPattern("key", self.release_url + |
364 | "/foo/1.*/source/foo-1.*.tar.gz") |
365 | hose = Hose([pattern]) |
366 | diff --git a/lib/lp/registry/tests/test_prf_log.py b/lib/lp/registry/tests/test_prf_log.py |
367 | index d55f54f..2d663a0 100644 |
368 | --- a/lib/lp/registry/tests/test_prf_log.py |
369 | +++ b/lib/lp/registry/tests/test_prf_log.py |
370 | @@ -7,38 +7,32 @@ |
371 | |
372 | __author__ = "Scott James Remnant <scott@canonical.com>" |
373 | |
374 | +import logging |
375 | import unittest |
376 | |
377 | +from lp.registry.scripts.productreleasefinder.log import get_logger |
378 | + |
379 | |
380 | class GetLogger(unittest.TestCase): |
381 | def testLogger(self): |
382 | """get_logger returns a Logger instance.""" |
383 | - from lp.registry.scripts.productreleasefinder.log import get_logger |
384 | - from logging import Logger |
385 | - self.assertTrue(isinstance(get_logger("test"), Logger)) |
386 | + self.assertTrue(isinstance(get_logger("test"), logging.Logger)) |
387 | |
388 | def testNoParent(self): |
389 | """get_logger works if no parent is given.""" |
390 | - from lp.registry.scripts.productreleasefinder.log import get_logger |
391 | self.assertEqual(get_logger("test").name, "test") |
392 | |
393 | def testRootParent(self): |
394 | """get_logger works if root logger is given.""" |
395 | - from lp.registry.scripts.productreleasefinder.log import get_logger |
396 | - from logging import root |
397 | - self.assertEqual(get_logger("test", root).name, "test") |
398 | + self.assertEqual(get_logger("test", logging.root).name, "test") |
399 | |
400 | def testNormalParent(self): |
401 | """get_logger works if non-root logger is given.""" |
402 | - from lp.registry.scripts.productreleasefinder.log import get_logger |
403 | - from logging import getLogger |
404 | - parent = getLogger("foo") |
405 | + parent = logging.getLogger("foo") |
406 | self.assertEqual(get_logger("test", parent).name, "foo.test") |
407 | |
408 | def testDeepParent(self): |
409 | """get_logger works if deep-level logger is given.""" |
410 | - from lp.registry.scripts.productreleasefinder.log import get_logger |
411 | - from logging import getLogger |
412 | - getLogger("foo") |
413 | - parent2 = getLogger("foo.bar") |
414 | + logging.getLogger("foo") |
415 | + parent2 = logging.getLogger("foo.bar") |
416 | self.assertEqual(get_logger("test", parent2).name, "foo.bar.test") |
417 | diff --git a/lib/lp/services/librarian/client.py b/lib/lp/services/librarian/client.py |
418 | index 6787768..a26e39f 100644 |
419 | --- a/lib/lp/services/librarian/client.py |
420 | +++ b/lib/lp/services/librarian/client.py |
421 | @@ -37,6 +37,7 @@ from six.moves.urllib.parse import ( |
422 | urlunparse, |
423 | ) |
424 | from six.moves.urllib.request import urlopen |
425 | +from sqlobject import SQLObjectNotFound |
426 | from storm.store import Store |
427 | from zope.interface import implementer |
428 | |
429 | @@ -385,7 +386,7 @@ class FileDownloadClient: |
430 | inaccessible. |
431 | """ |
432 | from lp.services.librarian.model import LibraryFileAlias |
433 | - from sqlobject import SQLObjectNotFound |
434 | + |
435 | try: |
436 | lfa = LibraryFileAlias.get(aliasID) |
437 | except SQLObjectNotFound: |
438 | diff --git a/lib/lp/services/mail/notificationrecipientset.py b/lib/lp/services/mail/notificationrecipientset.py |
439 | index 7297da2..6004399 100644 |
440 | --- a/lib/lp/services/mail/notificationrecipientset.py |
441 | +++ b/lib/lp/services/mail/notificationrecipientset.py |
442 | @@ -14,7 +14,10 @@ from operator import attrgetter |
443 | |
444 | import six |
445 | from zope.interface import implementer |
446 | -from zope.security.proxy import isinstance as zope_isinstance |
447 | +from zope.security.proxy import ( |
448 | + isinstance as zope_isinstance, |
449 | + removeSecurityProxy, |
450 | + ) |
451 | |
452 | from lp.registry.interfaces.person import IPerson |
453 | from lp.services.mail.interfaces import ( |
454 | @@ -107,8 +110,8 @@ class NotificationRecipientSet: |
455 | |
456 | def add(self, persons, reason, header): |
457 | """See `INotificationRecipientSet`.""" |
458 | - from zope.security.proxy import removeSecurityProxy |
459 | from lp.registry.model.person import get_recipients |
460 | + |
461 | if (IPerson.providedBy(persons) or |
462 | zope_isinstance(persons, StubPerson)): |
463 | persons = [persons] |
464 | @@ -143,8 +146,8 @@ class NotificationRecipientSet: |
465 | |
466 | def remove(self, persons): |
467 | """See `INotificationRecipientSet`.""" |
468 | - from zope.security.proxy import removeSecurityProxy |
469 | from lp.registry.model.person import get_recipients |
470 | + |
471 | if IPerson.providedBy(persons): |
472 | persons = [persons] |
473 | for person in persons: |
474 | diff --git a/lib/lp/testing/layers.py b/lib/lp/testing/layers.py |
475 | index 2d07f26..f6e931b 100644 |
476 | --- a/lib/lp/testing/layers.py |
477 | +++ b/lib/lp/testing/layers.py |
478 | @@ -78,6 +78,7 @@ from six.moves.urllib.error import ( |
479 | ) |
480 | from six.moves.urllib.parse import urlparse |
481 | from six.moves.urllib.request import urlopen |
482 | +from storm.uri import URI |
483 | from talisker.context import Context |
484 | import transaction |
485 | from webob.request import environ_from_url as orig_environ_from_url |
486 | @@ -935,9 +936,7 @@ class LaunchpadLayer(LibrarianLayer, MemcachedLayer, RabbitMQLayer): |
487 | in the testSetUp(). |
488 | """ |
489 | if LaunchpadLayer._raw_sessiondb_connection is None: |
490 | - from storm.uri import URI |
491 | - from lp.services.webapp.adapter import ( |
492 | - LaunchpadSessionDatabase) |
493 | + from lp.services.webapp.adapter import LaunchpadSessionDatabase |
494 | launchpad_session_database = LaunchpadSessionDatabase( |
495 | URI('launchpad-session:')) |
496 | LaunchpadLayer._raw_sessiondb_connection = ( |
497 | diff --git a/lib/lp/translations/scripts/translations_to_branch.py b/lib/lp/translations/scripts/translations_to_branch.py |
498 | index 0e57a88..f07abd5 100644 |
499 | --- a/lib/lp/translations/scripts/translations_to_branch.py |
500 | +++ b/lib/lp/translations/scripts/translations_to_branch.py |
501 | @@ -15,7 +15,7 @@ import os.path |
502 | |
503 | # FIRST Ensure correct plugins are loaded. Do not delete this comment or the |
504 | # line below this comment. |
505 | -import lp.codehosting # noqa: F401 |
506 | +import lp.codehosting # noqa: F401 # isort: split |
507 | |
508 | from breezy.errors import NotBranchError |
509 | from breezy.revision import NULL_REVISION |
510 | diff --git a/lib/sqlobject/__init__.py b/lib/sqlobject/__init__.py |
511 | index 3e5f9e4..5450477 100644 |
512 | --- a/lib/sqlobject/__init__.py |
513 | +++ b/lib/sqlobject/__init__.py |
514 | @@ -7,13 +7,14 @@ __metaclass__ = type |
515 | |
516 | # SKIP this file when reformatting, due to the sys mangling. |
517 | import datetime |
518 | +import sys |
519 | |
520 | import six |
521 | from storm.expr import SQL |
522 | from storm.sqlobject import * # noqa: F401,F403 |
523 | |
524 | + |
525 | # Provide the same interface from these other locations. |
526 | -import sys |
527 | sys.modules['sqlobject.joins'] = sys.modules['sqlobject'] |
528 | sys.modules['sqlobject.sqlbuilder'] = sys.modules['sqlobject'] |
529 | del sys |
Looks good!