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