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
1diff --git a/lib/lp/services/webapp/batching.py b/lib/lp/services/webapp/batching.py
2index 7cba096..ce4d3ea 100644
3--- a/lib/lp/services/webapp/batching.py
4+++ b/lib/lp/services/webapp/batching.py
5@@ -4,7 +4,6 @@
6 __metaclass__ = type
7
8 from datetime import datetime
9-from operator import isSequenceType
10 import re
11
12 from iso8601 import (
13@@ -14,6 +13,7 @@ from iso8601 import (
14 import lazr.batchnavigator
15 from lazr.batchnavigator.interfaces import IRangeFactory
16 import simplejson
17+from six.moves.collections_abc import Sequence
18 from storm import Undef
19 from storm.expr import (
20 And,
21@@ -220,7 +220,8 @@ class ShadowedList:
22 BatchNavigator and Batch.
23 """
24 def __init__(self, values, shadow_values):
25- if not isSequenceType(values) or not isSequenceType(shadow_values):
26+ if (not isinstance(values, Sequence) or
27+ not isinstance(shadow_values, Sequence)):
28 raise TypeError("values and shadow_values must be sequences.")
29 if len(values) != len(shadow_values):
30 raise ValueError(
31diff --git a/lib/lp/testing/factory.py b/lib/lp/testing/factory.py
32index bac9b17..ff2c03f 100644
33--- a/lib/lp/testing/factory.py
34+++ b/lib/lp/testing/factory.py
35@@ -34,10 +34,6 @@ from email.utils import (
36 )
37 import hashlib
38 from itertools import count
39-from operator import (
40- isMappingType,
41- isSequenceType,
42- )
43 import os
44 from StringIO import StringIO
45 import sys
46@@ -53,6 +49,10 @@ from lazr.jobrunner.jobrunner import SuspendJobException
47 import pytz
48 from pytz import UTC
49 import six
50+from six.moves.collections_abc import (
51+ Mapping,
52+ Sequence,
53+ )
54 from twisted.conch.ssh.common import (
55 MP,
56 NS,
57@@ -5039,11 +5039,11 @@ def is_security_proxied_or_harmless(obj):
58 return True
59 if type(obj) in unwrapped_types:
60 return True
61- if isSequenceType(obj) or isinstance(obj, (set, frozenset)):
62+ if isinstance(obj, (Sequence, set, frozenset)):
63 return all(
64 is_security_proxied_or_harmless(element)
65 for element in obj)
66- if isMappingType(obj):
67+ if isinstance(obj, Mapping):
68 return all(
69 (is_security_proxied_or_harmless(key) and
70 is_security_proxied_or_harmless(obj[key]))

Subscribers

People subscribed via source and target branches

to status/vote changes: