From 7a1c98b93dd47e53acd936618778062f24d86540 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rajmund=20Hru=C5=A1ka?= <rajmund.hruska@cesnet.cz> Date: Tue, 21 Jun 2022 12:41:26 +0000 Subject: [PATCH] Fix: Correctly import from collections. (Fixes: #2) --- typedcols.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/typedcols.py b/typedcols.py index 30ebccd..421987c 100644 --- a/typedcols.py +++ b/typedcols.py @@ -13,7 +13,12 @@ type definition. __version__ = '0.1.13' __author__ = 'Pavel Kácha <pavel.kacha@cesnet.cz>' -import collections +try: # Python 2 + from collections.abc import MutableMapping + from collections.abc import MutableSequence +except ImportError: # Python 3 + from collections import MutableMapping + from collections import MutableSequence import abc @@ -61,7 +66,7 @@ class TypedDictMetaclass(abc.ABCMeta): dictify_typedef(cls.typedef) -class TypedDict(collections.MutableMapping): +class TypedDict(MutableMapping): """ Dictionary type abstract class, which supports checking of inserted types, based on simple type definition. @@ -222,7 +227,7 @@ class TypedDict(collections.MutableMapping): TypedDict = TypedDictMetaclass("TypedDict", (TypedDict,), {}) -class TypedList(collections.MutableSequence): +class TypedList(MutableSequence): """ List type abstract class, which supports checking of inserted items type. -- GitLab