From c9aae5e45cdf789cd0133346f699ad9ae8cbd432 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Wed, 31 May 2023 17:58:28 +1200 Subject: [PATCH] CmdRunner module utils: deprecate format method `as_default_type()` (#6601) * CmdRunner module utils: deprecate format method `as_default_type()` * add changelog frag --- .../fragments/6601-cmdrunner-deprecate-default-type.yml | 2 ++ plugins/module_utils/cmd_runner.py | 5 +++++ 2 files changed, 7 insertions(+) create mode 100644 changelogs/fragments/6601-cmdrunner-deprecate-default-type.yml diff --git a/changelogs/fragments/6601-cmdrunner-deprecate-default-type.yml b/changelogs/fragments/6601-cmdrunner-deprecate-default-type.yml new file mode 100644 index 0000000000..5bb10dbc29 --- /dev/null +++ b/changelogs/fragments/6601-cmdrunner-deprecate-default-type.yml @@ -0,0 +1,2 @@ +deprecated_features: + - CmdRunner module utils - deprecate ``cmd_runner_fmt.as_default_type()`` formatter (https://github.com/ansible-collections/community.general/pull/6601). diff --git a/plugins/module_utils/cmd_runner.py b/plugins/module_utils/cmd_runner.py index fa4c555d19..846f76f9e3 100644 --- a/plugins/module_utils/cmd_runner.py +++ b/plugins/module_utils/cmd_runner.py @@ -147,6 +147,11 @@ class _Format(object): @staticmethod def as_default_type(_type, arg="", ignore_none=None): + # + # DEPRECATION: This method is deprecated and will be removed in community.general 10.0.0 + # + # Instead of using the implicit formats provided here, use the explicit necessary format method. + # fmt = _Format if _type == "dict": return fmt.as_func(lambda d: ["--{0}={1}".format(*a) for a in iteritems(d)], ignore_none=ignore_none)