diff options
author | Sean McGinnis <sean.mcginnis@gmail.com> | 2020-04-14 13:31:44 -0500 |
---|---|---|
committer | Sean McGinnis <sean.mcginnis@gmail.com> | 2020-04-14 13:31:44 -0500 |
commit | e9aab34815285954542e6734a1fa48556885d694 (patch) | |
tree | 83786cbf42cb94336134fd2d0c0efd11ade6fe5b | |
parent | 7d144b75e0eaeaab8ed09f8f7270ea4fd2bf04cc (diff) | |
download | taskflow-e9aab34815285954542e6734a1fa48556885d694.tar.gz |
Drop use of deprecated collections classes
Many classes have moved from collections to collections.abc. The
original imports work, but emit deprecation warnings.
Now that we are py3-only, we can drop any references to the older
deprecated locations.
Change-Id: I24b13c8654a33d99bf687a44a36cfdace39e3866
Signed-off-by: Sean McGinnis <sean.mcginnis@gmail.com>
-rw-r--r-- | taskflow/atom.py | 5 | ||||
-rw-r--r-- | taskflow/types/sets.py | 12 | ||||
-rw-r--r-- | taskflow/utils/iter_utils.py | 6 |
3 files changed, 8 insertions, 15 deletions
diff --git a/taskflow/atom.py b/taskflow/atom.py index f356247..6e41204 100644 --- a/taskflow/atom.py +++ b/taskflow/atom.py @@ -17,6 +17,7 @@ import abc import collections +from collections import abc as cabc import itertools from oslo_utils import reflection @@ -28,8 +29,8 @@ from taskflow.utils import misc # Helper types tuples... -_sequence_types = (list, tuple, collections.Sequence) -_set_types = (set, collections.Set) +_sequence_types = (list, tuple, cabc.Sequence) +_set_types = (set, cabc.Set) # the default list of revert arguments to ignore when deriving # revert argument mapping from the revert method signature diff --git a/taskflow/types/sets.py b/taskflow/types/sets.py index 95da1d9..bbd988d 100644 --- a/taskflow/types/sets.py +++ b/taskflow/types/sets.py @@ -15,16 +15,8 @@ # 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 - +from collections.abc import Hashable +from collections.abc import Set import itertools import six diff --git a/taskflow/utils/iter_utils.py b/taskflow/utils/iter_utils.py index d35fe16..8591d23 100644 --- a/taskflow/utils/iter_utils.py +++ b/taskflow/utils/iter_utils.py @@ -14,7 +14,7 @@ # License for the specific language governing permissions and limitations # under the License. -import collections +from collections import abc import itertools import six @@ -25,7 +25,7 @@ def _ensure_iterable(func): @six.wraps(func) def wrapper(it, *args, **kwargs): - if not isinstance(it, collections.Iterable): + if not isinstance(it, abc.Iterable): raise ValueError("Iterable expected, but '%s' is not" " iterable" % it) return func(it, *args, **kwargs) @@ -109,7 +109,7 @@ def unique_seen(its, seen_selector=None): all_its = list(its) for it in all_its: - if not isinstance(it, collections.Iterable): + if not isinstance(it, abc.Iterable): raise ValueError("Iterable expected, but '%s' is" " not iterable" % it) return _gen_it(all_its) |