diff --git a/plugins/filter/fact_diff.py b/plugins/filter/fact_diff.py index 742d6bca..1eb13bb6 100644 --- a/plugins/filter/fact_diff.py +++ b/plugins/filter/fact_diff.py @@ -15,47 +15,50 @@ DOCUMENTATION = """ name: fact_diff author: Ashwini Mhatre ((@amhatre)) - version_added: "2.12.0" + version_added: 2.12.0 short_description: Find the difference between currently set facts description: - - Compare two facts or variables and get a diff. + - Compare two facts or variables and get a diff. options: - before: + before: + description: + - The first fact to be used in the comparison. + type: raw + required: true + after: + description: + - The second fact to be used in the comparison. + type: raw + required: true + plugin: + description: + - Configure and specify the diff plugin to use + type: dict + default: {} + suboptions: + name: description: - - The first fact to be used in the comparison. - type: raw - required: True - after: + - 'The diff plugin to use, in fully qualified collection name format.' + default: ansible.utils.native + type: str + vars: description: - - The second fact to be used in the comparison. - type: raw - required: True - plugin: - description: - - Configure and specify the diff plugin to use + - Parameters passed to the diff plugin. type: dict default: {} suboptions: - name: - description: - - The diff plugin to use, in fully qualified collection name format. - default: ansible.utils.native - type: str - vars: - description: - - Parameters passed to the diff plugin. - type: dict - default: {} - suboptions: - skip_lines: - description: - - Skip lines matching these regular expressions. - - Matches will be removed prior to the diff. - - If the provided I(before) and I(after) are a string, they will be split. - - Each entry in each list will be cast to a string for the comparison - type: list - elements: str - notes: + skip_lines: + description: + - Skip lines matching these regular expressions. + - Matches will be removed prior to the diff. + - >- + If the provided I(before) and I(after) are a string, they will + be split. + - >- + Each entry in each list will be cast to a string for the + comparison + type: list + elements: str """ EXAMPLES = """ @@ -164,6 +167,7 @@ - Returns diff between before and after facts. """ from ansible.errors import AnsibleFilterError +from ansible.module_utils._text import to_text from ansible_collections.ansible.utils.plugins.module_utils.common.argspec_validate import ( AnsibleArgSpecValidator, @@ -189,10 +193,7 @@ def _fact_diff(*args, **kwargs): if not valid: raise AnsibleFilterError(errors) res = fact_diff(**updated_data) - import json - - res = str(res) - return res + return to_text(res) class FilterModule(object): diff --git a/plugins/filter/next_nth_usable.py b/plugins/filter/next_nth_usable.py index b2aee07d..1f766d02 100644 --- a/plugins/filter/next_nth_usable.py +++ b/plugins/filter/next_nth_usable.py @@ -127,8 +127,7 @@ def next_nth_usable(value, offset): v = netaddr.IPNetwork(v) except Exception: return False - - if isinstance(offset) is not int: + if not isinstance(offset, int): raise AnsibleFilterError("Must pass in an integer") if v.size > 1: first_usable, last_usable = _first_last(v) diff --git a/plugins/filter/previous_nth_usable.py b/plugins/filter/previous_nth_usable.py index ef99d245..6f767dd2 100644 --- a/plugins/filter/previous_nth_usable.py +++ b/plugins/filter/previous_nth_usable.py @@ -127,7 +127,7 @@ def previous_nth_usable(value, offset): except Exception: return False - if isinstance(offset) is not int: + if not isinstance(offset, int): raise AnsibleFilterError("Must pass in an integer") if v.size > 1: first_usable, last_usable = _first_last(v) diff --git a/tests/unit/mock/loader.py b/tests/unit/mock/loader.py index cfd7fe96..0fc53edc 100644 --- a/tests/unit/mock/loader.py +++ b/tests/unit/mock/loader.py @@ -31,7 +31,7 @@ class DictDataLoader(DataLoader): def __init__(self, file_mapping=None): file_mapping = {} if file_mapping is None else file_mapping - assert isinstance(file_mapping) is dict + assert isinstance(file_mapping, dict) super(DictDataLoader, self).__init__()