Merge ~cjwatson/launchpad:py3-with-metaclass into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: 95aee4b84835b38520d64b793f79f2bcd2d0b1ee
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:py3-with-metaclass
Merge into: launchpad:master
Diff against target: 451 lines (+54/-58)
20 files modified
lib/lp/app/widgets/tests/test_popup.py (+4/-3)
lib/lp/bugs/model/apportjob.py (+2/-2)
lib/lp/code/model/branchjob.py (+3/-3)
lib/lp/code/model/branchmergeproposaljob.py (+2/-3)
lib/lp/code/model/gitjob.py (+2/-3)
lib/lp/oci/model/ocirecipebuildjob.py (+3/-3)
lib/lp/oci/model/ocirecipejob.py (+3/-3)
lib/lp/registry/model/persontransferjob.py (+2/-3)
lib/lp/registry/model/sharingjob.py (+2/-3)
lib/lp/services/tests/test_utils.py (+4/-2)
lib/lp/services/webhooks/model.py (+2/-3)
lib/lp/snappy/model/snapbuildjob.py (+3/-3)
lib/lp/snappy/model/snapjob.py (+2/-3)
lib/lp/soyuz/model/archivejob.py (+3/-3)
lib/lp/soyuz/model/distributionjob.py (+3/-3)
lib/lp/soyuz/model/packagecopyjob.py (+3/-3)
lib/lp/soyuz/model/packagediffjob.py (+3/-3)
lib/lp/soyuz/model/packagetranslationsuploadjob.py (+3/-3)
lib/lp/testing/factory.py (+2/-3)
lib/lp/translations/model/translationsharingjob.py (+3/-3)
Reviewer Review Type Date Requested Status
Thiago F. Pappacena (community) Approve
Review via email: mp+383356@code.launchpad.net

Commit message

Use six.with_metaclass rather than __metaclass__

Description of the change

The old syntax no longer works in Python 3. See:

  https://www.python.org/dev/peps/pep-3115/

To post a comment you must log in.
Revision history for this message
Thiago F. Pappacena (pappacena) wrote :

LGTM

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/widgets/tests/test_popup.py b/lib/lp/app/widgets/tests/test_popup.py
2index ad6f7ed..346e7d7 100644
3--- a/lib/lp/app/widgets/tests/test_popup.py
4+++ b/lib/lp/app/widgets/tests/test_popup.py
5@@ -4,6 +4,7 @@
6 __metaclass__ = type
7
8 import simplejson
9+import six
10 from zope.interface import Interface
11 from zope.interface.interface import InterfaceClass
12 from zope.schema import Choice
13@@ -34,9 +35,9 @@ class TestMetaClass(InterfaceClass):
14 __module__=__module__)
15
16
17-class ITest(Interface):
18-# The schema class for the widget we will test.
19- __metaclass__ = TestMetaClass
20+class ITest(six.with_metaclass(TestMetaClass, Interface)):
21+ # The schema class for the widget we will test.
22+ pass
23
24
25 class TestVocabularyPickerWidget(TestCaseWithFactory):
26diff --git a/lib/lp/bugs/model/apportjob.py b/lib/lp/bugs/model/apportjob.py
27index c91c6ec..b99e3eb 100644
28--- a/lib/lp/bugs/model/apportjob.py
29+++ b/lib/lp/bugs/model/apportjob.py
30@@ -114,9 +114,9 @@ class ApportJob(StormBase):
31
32 @delegate_to(IApportJob)
33 @provider(IApportJobSource)
34-class ApportJobDerived(BaseRunnableJob):
35+class ApportJobDerived(
36+ six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
37 """Intermediate class for deriving from ApportJob."""
38- __metaclass__ = EnumeratedSubclass
39
40 def __init__(self, job):
41 self.context = job
42diff --git a/lib/lp/code/model/branchjob.py b/lib/lp/code/model/branchjob.py
43index 01a1f66..a26c47b 100644
44--- a/lib/lp/code/model/branchjob.py
45+++ b/lib/lp/code/model/branchjob.py
46@@ -38,6 +38,7 @@ from lazr.enum import (
47 DBEnumeratedType,
48 DBItem,
49 )
50+import six
51 from storm.exceptions import LostObjectError
52 from storm.expr import (
53 And,
54@@ -241,9 +242,8 @@ class BranchJob(StormBase):
55
56
57 @delegate_to(IBranchJob)
58-class BranchJobDerived(BaseRunnableJob):
59-
60- __metaclass__ = EnumeratedSubclass
61+class BranchJobDerived(
62+ six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
63
64 def __init__(self, branch_job):
65 self.context = branch_job
66diff --git a/lib/lp/code/model/branchmergeproposaljob.py b/lib/lp/code/model/branchmergeproposaljob.py
67index bd9fbef..d657f34 100644
68--- a/lib/lp/code/model/branchmergeproposaljob.py
69+++ b/lib/lp/code/model/branchmergeproposaljob.py
70@@ -225,11 +225,10 @@ class BranchMergeProposalJob(StormBase):
71
72
73 @delegate_to(IBranchMergeProposalJob)
74-class BranchMergeProposalJobDerived(BaseRunnableJob):
75+class BranchMergeProposalJobDerived(
76+ six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
77 """Intermediate class for deriving from BranchMergeProposalJob."""
78
79- __metaclass__ = EnumeratedSubclass
80-
81 def __init__(self, job):
82 self.context = job
83
84diff --git a/lib/lp/code/model/gitjob.py b/lib/lp/code/model/gitjob.py
85index fc11a40..3c041da 100644
86--- a/lib/lp/code/model/gitjob.py
87+++ b/lib/lp/code/model/gitjob.py
88@@ -17,6 +17,7 @@ from lazr.enum import (
89 DBEnumeratedType,
90 DBItem,
91 )
92+import six
93 from storm.exceptions import LostObjectError
94 from storm.locals import (
95 Int,
96@@ -140,9 +141,7 @@ class GitJob(StormBase):
97
98
99 @delegate_to(IGitJob)
100-class GitJobDerived(BaseRunnableJob):
101-
102- __metaclass__ = EnumeratedSubclass
103+class GitJobDerived(six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
104
105 def __init__(self, git_job):
106 self.context = git_job
107diff --git a/lib/lp/oci/model/ocirecipebuildjob.py b/lib/lp/oci/model/ocirecipebuildjob.py
108index c17ecf3..bd34c19 100644
109--- a/lib/lp/oci/model/ocirecipebuildjob.py
110+++ b/lib/lp/oci/model/ocirecipebuildjob.py
111@@ -18,6 +18,7 @@ from lazr.enum import (
112 DBItem,
113 )
114 from lazr.lifecycle.event import ObjectCreatedEvent
115+import six
116 from storm.databases.postgres import JSON
117 from storm.locals import (
118 Int,
119@@ -98,9 +99,8 @@ class OCIRecipeBuildJob(StormBase):
120
121
122 @delegate_to(IOCIRecipeBuildJob)
123-class OCIRecipeBuildJobDerived(BaseRunnableJob):
124-
125- __metaclass__ = EnumeratedSubclass
126+class OCIRecipeBuildJobDerived(
127+ six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
128
129 def __init__(self, oci_build_job):
130 self.context = oci_build_job
131diff --git a/lib/lp/oci/model/ocirecipejob.py b/lib/lp/oci/model/ocirecipejob.py
132index 529d7c1..7e18485 100644
133--- a/lib/lp/oci/model/ocirecipejob.py
134+++ b/lib/lp/oci/model/ocirecipejob.py
135@@ -14,6 +14,7 @@ from lazr.enum import (
136 DBEnumeratedType,
137 DBItem,
138 )
139+import six
140 from storm.databases.postgres import JSON
141 from storm.properties import Int
142 from storm.references import Reference
143@@ -98,9 +99,8 @@ class OCIRecipeJob(StormBase):
144
145
146 @delegate_to(IOCIRecipeJob)
147-class OCIRecipeJobDerived(BaseRunnableJob):
148-
149- __metaclass__ = EnumeratedSubclass
150+class OCIRecipeJobDerived(
151+ six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
152
153 def __init__(self, recipe_job):
154 self.context = recipe_job
155diff --git a/lib/lp/registry/model/persontransferjob.py b/lib/lp/registry/model/persontransferjob.py
156index 426adf1..60ec767 100644
157--- a/lib/lp/registry/model/persontransferjob.py
158+++ b/lib/lp/registry/model/persontransferjob.py
159@@ -130,7 +130,8 @@ class PersonTransferJob(StormBase):
160
161 @delegate_to(IPersonTransferJob)
162 @provider(IPersonTransferJobSource)
163-class PersonTransferJobDerived(BaseRunnableJob):
164+class PersonTransferJobDerived(
165+ six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
166 """Intermediate class for deriving from PersonTransferJob.
167
168 Storm classes can't simply be subclassed or you can end up with
169@@ -140,8 +141,6 @@ class PersonTransferJobDerived(BaseRunnableJob):
170 the run() method.
171 """
172
173- __metaclass__ = EnumeratedSubclass
174-
175 def __init__(self, job):
176 self.context = job
177
178diff --git a/lib/lp/registry/model/sharingjob.py b/lib/lp/registry/model/sharingjob.py
179index 9d2c444..cc2c22e 100644
180--- a/lib/lp/registry/model/sharingjob.py
181+++ b/lib/lp/registry/model/sharingjob.py
182@@ -172,11 +172,10 @@ class SharingJob(StormBase):
183
184 @delegate_to(ISharingJob)
185 @provider(ISharingJobSource)
186-class SharingJobDerived(BaseRunnableJob):
187+class SharingJobDerived(
188+ six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
189 """Intermediate class for deriving from SharingJob."""
190
191- __metaclass__ = EnumeratedSubclass
192-
193 def __init__(self, job):
194 self.context = job
195
196diff --git a/lib/lp/services/tests/test_utils.py b/lib/lp/services/tests/test_utils.py
197index 02922bb..333a612 100644
198--- a/lib/lp/services/tests/test_utils.py
199+++ b/lib/lp/services/tests/test_utils.py
200@@ -15,6 +15,7 @@ import sys
201
202 from fixtures import TempDir
203 from pytz import UTC
204+import six
205 from testtools.matchers import (
206 Equals,
207 GreaterThan,
208@@ -68,8 +69,9 @@ class TestAutoDecorate(TestCase):
209 def test_auto_decorate(self):
210 # All of the decorators passed to AutoDecorate are applied as
211 # decorators in reverse order.
212- class AutoDecoratedClass:
213- __metaclass__ = AutoDecorate(self.decorator_1, self.decorator_2)
214+ class AutoDecoratedClass(
215+ six.with_metaclass(
216+ AutoDecorate(self.decorator_1, self.decorator_2), object)):
217
218 def method_a(s):
219 self.log.append('a')
220diff --git a/lib/lp/services/webhooks/model.py b/lib/lp/services/webhooks/model.py
221index cb42ce9..e60975f 100644
222--- a/lib/lp/services/webhooks/model.py
223+++ b/lib/lp/services/webhooks/model.py
224@@ -368,9 +368,8 @@ class WebhookJob(StormBase):
225
226
227 @delegate_to(IWebhookJob)
228-class WebhookJobDerived(BaseRunnableJob):
229-
230- __metaclass__ = EnumeratedSubclass
231+class WebhookJobDerived(
232+ six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
233
234 def __init__(self, webhook_job):
235 self.context = webhook_job
236diff --git a/lib/lp/snappy/model/snapbuildjob.py b/lib/lp/snappy/model/snapbuildjob.py
237index 3002777..298c00f 100644
238--- a/lib/lp/snappy/model/snapbuildjob.py
239+++ b/lib/lp/snappy/model/snapbuildjob.py
240@@ -20,6 +20,7 @@ from lazr.enum import (
241 DBEnumeratedType,
242 DBItem,
243 )
244+import six
245 from storm.locals import (
246 Int,
247 JSON,
248@@ -115,9 +116,8 @@ class SnapBuildJob(StormBase):
249
250
251 @delegate_to(ISnapBuildJob)
252-class SnapBuildJobDerived(BaseRunnableJob):
253-
254- __metaclass__ = EnumeratedSubclass
255+class SnapBuildJobDerived(
256+ six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
257
258 def __init__(self, snap_build_job):
259 self.context = snap_build_job
260diff --git a/lib/lp/snappy/model/snapjob.py b/lib/lp/snappy/model/snapjob.py
261index 367450f..5b1f08d 100644
262--- a/lib/lp/snappy/model/snapjob.py
263+++ b/lib/lp/snappy/model/snapjob.py
264@@ -19,6 +19,7 @@ from lazr.enum import (
265 DBEnumeratedType,
266 DBItem,
267 )
268+import six
269 from storm.locals import (
270 Desc,
271 Int,
272@@ -120,9 +121,7 @@ class SnapJob(StormBase):
273
274
275 @delegate_to(ISnapJob)
276-class SnapJobDerived(BaseRunnableJob):
277-
278- __metaclass__ = EnumeratedSubclass
279+class SnapJobDerived(six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
280
281 def __init__(self, snap_job):
282 self.context = snap_job
283diff --git a/lib/lp/soyuz/model/archivejob.py b/lib/lp/soyuz/model/archivejob.py
284index 12b8659..b691683 100644
285--- a/lib/lp/soyuz/model/archivejob.py
286+++ b/lib/lp/soyuz/model/archivejob.py
287@@ -7,6 +7,7 @@ import logging
288 import StringIO
289
290 from lazr.delegates import delegate_to
291+import six
292 from storm.expr import And
293 from storm.locals import (
294 Int,
295@@ -77,11 +78,10 @@ class ArchiveJob(StormBase):
296
297 @delegate_to(IArchiveJob)
298 @provider(IArchiveJobSource)
299-class ArchiveJobDerived(BaseRunnableJob):
300+class ArchiveJobDerived(
301+ six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
302 """Intermediate class for deriving from ArchiveJob."""
303
304- __metaclass__ = EnumeratedSubclass
305-
306 def __init__(self, job):
307 self.context = job
308
309diff --git a/lib/lp/soyuz/model/distributionjob.py b/lib/lp/soyuz/model/distributionjob.py
310index 87bbb6a..57feaf6 100644
311--- a/lib/lp/soyuz/model/distributionjob.py
312+++ b/lib/lp/soyuz/model/distributionjob.py
313@@ -9,6 +9,7 @@ __all__ = [
314 ]
315
316 from lazr.delegates import delegate_to
317+import six
318 from storm.locals import (
319 And,
320 Int,
321@@ -68,11 +69,10 @@ class DistributionJob(StormBase):
322
323
324 @delegate_to(IDistributionJob)
325-class DistributionJobDerived(BaseRunnableJob):
326+class DistributionJobDerived(
327+ six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
328 """Abstract class for deriving from DistributionJob."""
329
330- __metaclass__ = EnumeratedSubclass
331-
332 def __init__(self, job):
333 self.context = job
334
335diff --git a/lib/lp/soyuz/model/packagecopyjob.py b/lib/lp/soyuz/model/packagecopyjob.py
336index a7f41fd..b4d92b2 100644
337--- a/lib/lp/soyuz/model/packagecopyjob.py
338+++ b/lib/lp/soyuz/model/packagecopyjob.py
339@@ -13,6 +13,7 @@ import logging
340 from lazr.delegates import delegate_to
341 from lazr.jobrunner.jobrunner import SuspendJobException
342 from psycopg2.extensions import TransactionRollbackError
343+import six
344 from storm.locals import (
345 Int,
346 JSON,
347@@ -175,11 +176,10 @@ class PackageCopyJob(StormBase):
348
349
350 @delegate_to(IPackageCopyJob)
351-class PackageCopyJobDerived(BaseRunnableJob):
352+class PackageCopyJobDerived(
353+ six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
354 """Abstract class for deriving from PackageCopyJob."""
355
356- __metaclass__ = EnumeratedSubclass
357-
358 def __init__(self, job):
359 self.context = job
360 self.logger = logging.getLogger()
361diff --git a/lib/lp/soyuz/model/packagediffjob.py b/lib/lp/soyuz/model/packagediffjob.py
362index 508143e..9f9cb3d 100644
363--- a/lib/lp/soyuz/model/packagediffjob.py
364+++ b/lib/lp/soyuz/model/packagediffjob.py
365@@ -9,6 +9,7 @@ __all__ = [
366
367 from lazr.delegates import delegate_to
368 import simplejson
369+import six
370 from zope.component import getUtility
371 from zope.interface import (
372 implementer,
373@@ -32,9 +33,8 @@ from lp.soyuz.interfaces.packagediffjob import (
374
375 @delegate_to(IPackageDiffJob)
376 @provider(IPackageDiffJobSource)
377-class PackageDiffJobDerived(BaseRunnableJob):
378-
379- __metaclass__ = EnumeratedSubclass
380+class PackageDiffJobDerived(
381+ six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
382
383 config = config.IPackageDiffJobSource
384
385diff --git a/lib/lp/soyuz/model/packagetranslationsuploadjob.py b/lib/lp/soyuz/model/packagetranslationsuploadjob.py
386index 96134b5..0af6707 100644
387--- a/lib/lp/soyuz/model/packagetranslationsuploadjob.py
388+++ b/lib/lp/soyuz/model/packagetranslationsuploadjob.py
389@@ -13,6 +13,7 @@ import os
390 import tempfile
391
392 from lazr.delegates import delegate_to
393+import six
394 from zope.component import getUtility
395 from zope.interface import (
396 implementer,
397@@ -75,9 +76,8 @@ def _filter_ubuntu_translation_file(filename):
398
399 @delegate_to(IPackageTranslationsUploadJob)
400 @provider(IPackageTranslationsUploadJobSource)
401-class PackageTranslationsUploadJobDerived(BaseRunnableJob):
402-
403- __metaclass__ = EnumeratedSubclass
404+class PackageTranslationsUploadJobDerived(
405+ six.with_metaclass(EnumeratedSubclass, BaseRunnableJob)):
406
407 config = config.IPackageTranslationsUploadJobSource
408
409diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
410index 70c8a01..815ad8f 100644
411--- a/lib/lp/testing/factory.py
412+++ b/lib/lp/testing/factory.py
413@@ -429,11 +429,10 @@ class GPGSigningContext:
414 self.mode = mode
415
416
417-class ObjectFactory:
418+class ObjectFactory(
419+ six.with_metaclass(AutoDecorate(default_master_store)), object):
420 """Factory methods for creating basic Python objects."""
421
422- __metaclass__ = AutoDecorate(default_master_store)
423-
424 # This allocates process-wide unique integers. We count on Python doing
425 # only cooperative threading to make this safe across threads.
426 _unique_int_counter = count(100000)
427diff --git a/lib/lp/translations/model/translationsharingjob.py b/lib/lp/translations/model/translationsharingjob.py
428index 80cdad4..8a60008 100644
429--- a/lib/lp/translations/model/translationsharingjob.py
430+++ b/lib/lp/translations/model/translationsharingjob.py
431@@ -16,6 +16,7 @@ from lazr.enum import (
432 DBEnumeratedType,
433 DBItem,
434 )
435+import six
436 from storm.locals import (
437 Int,
438 Reference,
439@@ -114,11 +115,10 @@ class TranslationSharingJob(StormBase):
440
441
442 @delegate_to(ITranslationSharingJob)
443-class TranslationSharingJobDerived:
444+class TranslationSharingJobDerived(
445+ six.with_metaclass(EnumeratedSubclass, object)):
446 """Base class for specialized TranslationTemplate Job types."""
447
448- __metaclass__ = EnumeratedSubclass
449-
450 def getDBClass(self):
451 return TranslationSharingJob
452

Subscribers

People subscribed via source and target branches

to status/vote changes: