From 5c06a554a8b87914d8bb4837e34323c9cbbfd935 Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Thu, 10 Sep 2026 17:23:52 +0100 Subject: [PATCH] Use `collections.abc` (#1057) (#1220) * use collections.abc ansible.module_utils.common._collections_compat shall be deprecated in ansible-core 2.24 Use collections.abc Link: https://forum.ansible.com/t/deprecation-warnings-in-ansible-core-2-20/44741 * Apply suggestion from @abikouo * Fix linter errors --------- (cherry picked from commit c643719085a57e3e5907bd88cd133085d0fe7a43) Signed-off-by: Plamerdi Makela Co-authored-by: Plamerdi Makela Co-authored-by: Bikouo Aubin <79859644+abikouo@users.noreply.github.com> Co-authored-by: Bianca Henderson --- changelogs/fragments/20260109-fix-deprecated-calls.yaml | 3 +++ plugins/lookup/k8s.py | 2 +- tests/unit/conftest.py | 2 +- 3 files changed, 5 insertions(+), 2 deletions(-) create mode 100644 changelogs/fragments/20260109-fix-deprecated-calls.yaml diff --git a/changelogs/fragments/20260109-fix-deprecated-calls.yaml b/changelogs/fragments/20260109-fix-deprecated-calls.yaml new file mode 100644 index 00000000..60e3e65d --- /dev/null +++ b/changelogs/fragments/20260109-fix-deprecated-calls.yaml @@ -0,0 +1,3 @@ +--- +minor_changes: + - use `collections.abc` instead of deprecated `ansible.module_utils.common._collections_compat` (https://github.com/ansible-collections/kubernetes.core/pull/1057). diff --git a/plugins/lookup/k8s.py b/plugins/lookup/k8s.py index ec9fc0c6..c524a935 100644 --- a/plugins/lookup/k8s.py +++ b/plugins/lookup/k8s.py @@ -209,9 +209,9 @@ RETURN = """ """ import os +from collections.abc import KeysView from ansible.errors import AnsibleError -from ansible.module_utils.common._collections_compat import KeysView from ansible.module_utils.common.validation import check_type_bool from ansible_collections.kubernetes.core.plugins.module_utils.k8s.client import ( get_api_client, diff --git a/tests/unit/conftest.py b/tests/unit/conftest.py index 107283c9..cdc1a01a 100644 --- a/tests/unit/conftest.py +++ b/tests/unit/conftest.py @@ -4,11 +4,11 @@ __metaclass__ = type import json import sys +from collections.abc import MutableMapping from io import BytesIO import ansible.module_utils.basic import pytest -from ansible.module_utils.common._collections_compat import MutableMapping from ansible.module_utils.common.text.converters import to_bytes