Merge ~cjwatson/launchpad:no-operator-istype into launchpad:master

Proposed by Colin Watson
Status: Merged
Approved by: Colin Watson
Approved revision: ce227fc2c884e2985b0612e2a8bdaa1a8daf98b1
Merge reported by: Otto Co-Pilot
Merged at revision: not available
Proposed branch: ~cjwatson/launchpad:no-operator-istype
Merge into: launchpad:master
Diff against target: 70 lines (+9/-8)
2 files modified
lib/lp/services/webapp/batching.py (+3/-2)
lib/lp/testing/factory.py (+6/-6)
Reviewer Review Type Date Requested Status
William Grant code Approve
Review via email: mp+379673@code.launchpad.net

Commit message

Convert from operator.is*Type to ABC tests

Description of the change

The operator.is*Type functions no longer exist in Python 3.

To post a comment you must log in.
Revision history for this message
William Grant (wgrant) wrote :

is_security_proxied_or_harmless seems like it could have two isinstances collapsed into one now.

review: Approve (code)
Revision history for this message
Colin Watson (cjwatson) wrote :

Good point, thanks. Done.

Preview Diff

[H/L] Next/Prev Comment, [J/K] Next/Prev File, [N/P] Next/Prev Hunk
diff --git a/lib/lp/services/webapp/batching.py b/lib/lp/services/webapp/batching.py
index 7cba096..ce4d3ea 100644
--- a/lib/lp/services/webapp/batching.py
+++ b/lib/lp/services/webapp/batching.py
@@ -4,7 +4,6 @@
4__metaclass__ = type4__metaclass__ = type
55
6from datetime import datetime6from datetime import datetime
7from operator import isSequenceType
8import re7import re
98
10from iso8601 import (9from iso8601 import (
@@ -14,6 +13,7 @@ from iso8601 import (
14import lazr.batchnavigator13import lazr.batchnavigator
15from lazr.batchnavigator.interfaces import IRangeFactory14from lazr.batchnavigator.interfaces import IRangeFactory
16import simplejson15import simplejson
16from six.moves.collections_abc import Sequence
17from storm import Undef17from storm import Undef
18from storm.expr import (18from storm.expr import (
19 And,19 And,
@@ -220,7 +220,8 @@ class ShadowedList:
220 BatchNavigator and Batch.220 BatchNavigator and Batch.
221 """221 """
222 def __init__(self, values, shadow_values):222 def __init__(self, values, shadow_values):
223 if not isSequenceType(values) or not isSequenceType(shadow_values):223 if (not isinstance(values, Sequence) or
224 not isinstance(shadow_values, Sequence)):
224 raise TypeError("values and shadow_values must be sequences.")225 raise TypeError("values and shadow_values must be sequences.")
225 if len(values) != len(shadow_values):226 if len(values) != len(shadow_values):
226 raise ValueError(227 raise ValueError(
diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
index bac9b17..ff2c03f 100644
--- a/lib/lp/testing/factory.py
+++ b/lib/lp/testing/factory.py
@@ -34,10 +34,6 @@ from email.utils import (
34 )34 )
35import hashlib35import hashlib
36from itertools import count36from itertools import count
37from operator import (
38 isMappingType,
39 isSequenceType,
40 )
41import os37import os
42from StringIO import StringIO38from StringIO import StringIO
43import sys39import sys
@@ -53,6 +49,10 @@ from lazr.jobrunner.jobrunner import SuspendJobException
53import pytz49import pytz
54from pytz import UTC50from pytz import UTC
55import six51import six
52from six.moves.collections_abc import (
53 Mapping,
54 Sequence,
55 )
56from twisted.conch.ssh.common import (56from twisted.conch.ssh.common import (
57 MP,57 MP,
58 NS,58 NS,
@@ -5039,11 +5039,11 @@ def is_security_proxied_or_harmless(obj):
5039 return True5039 return True
5040 if type(obj) in unwrapped_types:5040 if type(obj) in unwrapped_types:
5041 return True5041 return True
5042 if isSequenceType(obj) or isinstance(obj, (set, frozenset)):5042 if isinstance(obj, (Sequence, set, frozenset)):
5043 return all(5043 return all(
5044 is_security_proxied_or_harmless(element)5044 is_security_proxied_or_harmless(element)
5045 for element in obj)5045 for element in obj)
5046 if isMappingType(obj):5046 if isinstance(obj, Mapping):
5047 return all(5047 return all(
5048 (is_security_proxied_or_harmless(key) and5048 (is_security_proxied_or_harmless(key) and
5049 is_security_proxied_or_harmless(obj[key]))5049 is_security_proxied_or_harmless(obj[key]))

Subscribers

People subscribed via source and target branches

to status/vote changes: