mirror of
https://github.com/ansible-collections/community.general.git
synced 2025-07-26 06:31:23 -07:00
Python 3.8 collections compatibility fixes.
Includes a new pylint blacklist plugin to prevent regressions.
This commit is contained in:
parent
c4d1f0d416
commit
a11f631ee4
56 changed files with 317 additions and 104 deletions
|
@ -43,6 +43,7 @@ except ImportError:
|
|||
from ansible.module_utils import six
|
||||
from ansible.module_utils.basic import AnsibleModule
|
||||
from ansible.module_utils._text import to_native
|
||||
from ansible.module_utils.common._collections_compat import Mapping
|
||||
|
||||
|
||||
def transform_list_to_dict(list_):
|
||||
|
@ -59,7 +60,7 @@ def transform_list_to_dict(list_):
|
|||
return ret
|
||||
|
||||
for value in list_:
|
||||
if isinstance(value, collections.Mapping):
|
||||
if isinstance(value, Mapping):
|
||||
ret.update(value)
|
||||
else:
|
||||
ret[to_native(value, errors='surrogate_or_strict')] = True
|
||||
|
@ -108,7 +109,7 @@ def merge_list_by_key(original_list, updated_list, key, ignore_when_null=None):
|
|||
|
||||
|
||||
def _str_sorted(obj):
|
||||
if isinstance(obj, collections.Mapping):
|
||||
if isinstance(obj, Mapping):
|
||||
return json.dumps(obj, sort_keys=True)
|
||||
else:
|
||||
return str(obj)
|
||||
|
@ -430,7 +431,7 @@ class OneViewModuleBase(object):
|
|||
# If both values are null, empty or False it will be considered equal.
|
||||
elif not resource1[key] and not resource2[key]:
|
||||
continue
|
||||
elif isinstance(resource1[key], collections.Mapping):
|
||||
elif isinstance(resource1[key], Mapping):
|
||||
# recursive call
|
||||
if not self.compare(resource1[key], resource2[key]):
|
||||
self.module.log(self.MSG_DIFF_AT_KEY.format(key) + debug_resources)
|
||||
|
@ -482,7 +483,7 @@ class OneViewModuleBase(object):
|
|||
resource2 = sorted(resource2, key=_str_sorted)
|
||||
|
||||
for i, val in enumerate(resource1):
|
||||
if isinstance(val, collections.Mapping):
|
||||
if isinstance(val, Mapping):
|
||||
# change comparison function to compare dictionaries
|
||||
if not self.compare(val, resource2[i]):
|
||||
self.module.log("resources are different. " + debug_resources)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue