From 20d7be4f38ca67c0608f838ea094cdf053b3471a Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Sun, 16 Jun 2024 10:10:55 +0200 Subject: [PATCH] [PR #8512/ec4cf555 backport][stable-9] simplify cmd_runner_fmt.as_bool_not() (#8515) simplify cmd_runner_fmt.as_bool_not() (#8512) * simplify cmd_runner_fmt.as_bool_not() * add changelog frag (cherry picked from commit ec4cf55566478b7311be04a3a573c050487c72c3) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- changelogs/fragments/8512-as-bool-not.yml | 2 ++ plugins/module_utils/cmd_runner.py | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) create mode 100644 changelogs/fragments/8512-as-bool-not.yml diff --git a/changelogs/fragments/8512-as-bool-not.yml b/changelogs/fragments/8512-as-bool-not.yml new file mode 100644 index 0000000000..f579c19810 --- /dev/null +++ b/changelogs/fragments/8512-as-bool-not.yml @@ -0,0 +1,2 @@ +minor_changes: + - cmd_runner_fmt module utils - simplify implementation of ``cmd_runner_fmt.as_bool_not()`` (https://github.com/ansible-collections/community.general/pull/8512). diff --git a/plugins/module_utils/cmd_runner.py b/plugins/module_utils/cmd_runner.py index 8b4e76ba7c..da4f1b6fc5 100644 --- a/plugins/module_utils/cmd_runner.py +++ b/plugins/module_utils/cmd_runner.py @@ -127,7 +127,7 @@ class _Format(object): @staticmethod def as_bool_not(args): - return _ArgFormat(lambda value: [] if value else _ensure_list(args), ignore_none=False) + return _Format.as_bool([], args, ignore_none=False) @staticmethod def as_optval(arg, ignore_none=None):