summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSean McGinnis <sean.mcginnis@gmail.com>2019-04-03 11:00:18 -0500
committerStephen Finucane <stephenfin@redhat.com>2019-05-09 10:35:09 +0000
commit23889f561628fc80803fbc6a9a576d392266ef40 (patch)
tree0730c46e09ed3ce5bdababac3bdc3b9ad74599ae
parent09459070fd86797ffbb8729f52569aaf463ad995 (diff)
downloadtaskflow-23889f561628fc80803fbc6a9a576d392266ef40.tar.gz
Handle collections.abc deprecations
The use of ABC classes directly from collections has been deprecated in 3.x versions of Python. The direction is to use the classes defined in collections.abc. Python 2.7 does not have this, but Python 3.8 will be dropping the backwards compatibility to use the old location. Six also does not have support for this yet, so in the mean time to make sure we don't run into issues as folks try to move to 3.8, and to get rid of deprecation warnings in logs, this handles importing from the preferred location and falls back if it not available. Change-Id: I15554bf3c109045ebdc237ce7cb40299f5d1b298 Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
-rw-r--r--taskflow/types/sets.py12
1 files changed, 11 insertions, 1 deletions
diff --git a/taskflow/types/sets.py b/taskflow/types/sets.py
index 0db43bf..95da1d9 100644
--- a/taskflow/types/sets.py
+++ b/taskflow/types/sets.py
@@ -15,6 +15,16 @@
# under the License.
import collections
+
+# TODO(smcginnis) update this once six has support for collections.abc
+# (https://github.com/benjaminp/six/pull/241) or clean up once we drop py2.7.
+try:
+ from collections.abc import Hashable
+ from collections.abc import Set
+except ImportError:
+ from collections import Hashable
+ from collections import Set
+
import itertools
import six
@@ -32,7 +42,7 @@ def _merge_in(target, iterable=None, sentinel=_sentinel):
return target
-class OrderedSet(collections.Set, collections.Hashable):
+class OrderedSet(Set, Hashable):
"""A read-only hashable set that retains insertion/initial ordering.
It should work in all existing places that ``frozenset`` is used.