diff --git a/yaql/language/utils.py b/yaql/language/utils.py index 97ad8d9..8240baa 100644 --- a/yaql/language/utils.py +++ b/yaql/language/utils.py @@ -32,35 +32,35 @@ NO_VALUE = create_marker('') def is_iterator(obj): - return isinstance(obj, collections.Iterator) + return isinstance(obj, collections.abc.Iterator) def is_iterable(obj): return ( - isinstance(obj, collections.Iterable) and + isinstance(obj, collections.abc.Iterable) and not isinstance(obj, (str, MappingType)) ) def is_sequence(obj): - return isinstance(obj, collections.Sequence) and not isinstance( + return isinstance(obj, collections.abc.Sequence) and not isinstance( obj, str) def is_mutable(obj): - return isinstance(obj, (collections.MutableSequence, - collections.MutableSet, - collections.MutableMapping)) + return isinstance(obj, (collections.abc.MutableSequence, + collections.abc.MutableSet, + collections.abc.MutableMapping)) -SequenceType = collections.Sequence -MutableSequenceType = collections.MutableSequence -SetType = collections.Set -MutableSetType = collections.MutableSet -MappingType = collections.Mapping -MutableMappingType = collections.MutableMapping -IterableType = collections.Iterable -IteratorType = collections.Iterator +SequenceType = collections.abc.Sequence +MutableSequenceType = collections.abc.MutableSequence +SetType = collections.abc.Set +MutableSetType = collections.abc.MutableSet +MappingType = collections.abc.Mapping +MutableMappingType = collections.abc.MutableMapping +IterableType = collections.abc.Iterable +IteratorType = collections.abc.Iterator QueueType = collections.deque @@ -85,7 +85,7 @@ def convert_input_data(obj, rec=None): def convert_output_data(obj, limit_func, engine, rec=None): if rec is None: rec = convert_output_data - if isinstance(obj, collections.Mapping): + if isinstance(obj, collections.abc.Mapping): result = {} for key, value in limit_func(obj.items()): result[rec(key, limit_func, engine, rec)] = rec( @@ -119,7 +119,7 @@ class MappingRule(object): self.destination = destination -class FrozenDict(collections.Mapping): +class FrozenDict(collections.abc.Mapping): def __init__(self, *args, **kwargs): self._d = dict(*args, **kwargs) self._hash = None diff --git a/yaql/language/yaqltypes.py b/yaql/language/yaqltypes.py index 14a7301..d3c8693 100644 --- a/yaql/language/yaqltypes.py +++ b/yaql/language/yaqltypes.py @@ -185,7 +185,7 @@ class Iterable(PythonType): def __init__(self, validators=None, nullable=False): super(Iterable, self).__init__( - collections.Iterable, nullable, + collections.abc.Iterable, nullable, [lambda t: not isinstance(t, (str, utils.MappingType))] + ( validators or [])) @@ -217,7 +217,7 @@ class Sequence(PythonType): def __init__(self, validators=None, nullable=False): super(Sequence, self).__init__( - collections.Sequence, nullable, [ + collections.abc.Sequence, nullable, [ lambda t: not isinstance(t, (str, dict))] + ( validators or [])) diff --git a/yaql/standard_library/queries.py b/yaql/standard_library/queries.py index 103529d..5cc8163 100644 --- a/yaql/standard_library/queries.py +++ b/yaql/standard_library/queries.py @@ -883,7 +883,7 @@ class GroupAggregator(object): else: if not ( len(value_list) == 2 and - isinstance(result, collections.Sequence) and + isinstance(result, collections.abc.Sequence) and not isinstance(result, str) and len(result) == 2 and result[0] == value_list[0]