diff options
author | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2019-01-03 22:36:16 +0000 |
---|---|---|
committer | Tristan Van Berkom <tristan.van.berkom@gmail.com> | 2019-01-03 22:36:16 +0000 |
commit | a85da5910acba5be60746be99a4159a59d10494c (patch) | |
tree | 9f921c646e57e65a86057b7a9d7aad9ba26b72ef | |
parent | d6689ed2047ccc040d8c3445f8b2703306b2122c (diff) | |
parent | e15278d7ccb18c92ece2c08b4cad22916974fd54 (diff) | |
download | buildstream-a85da5910acba5be60746be99a4159a59d10494c.tar.gz |
Merge branch 'coldtom/collections' into 'master'
Use collections.abc for Mapping, Iterable
Closes #831
See merge request BuildStream/buildstream!1020
-rw-r--r-- | buildstream/_frontend/complete.py | 4 | ||||
-rw-r--r-- | buildstream/_yaml.py | 24 |
2 files changed, 14 insertions, 14 deletions
diff --git a/buildstream/_frontend/complete.py b/buildstream/_frontend/complete.py index 1dbdaadb1..bf9324812 100644 --- a/buildstream/_frontend/complete.py +++ b/buildstream/_frontend/complete.py @@ -31,7 +31,7 @@ # (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE # OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. # -import collections +import collections.abc import copy import os @@ -218,7 +218,7 @@ def is_incomplete_argument(current_params, cmd_param): return True if cmd_param.nargs == -1: return True - if isinstance(current_param_values, collections.Iterable) \ + if isinstance(current_param_values, collections.abc.Iterable) \ and cmd_param.nargs > 1 and len(current_param_values) < cmd_param.nargs: return True return False diff --git a/buildstream/_yaml.py b/buildstream/_yaml.py index 8d7302b80..753254e6a 100644 --- a/buildstream/_yaml.py +++ b/buildstream/_yaml.py @@ -287,7 +287,7 @@ def node_decorate_dict(filename, target, source, toplevel): provenance.members[key] = member target_value = target.get(key) - if isinstance(value, collections.Mapping): + if isinstance(value, collections.abc.Mapping): node_decorate_dict(filename, target_value, value, toplevel) elif isinstance(value, list): member.elements = node_decorate_list(filename, target_value, value, toplevel) @@ -302,7 +302,7 @@ def node_decorate_list(filename, target, source, toplevel): target_item = target[idx] element = ElementProvenance(filename, source, idx, toplevel) - if isinstance(item, collections.Mapping): + if isinstance(item, collections.abc.Mapping): node_decorate_dict(filename, target_item, item, toplevel) elif isinstance(item, list): element.elements = node_decorate_list(filename, target_item, item, toplevel) @@ -578,7 +578,7 @@ def is_ruamel_str(value): # def is_composite_list(node): - if isinstance(node, collections.Mapping): + if isinstance(node, collections.abc.Mapping): has_directives = False has_keys = False @@ -847,7 +847,7 @@ def composite_dict(target, source, path=None): target_value = target.get(key) - if isinstance(source_value, collections.Mapping): + if isinstance(source_value, collections.abc.Mapping): # Handle creating new dicts on target side if target_value is None: @@ -862,7 +862,7 @@ def composite_dict(target, source, path=None): # Add a new provenance member element to the containing dict target_provenance.members[key] = source_provenance.members[key] - if not isinstance(target_value, collections.Mapping): + if not isinstance(target_value, collections.abc.Mapping): raise CompositeTypeError(thispath, type(target_value), type(source_value)) # Recurse into matching dictionary @@ -923,7 +923,7 @@ RoundTripRepresenter.add_representer(SanitizedDict, # def node_sanitize(node): - if isinstance(node, collections.Mapping): + if isinstance(node, collections.abc.Mapping): result = SanitizedDict() @@ -1067,7 +1067,7 @@ class ChainMap(collections.ChainMap): def node_chain_copy(source): copy = ChainMap({}, source) for key, value in source.items(): - if isinstance(value, collections.Mapping): + if isinstance(value, collections.abc.Mapping): copy[key] = node_chain_copy(value) elif isinstance(value, list): copy[key] = list_chain_copy(value) @@ -1080,7 +1080,7 @@ def node_chain_copy(source): def list_chain_copy(source): copy = [] for item in source: - if isinstance(item, collections.Mapping): + if isinstance(item, collections.abc.Mapping): copy.append(node_chain_copy(item)) elif isinstance(item, list): copy.append(list_chain_copy(item)) @@ -1095,7 +1095,7 @@ def list_chain_copy(source): def node_copy(source): copy = {} for key, value in source.items(): - if isinstance(value, collections.Mapping): + if isinstance(value, collections.abc.Mapping): copy[key] = node_copy(value) elif isinstance(value, list): copy[key] = list_copy(value) @@ -1112,7 +1112,7 @@ def node_copy(source): def list_copy(source): copy = [] for item in source: - if isinstance(item, collections.Mapping): + if isinstance(item, collections.abc.Mapping): copy.append(node_copy(item)) elif isinstance(item, list): copy.append(list_copy(item)) @@ -1147,7 +1147,7 @@ def node_final_assertions(node): raise LoadError(LoadErrorReason.TRAILING_LIST_DIRECTIVE, "{}: Attempt to override non-existing list".format(provenance)) - if isinstance(value, collections.Mapping): + if isinstance(value, collections.abc.Mapping): node_final_assertions(value) elif isinstance(value, list): list_final_assertions(value) @@ -1155,7 +1155,7 @@ def node_final_assertions(node): def list_final_assertions(values): for value in values: - if isinstance(value, collections.Mapping): + if isinstance(value, collections.abc.Mapping): node_final_assertions(value) elif isinstance(value, list): list_final_assertions(value) |