Import ABC classes from collection.abc
ABC classes should be imported from "collections.abc", not "collections". Closes-Bug: #1936667 Change-Id: I863f21b310fdf39030b13e2926e947b16043851a
This commit is contained in:
parent
d20b8708bc
commit
e961c6d473
@ -12,13 +12,13 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import collections
|
||||
from collections import abc
|
||||
import uuid
|
||||
|
||||
|
||||
def val_to_py(val):
|
||||
"""Convert a json ovsdb return value to native python object"""
|
||||
if isinstance(val, collections.Sequence) and len(val) == 2:
|
||||
if isinstance(val, abc.Sequence) and len(val) == 2:
|
||||
if val[0] == "uuid":
|
||||
return uuid.UUID(val[1])
|
||||
elif val[0] == "set":
|
||||
|
@ -12,6 +12,7 @@
|
||||
|
||||
import abc
|
||||
import collections
|
||||
from collections import abc as collections_abc
|
||||
import copy
|
||||
import functools
|
||||
import itertools
|
||||
@ -282,7 +283,7 @@ class NeutronObject(obj_base.VersionedObject,
|
||||
|
||||
@classmethod
|
||||
def _update_objects(cls, objects, values):
|
||||
if not isinstance(objects, collections.Sequence):
|
||||
if not isinstance(objects, collections_abc.Sequence):
|
||||
objects = (objects, )
|
||||
|
||||
for obj in objects:
|
||||
|
@ -13,7 +13,7 @@
|
||||
# License for the specific language governing permissions and limitations
|
||||
# under the License.
|
||||
|
||||
import collections
|
||||
from collections import abc
|
||||
import itertools
|
||||
import re
|
||||
import sys
|
||||
@ -142,7 +142,7 @@ def _is_attribute_explicitly_set(attribute_name, resource, target, action):
|
||||
def _should_validate_sub_attributes(attribute, sub_attr):
|
||||
"""Verify that sub-attributes are iterable and should be validated."""
|
||||
validate = attribute.get('validate')
|
||||
return (validate and isinstance(sub_attr, collections.Iterable) and
|
||||
return (validate and isinstance(sub_attr, abc.Iterable) and
|
||||
any([k.startswith('type:dict') and
|
||||
v for (k, v) in validate.items()]))
|
||||
|
||||
|
@ -11,6 +11,7 @@
|
||||
# under the License.
|
||||
|
||||
import collections
|
||||
from collections import abc
|
||||
import copy
|
||||
import itertools
|
||||
import random
|
||||
@ -672,7 +673,7 @@ class _BaseObjectTestCase(object):
|
||||
objs or self.objs):
|
||||
val = v() if callable(v) else v
|
||||
db_obj_key = obj.fields_need_translation.get(k, k)
|
||||
if isinstance(val, collections.Mapping):
|
||||
if isinstance(val, abc.Mapping):
|
||||
self.update_obj_fields(
|
||||
val, db_obj[db_obj_key], fields[k], obj[k])
|
||||
else:
|
||||
|
Loading…
Reference in New Issue
Block a user