[Notes] [Git][BuildStream/buildstream][master] 2 commits: Use collections.abc for Mapping, Iterable



Title: GitLab

Tristan Van Berkom pushed to branch master at BuildStream / buildstream

Commits:

2 changed files:

Changes:

  • buildstream/_frontend/complete.py
    ... ... @@ -31,7 +31,7 @@
    31 31
     #  (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
    
    32 32
     #  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
    
    33 33
     #
    
    34
    -import collections
    
    34
    +import collections.abc
    
    35 35
     import copy
    
    36 36
     import os
    
    37 37
     
    
    ... ... @@ -218,7 +218,7 @@ def is_incomplete_argument(current_params, cmd_param):
    218 218
             return True
    
    219 219
         if cmd_param.nargs == -1:
    
    220 220
             return True
    
    221
    -    if isinstance(current_param_values, collections.Iterable) \
    
    221
    +    if isinstance(current_param_values, collections.abc.Iterable) \
    
    222 222
                 and cmd_param.nargs > 1 and len(current_param_values) < cmd_param.nargs:
    
    223 223
             return True
    
    224 224
         return False
    

  • buildstream/_yaml.py
    ... ... @@ -287,7 +287,7 @@ def node_decorate_dict(filename, target, source, toplevel):
    287 287
             provenance.members[key] = member
    
    288 288
     
    
    289 289
             target_value = target.get(key)
    
    290
    -        if isinstance(value, collections.Mapping):
    
    290
    +        if isinstance(value, collections.abc.Mapping):
    
    291 291
                 node_decorate_dict(filename, target_value, value, toplevel)
    
    292 292
             elif isinstance(value, list):
    
    293 293
                 member.elements = node_decorate_list(filename, target_value, value, toplevel)
    
    ... ... @@ -302,7 +302,7 @@ def node_decorate_list(filename, target, source, toplevel):
    302 302
             target_item = target[idx]
    
    303 303
             element = ElementProvenance(filename, source, idx, toplevel)
    
    304 304
     
    
    305
    -        if isinstance(item, collections.Mapping):
    
    305
    +        if isinstance(item, collections.abc.Mapping):
    
    306 306
                 node_decorate_dict(filename, target_item, item, toplevel)
    
    307 307
             elif isinstance(item, list):
    
    308 308
                 element.elements = node_decorate_list(filename, target_item, item, toplevel)
    
    ... ... @@ -578,7 +578,7 @@ def is_ruamel_str(value):
    578 578
     #
    
    579 579
     def is_composite_list(node):
    
    580 580
     
    
    581
    -    if isinstance(node, collections.Mapping):
    
    581
    +    if isinstance(node, collections.abc.Mapping):
    
    582 582
             has_directives = False
    
    583 583
             has_keys = False
    
    584 584
     
    
    ... ... @@ -847,7 +847,7 @@ def composite_dict(target, source, path=None):
    847 847
     
    
    848 848
             target_value = target.get(key)
    
    849 849
     
    
    850
    -        if isinstance(source_value, collections.Mapping):
    
    850
    +        if isinstance(source_value, collections.abc.Mapping):
    
    851 851
     
    
    852 852
                 # Handle creating new dicts on target side
    
    853 853
                 if target_value is None:
    
    ... ... @@ -862,7 +862,7 @@ def composite_dict(target, source, path=None):
    862 862
                     # Add a new provenance member element to the containing dict
    
    863 863
                     target_provenance.members[key] = source_provenance.members[key]
    
    864 864
     
    
    865
    -            if not isinstance(target_value, collections.Mapping):
    
    865
    +            if not isinstance(target_value, collections.abc.Mapping):
    
    866 866
                     raise CompositeTypeError(thispath, type(target_value), type(source_value))
    
    867 867
     
    
    868 868
                 # Recurse into matching dictionary
    
    ... ... @@ -923,7 +923,7 @@ RoundTripRepresenter.add_representer(SanitizedDict,
    923 923
     #
    
    924 924
     def node_sanitize(node):
    
    925 925
     
    
    926
    -    if isinstance(node, collections.Mapping):
    
    926
    +    if isinstance(node, collections.abc.Mapping):
    
    927 927
     
    
    928 928
             result = SanitizedDict()
    
    929 929
     
    
    ... ... @@ -1067,7 +1067,7 @@ class ChainMap(collections.ChainMap):
    1067 1067
     def node_chain_copy(source):
    
    1068 1068
         copy = ChainMap({}, source)
    
    1069 1069
         for key, value in source.items():
    
    1070
    -        if isinstance(value, collections.Mapping):
    
    1070
    +        if isinstance(value, collections.abc.Mapping):
    
    1071 1071
                 copy[key] = node_chain_copy(value)
    
    1072 1072
             elif isinstance(value, list):
    
    1073 1073
                 copy[key] = list_chain_copy(value)
    
    ... ... @@ -1080,7 +1080,7 @@ def node_chain_copy(source):
    1080 1080
     def list_chain_copy(source):
    
    1081 1081
         copy = []
    
    1082 1082
         for item in source:
    
    1083
    -        if isinstance(item, collections.Mapping):
    
    1083
    +        if isinstance(item, collections.abc.Mapping):
    
    1084 1084
                 copy.append(node_chain_copy(item))
    
    1085 1085
             elif isinstance(item, list):
    
    1086 1086
                 copy.append(list_chain_copy(item))
    
    ... ... @@ -1095,7 +1095,7 @@ def list_chain_copy(source):
    1095 1095
     def node_copy(source):
    
    1096 1096
         copy = {}
    
    1097 1097
         for key, value in source.items():
    
    1098
    -        if isinstance(value, collections.Mapping):
    
    1098
    +        if isinstance(value, collections.abc.Mapping):
    
    1099 1099
                 copy[key] = node_copy(value)
    
    1100 1100
             elif isinstance(value, list):
    
    1101 1101
                 copy[key] = list_copy(value)
    
    ... ... @@ -1112,7 +1112,7 @@ def node_copy(source):
    1112 1112
     def list_copy(source):
    
    1113 1113
         copy = []
    
    1114 1114
         for item in source:
    
    1115
    -        if isinstance(item, collections.Mapping):
    
    1115
    +        if isinstance(item, collections.abc.Mapping):
    
    1116 1116
                 copy.append(node_copy(item))
    
    1117 1117
             elif isinstance(item, list):
    
    1118 1118
                 copy.append(list_copy(item))
    
    ... ... @@ -1147,7 +1147,7 @@ def node_final_assertions(node):
    1147 1147
                 raise LoadError(LoadErrorReason.TRAILING_LIST_DIRECTIVE,
    
    1148 1148
                                 "{}: Attempt to override non-existing list".format(provenance))
    
    1149 1149
     
    
    1150
    -        if isinstance(value, collections.Mapping):
    
    1150
    +        if isinstance(value, collections.abc.Mapping):
    
    1151 1151
                 node_final_assertions(value)
    
    1152 1152
             elif isinstance(value, list):
    
    1153 1153
                 list_final_assertions(value)
    
    ... ... @@ -1155,7 +1155,7 @@ def node_final_assertions(node):
    1155 1155
     
    
    1156 1156
     def list_final_assertions(values):
    
    1157 1157
         for value in values:
    
    1158
    -        if isinstance(value, collections.Mapping):
    
    1158
    +        if isinstance(value, collections.abc.Mapping):
    
    1159 1159
                 node_final_assertions(value)
    
    1160 1160
             elif isinstance(value, list):
    
    1161 1161
                 list_final_assertions(value)
    



  • [Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]