Merge "Import ABC classes from collection.abc"

This commit is contained in:
Zuul 2021-07-20 13:22:42 +00:00 committed by Gerrit Code Review
commit 68e0e9447a
4 changed files with 8 additions and 6 deletions

View File

@ -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":

View File

@ -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:

View File

@ -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()]))

View File

@ -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: