Remove collections.abc backwards compatibility

The collections module moves some abstract classes into the abc
submodules in py3. While we supported older versions of python, we
needed to handle importing from either the old or new locations.

Now that we only support runtimes that include the collections.abc
module, we can remove the backwards compatibility handling we had for
the old location.

Change-Id: Idd106a8199fa586e0b34c054383d64218383c001
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
This commit is contained in:
Sean McGinnis 2020-10-16 07:52:36 -05:00
parent 27959daf2b
commit d6df2c20cb
No known key found for this signature in database
GPG Key ID: CE7EE4BFAF8D70C8
4 changed files with 7 additions and 22 deletions

View File

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

View File

@ -14,11 +14,7 @@
"""Cinder common internal object model"""
try:
from collections.abc import Callable
except ImportError:
from collections import Callable
from collections import abc
import contextlib
import datetime
@ -167,7 +163,7 @@ class CinderObjectRegistry(base.VersionedObjectRegistry):
# If registering class has a callable initialization method, call it.
if isinstance(getattr(cls, 'cinder_ovo_cls_init', None),
Callable):
abc.Callable):
cls.cinder_ovo_cls_init()
@ -578,7 +574,7 @@ class CinderObjectSerializer(base.VersionedObjectSerializer):
entity = self._process_iterable(context, self.serialize_entity,
entity)
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.
backport_ver = self._get_capped_obj_version(entity)
entity = entity.obj_to_primitive(backport_ver, self.manifest)

View File

@ -13,11 +13,7 @@
# License for the specific language governing permissions and limitations
# under the License.
try:
import collections.abc as collections
except ImportError:
import collections
import collections.abc as collections
import inspect
import decorator

View File

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