diff options
author | bst-marge-bot <marge-bot@buildstream.build> | 2020-04-04 18:08:59 +0000 |
---|---|---|
committer | bst-marge-bot <marge-bot@buildstream.build> | 2020-04-04 18:08:59 +0000 |
commit | 232e65923f838d4b30744d501cd3c27f7370acb7 (patch) | |
tree | ac99f661ce1af26fdabf8bb7398850fa59d10e06 | |
parent | 506e1723efc0afbd09361df3c050c88201fdd268 (diff) | |
parent | 9b4e483fa61a292caf39420aa1496b1adbafacec (diff) | |
download | buildstream-232e65923f838d4b30744d501cd3c27f7370acb7.tar.gz |
Merge branch 'jjardon/bst-1-collections' into 'bst-1'
Use collections.abc for Mapping, Iterable
See merge request BuildStream/buildstream!1854
-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 5606f13e5..e6a3968f8 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 bd3ab15da..4f2f88329 100644 --- a/buildstream/_yaml.py +++ b/buildstream/_yaml.py @@ -280,7 +280,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) @@ -295,7 +295,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) @@ -569,7 +569,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 @@ -838,7 +838,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: @@ -853,7 +853,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 @@ -914,7 +914,7 @@ RoundTripRepresenter.add_representer(SanitizedDict, # def node_sanitize(node): - if isinstance(node, collections.Mapping): + if isinstance(node, collections.abc.Mapping): result = SanitizedDict() @@ -1052,7 +1052,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) @@ -1065,7 +1065,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)) @@ -1080,7 +1080,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) @@ -1097,7 +1097,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)) @@ -1132,7 +1132,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) @@ -1140,7 +1140,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) |