Merge "Remove collections.abc backwards compatibility"

This commit is contained in:
Zuul 2020-12-06 19:28:11 +00:00 committed by Gerrit Code Review
commit 95d00bd7a6
4 changed files with 7 additions and 22 deletions

View File

@ -50,11 +50,7 @@
"""CLI interface for cinder management.""" """CLI interface for cinder management."""
try: import collections.abc as collections
import collections.abc as collections
except ImportError:
import collections
import logging as python_logging import logging as python_logging
import sys import sys
import time import time

View File

@ -14,11 +14,7 @@
"""Cinder common internal object model""" """Cinder common internal object model"""
try: from collections import abc
from collections.abc import Callable
except ImportError:
from collections import Callable
import contextlib import contextlib
import datetime import datetime
@ -167,7 +163,7 @@ class CinderObjectRegistry(base.VersionedObjectRegistry):
# If registering class has a callable initialization method, call it. # If registering class has a callable initialization method, call it.
if isinstance(getattr(cls, 'cinder_ovo_cls_init', None), if isinstance(getattr(cls, 'cinder_ovo_cls_init', None),
Callable): abc.Callable):
cls.cinder_ovo_cls_init() cls.cinder_ovo_cls_init()
@ -578,7 +574,7 @@ class CinderObjectSerializer(base.VersionedObjectSerializer):
entity = self._process_iterable(context, self.serialize_entity, entity = self._process_iterable(context, self.serialize_entity,
entity) entity)
elif (hasattr(entity, 'obj_to_primitive') and elif (hasattr(entity, 'obj_to_primitive') and
isinstance(entity.obj_to_primitive, Callable)): isinstance(entity.obj_to_primitive, abc.Callable)):
# NOTE(dulek): Backport outgoing object to the capped version. # NOTE(dulek): Backport outgoing object to the capped version.
backport_ver = self._get_capped_obj_version(entity) backport_ver = self._get_capped_obj_version(entity)
entity = entity.obj_to_primitive(backport_ver, self.manifest) entity = entity.obj_to_primitive(backport_ver, self.manifest)

View File

@ -13,11 +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.
try: import collections.abc as collections
import collections.abc as collections
except ImportError:
import collections
import inspect import inspect
import decorator import decorator

View File

@ -13,10 +13,7 @@
# under the License. # under the License.
"""Mock unit tests for the NetApp block storage driver interfaces""" """Mock unit tests for the NetApp block storage driver interfaces"""
try: from collections import abc
from collections.abc import Callable
except ImportError:
from collections import Callable
from cinder.tests.unit import test from cinder.tests.unit import test
from cinder.volume.drivers.netapp.dataontap import block_cmode from cinder.volume.drivers.netapp.dataontap import block_cmode
@ -56,4 +53,4 @@ class NetAppBlockStorageDriverInterfaceTestCase(test.TestCase):
def _get_local_functions(self, obj): def _get_local_functions(self, obj):
"""Get function names of an object without superclass functions.""" """Get function names of an object without superclass functions."""
return set([key for key, value in type(obj).__dict__.items() return set([key for key, value in type(obj).__dict__.items()
if isinstance(value, Callable)]) if isinstance(value, abc.Callable)])