diff options
author | Matt Clay <matt@mystile.com> | 2023-02-03 16:22:40 -0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-03 16:22:40 -0800 |
commit | 379058e10f3dbc0fdcaf80394bd09b18927e7d33 (patch) | |
tree | 71d411345c6c140a65c49131e50632d4f9cef363 /test | |
parent | e658995760ac1209cb12df97027a2e282b4536ae (diff) | |
download | ansible-379058e10f3dbc0fdcaf80394bd09b18927e7d33.tar.gz |
Update collections.abc imports (#79911)
* Update `collections.abc` imports
- Use `six.moves` for modules and module_utils
- Use `collections.abc` for controller code
This avoids using `ansible.module_utils.common._collections_compat`,
which was added before the vendored `six` was updated to provide these
imports.
* Update _collections_compat to use six.moves
Also update the custom pylint rule to reflect this change.
Diffstat (limited to 'test')
8 files changed, 8 insertions, 11 deletions
diff --git a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/lookup/noop.py b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/lookup/noop.py index d456986957..639d3c6b05 100644 --- a/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/lookup/noop.py +++ b/test/integration/targets/ansible-doc/broken-docs/collections/ansible_collections/testns/testcol/plugins/lookup/noop.py @@ -32,7 +32,8 @@ RETURN = """ version_added: 1.0.0 """ -from ansible.module_utils.common._collections_compat import Sequence +from collections.abc import Sequence + from ansible.plugins.lookup import LookupBase from ansible.errors import AnsibleError diff --git a/test/lib/ansible_test/_util/controller/sanity/pylint/plugins/unwanted.py b/test/lib/ansible_test/_util/controller/sanity/pylint/plugins/unwanted.py index 1be42f51f2..3649732b8a 100644 --- a/test/lib/ansible_test/_util/controller/sanity/pylint/plugins/unwanted.py +++ b/test/lib/ansible_test/_util/controller/sanity/pylint/plugins/unwanted.py @@ -94,10 +94,7 @@ class AnsibleUnwantedChecker(BaseChecker): )), # see https://docs.python.org/3/library/collections.abc.html - collections=UnwantedEntry('ansible.module_utils.common._collections_compat', - ignore_paths=( - '/lib/ansible/module_utils/common/_collections_compat.py', - ), + collections=UnwantedEntry('ansible.module_utils.six.moves.collections_abc', names=( 'MappingView', 'ItemsView', diff --git a/test/support/integration/plugins/module_utils/network/common/utils.py b/test/support/integration/plugins/module_utils/network/common/utils.py index 8031738781..b15f9015d7 100644 --- a/test/support/integration/plugins/module_utils/network/common/utils.py +++ b/test/support/integration/plugins/module_utils/network/common/utils.py @@ -37,7 +37,7 @@ import json from itertools import chain from ansible.module_utils._text import to_text, to_bytes -from ansible.module_utils.common._collections_compat import Mapping +from ansible.module_utils.six.moves.collections_abc import Mapping from ansible.module_utils.six import iteritems, string_types from ansible.module_utils import basic from ansible.module_utils.parsing.convert_bool import boolean diff --git a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/utils.py b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/utils.py index 64eca15763..47b3b0aca0 100644 --- a/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/utils.py +++ b/test/support/network-integration/collections/ansible_collections/ansible/netcommon/plugins/module_utils/network/common/utils.py @@ -37,7 +37,7 @@ import json from itertools import chain from ansible.module_utils._text import to_text, to_bytes -from ansible.module_utils.common._collections_compat import Mapping +from ansible.module_utils.six.moves.collections_abc import Mapping from ansible.module_utils.six import iteritems, string_types from ansible.module_utils import basic from ansible.module_utils.parsing.convert_bool import boolean diff --git a/test/units/executor/module_common/test_recursive_finder.py b/test/units/executor/module_common/test_recursive_finder.py index 651ed78255..95b49d354d 100644 --- a/test/units/executor/module_common/test_recursive_finder.py +++ b/test/units/executor/module_common/test_recursive_finder.py @@ -42,7 +42,6 @@ MODULE_UTILS_BASIC_FILES = frozenset(('ansible/__init__.py', 'ansible/module_utils/basic.py', 'ansible/module_utils/six/__init__.py', 'ansible/module_utils/_text.py', - 'ansible/module_utils/common/_collections_compat.py', 'ansible/module_utils/common/_json_compat.py', 'ansible/module_utils/common/collections.py', 'ansible/module_utils/common/parameters.py', diff --git a/test/units/module_utils/common/test_collections.py b/test/units/module_utils/common/test_collections.py index 95b2a402f2..72913edb14 100644 --- a/test/units/module_utils/common/test_collections.py +++ b/test/units/module_utils/common/test_collections.py @@ -9,7 +9,7 @@ __metaclass__ = type import pytest from ansible.module_utils.six import Iterator -from ansible.module_utils.common._collections_compat import Sequence +from ansible.module_utils.six.moves.collections_abc import Sequence from ansible.module_utils.common.collections import ImmutableDict, is_iterable, is_sequence diff --git a/test/units/module_utils/conftest.py b/test/units/module_utils/conftest.py index 8bc13c4d55..dc810652c7 100644 --- a/test/units/module_utils/conftest.py +++ b/test/units/module_utils/conftest.py @@ -13,7 +13,7 @@ import pytest import ansible.module_utils.basic from ansible.module_utils.six import PY3, string_types from ansible.module_utils._text import to_bytes -from ansible.module_utils.common._collections_compat import MutableMapping +from ansible.module_utils.six.moves.collections_abc import MutableMapping @pytest.fixture diff --git a/test/units/modules/conftest.py b/test/units/modules/conftest.py index a7d1e0475f..b5cd636b63 100644 --- a/test/units/modules/conftest.py +++ b/test/units/modules/conftest.py @@ -10,7 +10,7 @@ import pytest from ansible.module_utils.six import string_types from ansible.module_utils._text import to_bytes -from ansible.module_utils.common._collections_compat import MutableMapping +from ansible.module_utils.six.moves.collections_abc import MutableMapping @pytest.fixture |