diff --git a/changelogs/fragments/297-scrub_none_parameters-descend-default.yml b/changelogs/fragments/297-scrub_none_parameters-descend-default.yml new file mode 100644 index 00000000000..8874e379b04 --- /dev/null +++ b/changelogs/fragments/297-scrub_none_parameters-descend-default.yml @@ -0,0 +1,2 @@ +breaking_changes: +- module_utils/core - updated the ``scrub_none_parameters`` function so that ``descend_into_lists`` is set to ``True`` by default (https://github.com/ansible-collections/amazon.aws/pull/297). diff --git a/plugins/module_utils/core.py b/plugins/module_utils/core.py index 7e72843d62a..44855fdf3af 100644 --- a/plugins/module_utils/core.py +++ b/plugins/module_utils/core.py @@ -360,7 +360,7 @@ def get_boto3_client_method_parameters(client, method_name, required=False): return parameters -def scrub_none_parameters(parameters, descend_into_lists=False): +def scrub_none_parameters(parameters, descend_into_lists=True): """ Iterate over a dictionary removing any keys that have a None value diff --git a/tests/unit/module_utils/core/test_scrub_none_parameters.py b/tests/unit/module_utils/core/test_scrub_none_parameters.py index a1a1b491788..8c1faf42832 100644 --- a/tests/unit/module_utils/core/test_scrub_none_parameters.py +++ b/tests/unit/module_utils/core/test_scrub_none_parameters.py @@ -83,6 +83,6 @@ @pytest.mark.parametrize("input_params, output_params_no_descend, output_params_descend", scrub_none_test_data) def test_scrub_none_parameters(input_params, output_params_no_descend, output_params_descend): - assert scrub_none_parameters(input_params) == output_params_no_descend + assert scrub_none_parameters(input_params) == output_params_descend assert scrub_none_parameters(input_params, descend_into_lists=False) == output_params_no_descend assert scrub_none_parameters(input_params, descend_into_lists=True) == output_params_descend