Merge ~cjwatson/launchpad:deconfuse-isort into launchpad: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)
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.
Revision history for this message
Cristian Gonzalez (cristiangsp) wrote :

Looks good!

review: Approve

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/contrib/glock.py b/lib/contrib/glock.py
index de39d12..69def87 100644
--- a/lib/contrib/glock.py
+++ b/lib/contrib/glock.py
@@ -29,7 +29,6 @@ __doc__ += '\n@author: %s (U{%s})\n@version: %s' % (__author__[0],
29 __author__[1], __version__)29 __author__[1], __version__)
30__all__ = ['GlobalLock', 'GlobalLockError', 'LockAlreadyAcquired', 'NotOwner']30__all__ = ['GlobalLock', 'GlobalLockError', 'LockAlreadyAcquired', 'NotOwner']
3131
32# Imports:
33import sys, string, os, errno, re32import sys, string, os, errno, re
3433
35# System-dependent imports for locking implementation:34# System-dependent imports for locking implementation:
diff --git a/lib/lp/app/browser/tests/test_vocabulary.py b/lib/lp/app/browser/tests/test_vocabulary.py
index 2904d8c..7265281 100644
--- a/lib/lp/app/browser/tests/test_vocabulary.py
+++ b/lib/lp/app/browser/tests/test_vocabulary.py
@@ -328,9 +328,7 @@ class TestProductPickerEntrySourceAdapter(TestCaseWithFactory):
328 def test_provides_commercial_subscription_expired(self):328 def test_provides_commercial_subscription_expired(self):
329 product = self.factory.makeProduct(name='fnord')329 product = self.factory.makeProduct(name='fnord')
330 self.factory.makeCommercialSubscription(product)330 self.factory.makeCommercialSubscription(product)
331 import datetime331 then = datetime(2005, 6, 15, 0, 0, 0, 0, pytz.UTC)
332 import pytz
333 then = datetime.datetime(2005, 6, 15, 0, 0, 0, 0, pytz.UTC)
334 with celebrity_logged_in('admin'):332 with celebrity_logged_in('admin'):
335 product.commercial_subscription.date_expires = then333 product.commercial_subscription.date_expires = then
336 self.assertEqual(334 self.assertEqual(
diff --git a/lib/lp/code/browser/tests/test_codeimport.py b/lib/lp/code/browser/tests/test_codeimport.py
index f8b1470..0dd76c6 100644
--- a/lib/lp/code/browser/tests/test_codeimport.py
+++ b/lib/lp/code/browser/tests/test_codeimport.py
@@ -94,48 +94,48 @@ class TestImportDetails(TestCaseWithFactory):
9494
95 def test_other_users_are_forbidden_to_change_codeimport(self):95 def test_other_users_are_forbidden_to_change_codeimport(self):
96 # Unauthorized users are forbidden to edit an import.96 # Unauthorized users are forbidden to edit an import.
97 cimport = self.factory.makeCodeImport()97 code_import = self.factory.makeCodeImport()
98 another_person = self.factory.makePerson()98 another_person = self.factory.makePerson()
99 with person_logged_in(another_person):99 with person_logged_in(another_person):
100 self.assertRaises(100 self.assertRaises(
101 Unauthorized, create_initialized_view, cimport.branch,101 Unauthorized, create_initialized_view, code_import.branch,
102 '+edit-import')102 '+edit-import')
103103
104 def test_branch_owner_of_import_can_edit_it(self):104 def test_branch_owner_of_import_can_edit_it(self):
105 # Owners are allowed to edit code import.105 # Owners are allowed to edit code import.
106 cimport = self.factory.makeCodeImport()106 code_import = self.factory.makeCodeImport()
107 with person_logged_in(cimport.branch.owner):107 with person_logged_in(code_import.branch.owner):
108 view = create_initialized_view(108 view = create_initialized_view(
109 cimport.branch, '+edit-import', form={109 code_import.branch, '+edit-import', form={
110 "field.actions.update": "update",110 "field.actions.update": "update",
111 "field.url": "http://foo.test"111 "field.url": "http://foo.test"
112 })112 })
113 self.assertEqual([], view.errors)113 self.assertEqual([], view.errors)
114 self.assertEqual('http://foo.test', cimport.url)114 self.assertEqual('http://foo.test', code_import.url)
115115
116 def test_branch_owner_of_import_cannot_change_status(self):116 def test_branch_owner_of_import_cannot_change_status(self):
117 # Owners are allowed to edit code import.117 # Owners are allowed to edit code import.
118 cimport = self.factory.makeCodeImport()118 code_import = self.factory.makeCodeImport()
119 original_url = cimport.url119 original_url = code_import.url
120 with person_logged_in(cimport.branch.owner):120 with person_logged_in(code_import.branch.owner):
121 view = create_initialized_view(121 view = create_initialized_view(
122 cimport.branch, '+edit-import', form={122 code_import.branch, '+edit-import', form={
123 "field.actions.suspend": "Suspend",123 "field.actions.suspend": "Suspend",
124 "field.url": "http://foo.test"124 "field.url": "http://foo.test"
125 })125 })
126 self.assertEqual([], view.errors)126 self.assertEqual([], view.errors)
127 self.assertEqual(original_url, cimport.url)127 self.assertEqual(original_url, code_import.url)
128128
129 def test_admin_can_change_code_import_status(self):129 def test_admin_can_change_code_import_status(self):
130 # Owners are allowed to edit code import.130 # Owners are allowed to edit code import.
131 cimport = self.factory.makeCodeImport()131 code_import = self.factory.makeCodeImport()
132 with admin_logged_in():132 with admin_logged_in():
133 view = create_initialized_view(133 view = create_initialized_view(
134 cimport.branch, '+edit-import', form={134 code_import.branch, '+edit-import', form={
135 "field.actions.suspend": "Suspend",135 "field.actions.suspend": "Suspend",
136 "field.url": "http://foo.test"136 "field.url": "http://foo.test"
137 })137 })
138 self.assertEqual([], view.errors)138 self.assertEqual([], view.errors)
139 self.assertEqual("http://foo.test", cimport.url)139 self.assertEqual("http://foo.test", code_import.url)
140 self.assertEqual(140 self.assertEqual(
141 CodeImportReviewStatus.SUSPENDED, cimport.review_status)141 CodeImportReviewStatus.SUSPENDED, code_import.review_status)
diff --git a/lib/lp/code/bzr.py b/lib/lp/code/bzr.py
index e823fc2..8e2e264 100644
--- a/lib/lp/code/bzr.py
+++ b/lib/lp/code/bzr.py
@@ -19,7 +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.codehosting # noqa: F40122import lp.codehosting # noqa: F401 # isort: split
2323
24from breezy.branch import UnstackableBranchFormat24from breezy.branch import UnstackableBranchFormat
25from breezy.bzr.branch import (25from breezy.bzr.branch import (
diff --git a/lib/lp/code/interfaces/branch.py b/lib/lp/code/interfaces/branch.py
index 45c8086..b8d52e5 100644
--- a/lib/lp/code/interfaces/branch.py
+++ b/lib/lp/code/interfaces/branch.py
@@ -50,6 +50,7 @@ from lazr.restful.fields import (
50 ReferenceChoice,50 ReferenceChoice,
51 )51 )
52from lazr.restful.interface import copy_field52from lazr.restful.interface import copy_field
53from lazr.uri import URI
53from six.moves import http_client54from six.moves import http_client
54from zope.component import getUtility55from zope.component import getUtility
55from zope.interface import (56from zope.interface import (
@@ -157,7 +158,6 @@ class BranchURIField(URIField):
157 def _validate(self, value):158 def _validate(self, value):
158 # import here to avoid circular import159 # import here to avoid circular import
159 from lp.services.webapp import canonical_url160 from lp.services.webapp import canonical_url
160 from lazr.uri import URI
161161
162 # Can't use super-- this derives from an old-style class162 # Can't use super-- this derives from an old-style class
163 URIField._validate(self, value)163 URIField._validate(self, value)
diff --git a/lib/lp/code/interfaces/webservice.py b/lib/lp/code/interfaces/webservice.py
index 428c998..02546e9 100644
--- a/lib/lp/code/interfaces/webservice.py
+++ b/lib/lp/code/interfaces/webservice.py
@@ -35,6 +35,9 @@ __all__ = [
35 'ISourcePackageRecipeBuild',35 'ISourcePackageRecipeBuild',
36 ]36 ]
3737
38# XXX: JonathanLange 2010-11-09 bug=673083: Legacy work-around for circular
39# import bugs. Break this up into a per-package thing.
40from lp import _schema_circular_imports # noqa: F401
38# The exceptions are imported so that they can produce the special41# The exceptions are imported so that they can produce the special
39# status code defined by error_status when they are raised.42# status code defined by error_status when they are raised.
40from lp.code.errors import (43from lp.code.errors import (
@@ -70,9 +73,3 @@ from lp.code.interfaces.sourcepackagerecipe import ISourcePackageRecipe
70from lp.code.interfaces.sourcepackagerecipebuild import (73from lp.code.interfaces.sourcepackagerecipebuild import (
71 ISourcePackageRecipeBuild,74 ISourcePackageRecipeBuild,
72 )75 )
73
74
75# XXX: JonathanLange 2010-11-09 bug=673083: Legacy work-around for circular
76# import bugs. Break this up into a per-package thing.
77from lp import _schema_circular_imports
78_schema_circular_imports
diff --git a/lib/lp/codehosting/puller/worker.py b/lib/lp/codehosting/puller/worker.py
index 4ccfcbe..e3c23a6 100644
--- a/lib/lp/codehosting/puller/worker.py
+++ b/lib/lp/codehosting/puller/worker.py
@@ -8,7 +8,7 @@ import sys
88
9# FIRST Ensure correct plugins are loaded. Do not delete this comment or the9# FIRST Ensure correct plugins are loaded. Do not delete this comment or the
10# line below this comment.10# line below this comment.
11import lp.codehosting # noqa: F40111import lp.codehosting # noqa: F401 # isort: split
1212
13from breezy import (13from breezy import (
14 errors,14 errors,
diff --git a/lib/lp/registry/tests/test_prf_filter.py b/lib/lp/registry/tests/test_prf_filter.py
index 1dc0d24..093dc79 100644
--- a/lib/lp/registry/tests/test_prf_filter.py
+++ b/lib/lp/registry/tests/test_prf_filter.py
@@ -3,24 +3,24 @@
33
4"""Tests for lp.registry.scripts.productreleasefinder.filter."""4"""Tests for lp.registry.scripts.productreleasefinder.filter."""
55
6import logging
6import unittest7import unittest
78
9from lp.registry.scripts.productreleasefinder.filter import (
10 Filter,
11 FilterPattern,
12 )
13
814
9class Filter_Logging(unittest.TestCase):15class Filter_Logging(unittest.TestCase):
10 def testCreatesDefaultLogger(self):16 def testCreatesDefaultLogger(self):
11 """Filter creates a default logger."""17 """Filter creates a default logger."""
12 from lp.registry.scripts.productreleasefinder.filter import (
13 Filter)
14 from logging import Logger
15 f = Filter()18 f = Filter()
16 self.assertTrue(isinstance(f.log, Logger))19 self.assertTrue(isinstance(f.log, logging.Logger))
1720
18 def testCreatesChildLogger(self):21 def testCreatesChildLogger(self):
19 """Filter creates a child logger if given a parent."""22 """Filter creates a child logger if given a parent."""
20 from lp.registry.scripts.productreleasefinder.filter import (23 parent = logging.getLogger("foo")
21 Filter)
22 from logging import getLogger
23 parent = getLogger("foo")
24 f = Filter(log_parent=parent)24 f = Filter(log_parent=parent)
25 self.assertEqual(f.log.parent, parent)25 self.assertEqual(f.log.parent, parent)
2626
@@ -28,15 +28,11 @@ class Filter_Logging(unittest.TestCase):
28class Filter_Init(unittest.TestCase):28class Filter_Init(unittest.TestCase):
29 def testDefaultFiltersProperty(self):29 def testDefaultFiltersProperty(self):
30 """Filter constructor initializes filters property to empty dict."""30 """Filter constructor initializes filters property to empty dict."""
31 from lp.registry.scripts.productreleasefinder.filter import (
32 Filter)
33 f = Filter()31 f = Filter()
34 self.assertEqual(f.filters, [])32 self.assertEqual(f.filters, [])
3533
36 def testFiltersPropertyGiven(self):34 def testFiltersPropertyGiven(self):
37 """Filter constructor accepts argument to set filters property."""35 """Filter constructor accepts argument to set filters property."""
38 from lp.registry.scripts.productreleasefinder.filter import (
39 Filter)
40 f = Filter(["wibble"])36 f = Filter(["wibble"])
41 self.assertEqual(len(f.filters), 1)37 self.assertEqual(len(f.filters), 1)
42 self.assertEqual(f.filters[0], "wibble")38 self.assertEqual(f.filters[0], "wibble")
@@ -45,14 +41,10 @@ class Filter_Init(unittest.TestCase):
45class Filter_CheckUrl(unittest.TestCase):41class Filter_CheckUrl(unittest.TestCase):
46 def testNoFilters(self):42 def testNoFilters(self):
47 """Filter.check returns None if there are no filters."""43 """Filter.check returns None if there are no filters."""
48 from lp.registry.scripts.productreleasefinder.filter import (
49 Filter)
50 f = Filter()44 f = Filter()
51 self.assertEqual(f.check("file:///subdir/file"), None)45 self.assertEqual(f.check("file:///subdir/file"), None)
5246
53 def makeFilter(self, key, urlglob):47 def makeFilter(self, key, urlglob):
54 from lp.registry.scripts.productreleasefinder.filter import (
55 Filter, FilterPattern)
56 pattern = FilterPattern(key, urlglob)48 pattern = FilterPattern(key, urlglob)
57 return Filter([pattern])49 return Filter([pattern])
5850
@@ -85,8 +77,6 @@ class Filter_CheckUrl(unittest.TestCase):
85class Filter_IsPossibleParentUrl(unittest.TestCase):77class Filter_IsPossibleParentUrl(unittest.TestCase):
8678
87 def makeFilter(self, key, urlglob):79 def makeFilter(self, key, urlglob):
88 from lp.registry.scripts.productreleasefinder.filter import (
89 Filter, FilterPattern)
90 pattern = FilterPattern(key, urlglob)80 pattern = FilterPattern(key, urlglob)
91 return Filter([pattern])81 return Filter([pattern])
9282
diff --git a/lib/lp/registry/tests/test_prf_hose.py b/lib/lp/registry/tests/test_prf_hose.py
index c679cc8..f56eb57 100644
--- a/lib/lp/registry/tests/test_prf_hose.py
+++ b/lib/lp/registry/tests/test_prf_hose.py
@@ -3,11 +3,17 @@
33
4"""Tests for lp.registry.scripts.productreleasefinder.hose."""4"""Tests for lp.registry.scripts.productreleasefinder.hose."""
55
6import logging
6import os7import os
7import shutil8import shutil
8import tempfile9import tempfile
9import unittest10import unittest
1011
12from lp.registry.scripts.productreleasefinder.filter import (
13 Filter,
14 FilterPattern,
15 )
16from lp.registry.scripts.productreleasefinder.hose import Hose
11from lp.testing import reset_logging17from lp.testing import reset_logging
1218
1319
@@ -68,16 +74,12 @@ class InstrumentedMethodObserver:
68class Hose_Logging(unittest.TestCase):74class Hose_Logging(unittest.TestCase):
69 def testCreatesDefaultLogger(self):75 def testCreatesDefaultLogger(self):
70 """Hose creates a default logger."""76 """Hose creates a default logger."""
71 from lp.registry.scripts.productreleasefinder.hose import Hose
72 from logging import Logger
73 h = Hose()77 h = Hose()
74 self.assertTrue(isinstance(h.log, Logger))78 self.assertTrue(isinstance(h.log, logging.Logger))
7579
76 def testCreatesChildLogger(self):80 def testCreatesChildLogger(self):
77 """Hose creates a child logger if given a parent."""81 """Hose creates a child logger if given a parent."""
78 from lp.registry.scripts.productreleasefinder.hose import Hose82 parent = logging.getLogger("foo")
79 from logging import getLogger
80 parent = getLogger("foo")
81 h = Hose(log_parent=parent)83 h = Hose(log_parent=parent)
82 self.assertEqual(h.log.parent, parent)84 self.assertEqual(h.log.parent, parent)
8385
@@ -85,23 +87,16 @@ class Hose_Logging(unittest.TestCase):
85class Hose_Filter(unittest.TestCase):87class Hose_Filter(unittest.TestCase):
86 def testCreatesFilterObject(self):88 def testCreatesFilterObject(self):
87 """Hose creates a Filter object."""89 """Hose creates a Filter object."""
88 from lp.registry.scripts.productreleasefinder.hose import Hose
89 from lp.registry.scripts.productreleasefinder.filter import (
90 Filter)
91 h = Hose()90 h = Hose()
92 self.assertTrue(isinstance(h.filter, Filter))91 self.assertTrue(isinstance(h.filter, Filter))
9392
94 def testDefaultsFiltersToEmptyDict(self):93 def testDefaultsFiltersToEmptyDict(self):
95 """Hose creates Filter object with empty dictionary."""94 """Hose creates Filter object with empty dictionary."""
96 from lp.registry.scripts.productreleasefinder.hose import Hose
97 h = Hose()95 h = Hose()
98 self.assertEqual(h.filter.filters, [])96 self.assertEqual(h.filter.filters, [])
9997
100 def testCreatesFiltersWithGiven(self):98 def testCreatesFiltersWithGiven(self):
101 """Hose creates Filter object with dictionary given."""99 """Hose creates Filter object with dictionary given."""
102 from lp.registry.scripts.productreleasefinder.hose import Hose
103 from lp.registry.scripts.productreleasefinder.filter import (
104 FilterPattern)
105 pattern = FilterPattern("foo", "http:e*")100 pattern = FilterPattern("foo", "http:e*")
106 h = Hose([pattern])101 h = Hose([pattern])
107 self.assertEqual(len(h.filter.filters), 1)102 self.assertEqual(len(h.filter.filters), 1)
@@ -111,7 +106,6 @@ class Hose_Filter(unittest.TestCase):
111class Hose_Urls(unittest.TestCase):106class Hose_Urls(unittest.TestCase):
112 def testCallsReduceWork(self):107 def testCallsReduceWork(self):
113 """Hose constructor calls reduceWork function."""108 """Hose constructor calls reduceWork function."""
114 from lp.registry.scripts.productreleasefinder.hose import Hose
115 h = Hose.__new__(Hose)109 h = Hose.__new__(Hose)
116110
117 class Observer(InstrumentedMethodObserver):111 class Observer(InstrumentedMethodObserver):
@@ -128,9 +122,6 @@ class Hose_Urls(unittest.TestCase):
128122
129 def testPassesUrlList(self):123 def testPassesUrlList(self):
130 """Hose constructor passes url list to reduceWork."""124 """Hose constructor passes url list to reduceWork."""
131 from lp.registry.scripts.productreleasefinder.hose import Hose
132 from lp.registry.scripts.productreleasefinder.filter import (
133 FilterPattern)
134 pattern = FilterPattern("foo", "http://archive.ubuntu.com/e*")125 pattern = FilterPattern("foo", "http://archive.ubuntu.com/e*")
135 h = Hose.__new__(Hose)126 h = Hose.__new__(Hose)
136127
@@ -148,8 +139,6 @@ class Hose_Urls(unittest.TestCase):
148139
149 def testSetsUrlProperty(self):140 def testSetsUrlProperty(self):
150 """Hose constructor sets urls property to reduceWork return value."""141 """Hose constructor sets urls property to reduceWork return value."""
151 from lp.registry.scripts.productreleasefinder.hose import Hose
152
153 class TestHose(Hose):142 class TestHose(Hose):
154 def reduceWork(self, url_list):143 def reduceWork(self, url_list):
155 return "wibble"144 return "wibble"
@@ -161,20 +150,17 @@ class Hose_Urls(unittest.TestCase):
161class Hose_ReduceWork(unittest.TestCase):150class Hose_ReduceWork(unittest.TestCase):
162 def testEmptyList(self):151 def testEmptyList(self):
163 """Hose.reduceWork returns empty list when given one."""152 """Hose.reduceWork returns empty list when given one."""
164 from lp.registry.scripts.productreleasefinder.hose import Hose
165 h = Hose()153 h = Hose()
166 self.assertEqual(h.reduceWork([]), [])154 self.assertEqual(h.reduceWork([]), [])
167155
168 def testReducedList(self):156 def testReducedList(self):
169 """Hose.reduceWork returns same list when nothing to do."""157 """Hose.reduceWork returns same list when nothing to do."""
170 from lp.registry.scripts.productreleasefinder.hose import Hose
171 h = Hose()158 h = Hose()
172 self.assertEqual(h.reduceWork(["http://localhost/", "file:///usr/"]),159 self.assertEqual(h.reduceWork(["http://localhost/", "file:///usr/"]),
173 ["http://localhost/", "file:///usr/"])160 ["http://localhost/", "file:///usr/"])
174161
175 def testReducesList(self):162 def testReducesList(self):
176 """Hose.reduceWork removes children elements from list."""163 """Hose.reduceWork removes children elements from list."""
177 from lp.registry.scripts.productreleasefinder.hose import Hose
178 h = Hose()164 h = Hose()
179 self.assertEqual(h.reduceWork(["http://localhost/",165 self.assertEqual(h.reduceWork(["http://localhost/",
180 "http://localhost/foo/bar/",166 "http://localhost/foo/bar/",
@@ -219,9 +205,6 @@ class Hose_LimitWalk(unittest.TestCase):
219 fp.close()205 fp.close()
220206
221 # Run the hose over the test data207 # Run the hose over the test data
222 from lp.registry.scripts.productreleasefinder.hose import Hose
223 from lp.registry.scripts.productreleasefinder.filter import (
224 FilterPattern)
225 pattern = FilterPattern("key", self.release_url +208 pattern = FilterPattern("key", self.release_url +
226 "/foo/1.*/source/foo-1.*.tar.gz")209 "/foo/1.*/source/foo-1.*.tar.gz")
227 hose = Hose([pattern])210 hose = Hose([pattern])
diff --git a/lib/lp/registry/tests/test_prf_log.py b/lib/lp/registry/tests/test_prf_log.py
index d55f54f..2d663a0 100644
--- a/lib/lp/registry/tests/test_prf_log.py
+++ b/lib/lp/registry/tests/test_prf_log.py
@@ -7,38 +7,32 @@
77
8__author__ = "Scott James Remnant <scott@canonical.com>"8__author__ = "Scott James Remnant <scott@canonical.com>"
99
10import logging
10import unittest11import unittest
1112
13from lp.registry.scripts.productreleasefinder.log import get_logger
14
1215
13class GetLogger(unittest.TestCase):16class GetLogger(unittest.TestCase):
14 def testLogger(self):17 def testLogger(self):
15 """get_logger returns a Logger instance."""18 """get_logger returns a Logger instance."""
16 from lp.registry.scripts.productreleasefinder.log import get_logger19 self.assertTrue(isinstance(get_logger("test"), logging.Logger))
17 from logging import Logger
18 self.assertTrue(isinstance(get_logger("test"), Logger))
1920
20 def testNoParent(self):21 def testNoParent(self):
21 """get_logger works if no parent is given."""22 """get_logger works if no parent is given."""
22 from lp.registry.scripts.productreleasefinder.log import get_logger
23 self.assertEqual(get_logger("test").name, "test")23 self.assertEqual(get_logger("test").name, "test")
2424
25 def testRootParent(self):25 def testRootParent(self):
26 """get_logger works if root logger is given."""26 """get_logger works if root logger is given."""
27 from lp.registry.scripts.productreleasefinder.log import get_logger27 self.assertEqual(get_logger("test", logging.root).name, "test")
28 from logging import root
29 self.assertEqual(get_logger("test", root).name, "test")
3028
31 def testNormalParent(self):29 def testNormalParent(self):
32 """get_logger works if non-root logger is given."""30 """get_logger works if non-root logger is given."""
33 from lp.registry.scripts.productreleasefinder.log import get_logger31 parent = logging.getLogger("foo")
34 from logging import getLogger
35 parent = getLogger("foo")
36 self.assertEqual(get_logger("test", parent).name, "foo.test")32 self.assertEqual(get_logger("test", parent).name, "foo.test")
3733
38 def testDeepParent(self):34 def testDeepParent(self):
39 """get_logger works if deep-level logger is given."""35 """get_logger works if deep-level logger is given."""
40 from lp.registry.scripts.productreleasefinder.log import get_logger36 logging.getLogger("foo")
41 from logging import getLogger37 parent2 = logging.getLogger("foo.bar")
42 getLogger("foo")
43 parent2 = getLogger("foo.bar")
44 self.assertEqual(get_logger("test", parent2).name, "foo.bar.test")38 self.assertEqual(get_logger("test", parent2).name, "foo.bar.test")
diff --git a/lib/lp/services/librarian/client.py b/lib/lp/services/librarian/client.py
index 6787768..a26e39f 100644
--- a/lib/lp/services/librarian/client.py
+++ b/lib/lp/services/librarian/client.py
@@ -37,6 +37,7 @@ from six.moves.urllib.parse import (
37 urlunparse,37 urlunparse,
38 )38 )
39from six.moves.urllib.request import urlopen39from six.moves.urllib.request import urlopen
40from sqlobject import SQLObjectNotFound
40from storm.store import Store41from storm.store import Store
41from zope.interface import implementer42from zope.interface import implementer
4243
@@ -385,7 +386,7 @@ class FileDownloadClient:
385 inaccessible.386 inaccessible.
386 """387 """
387 from lp.services.librarian.model import LibraryFileAlias388 from lp.services.librarian.model import LibraryFileAlias
388 from sqlobject import SQLObjectNotFound389
389 try:390 try:
390 lfa = LibraryFileAlias.get(aliasID)391 lfa = LibraryFileAlias.get(aliasID)
391 except SQLObjectNotFound:392 except SQLObjectNotFound:
diff --git a/lib/lp/services/mail/notificationrecipientset.py b/lib/lp/services/mail/notificationrecipientset.py
index 7297da2..6004399 100644
--- a/lib/lp/services/mail/notificationrecipientset.py
+++ b/lib/lp/services/mail/notificationrecipientset.py
@@ -14,7 +14,10 @@ from operator import attrgetter
1414
15import six15import six
16from zope.interface import implementer16from zope.interface import implementer
17from zope.security.proxy import isinstance as zope_isinstance17from zope.security.proxy import (
18 isinstance as zope_isinstance,
19 removeSecurityProxy,
20 )
1821
19from lp.registry.interfaces.person import IPerson22from lp.registry.interfaces.person import IPerson
20from lp.services.mail.interfaces import (23from lp.services.mail.interfaces import (
@@ -107,8 +110,8 @@ class NotificationRecipientSet:
107110
108 def add(self, persons, reason, header):111 def add(self, persons, reason, header):
109 """See `INotificationRecipientSet`."""112 """See `INotificationRecipientSet`."""
110 from zope.security.proxy import removeSecurityProxy
111 from lp.registry.model.person import get_recipients113 from lp.registry.model.person import get_recipients
114
112 if (IPerson.providedBy(persons) or115 if (IPerson.providedBy(persons) or
113 zope_isinstance(persons, StubPerson)):116 zope_isinstance(persons, StubPerson)):
114 persons = [persons]117 persons = [persons]
@@ -143,8 +146,8 @@ class NotificationRecipientSet:
143146
144 def remove(self, persons):147 def remove(self, persons):
145 """See `INotificationRecipientSet`."""148 """See `INotificationRecipientSet`."""
146 from zope.security.proxy import removeSecurityProxy
147 from lp.registry.model.person import get_recipients149 from lp.registry.model.person import get_recipients
150
148 if IPerson.providedBy(persons):151 if IPerson.providedBy(persons):
149 persons = [persons]152 persons = [persons]
150 for person in persons:153 for person in persons:
diff --git a/lib/lp/testing/layers.py b/lib/lp/testing/layers.py
index 2d07f26..f6e931b 100644
--- a/lib/lp/testing/layers.py
+++ b/lib/lp/testing/layers.py
@@ -78,6 +78,7 @@ from six.moves.urllib.error import (
78 )78 )
79from six.moves.urllib.parse import urlparse79from six.moves.urllib.parse import urlparse
80from six.moves.urllib.request import urlopen80from six.moves.urllib.request import urlopen
81from storm.uri import URI
81from talisker.context import Context82from talisker.context import Context
82import transaction83import transaction
83from webob.request import environ_from_url as orig_environ_from_url84from webob.request import environ_from_url as orig_environ_from_url
@@ -935,9 +936,7 @@ class LaunchpadLayer(LibrarianLayer, MemcachedLayer, RabbitMQLayer):
935 in the testSetUp().936 in the testSetUp().
936 """937 """
937 if LaunchpadLayer._raw_sessiondb_connection is None:938 if LaunchpadLayer._raw_sessiondb_connection is None:
938 from storm.uri import URI939 from lp.services.webapp.adapter import LaunchpadSessionDatabase
939 from lp.services.webapp.adapter import (
940 LaunchpadSessionDatabase)
941 launchpad_session_database = LaunchpadSessionDatabase(940 launchpad_session_database = LaunchpadSessionDatabase(
942 URI('launchpad-session:'))941 URI('launchpad-session:'))
943 LaunchpadLayer._raw_sessiondb_connection = (942 LaunchpadLayer._raw_sessiondb_connection = (
diff --git a/lib/lp/translations/scripts/translations_to_branch.py b/lib/lp/translations/scripts/translations_to_branch.py
index 0e57a88..f07abd5 100644
--- a/lib/lp/translations/scripts/translations_to_branch.py
+++ b/lib/lp/translations/scripts/translations_to_branch.py
@@ -15,7 +15,7 @@ import os.path
1515
16# FIRST Ensure correct plugins are loaded. Do not delete this comment or the16# FIRST Ensure correct plugins are loaded. Do not delete this comment or the
17# line below this comment.17# line below this comment.
18import lp.codehosting # noqa: F40118import lp.codehosting # noqa: F401 # isort: split
1919
20from breezy.errors import NotBranchError20from breezy.errors import NotBranchError
21from breezy.revision import NULL_REVISION21from breezy.revision import NULL_REVISION
diff --git a/lib/sqlobject/__init__.py b/lib/sqlobject/__init__.py
index 3e5f9e4..5450477 100644
--- a/lib/sqlobject/__init__.py
+++ b/lib/sqlobject/__init__.py
@@ -7,13 +7,14 @@ __metaclass__ = type
77
8# SKIP this file when reformatting, due to the sys mangling.8# SKIP this file when reformatting, due to the sys mangling.
9import datetime9import datetime
10import sys
1011
11import six12import six
12from storm.expr import SQL13from storm.expr import SQL
13from storm.sqlobject import * # noqa: F401,F40314from storm.sqlobject import * # noqa: F401,F403
1415
16
15# Provide the same interface from these other locations.17# Provide the same interface from these other locations.
16import sys
17sys.modules['sqlobject.joins'] = sys.modules['sqlobject']18sys.modules['sqlobject.joins'] = sys.modules['sqlobject']
18sys.modules['sqlobject.sqlbuilder'] = sys.modules['sqlobject']19sys.modules['sqlobject.sqlbuilder'] = sys.modules['sqlobject']
19del sys20del sys

Subscribers

People subscribed via source and target branches

to status/vote changes: