diff options
Diffstat (limited to 'lib/ansible/module_utils/common/_collections_compat.py')
-rw-r--r-- | lib/ansible/module_utils/common/_collections_compat.py | 56 |
1 files changed, 19 insertions, 37 deletions
diff --git a/lib/ansible/module_utils/common/_collections_compat.py b/lib/ansible/module_utils/common/_collections_compat.py index 3412408f..f0f8f0d0 100644 --- a/lib/ansible/module_utils/common/_collections_compat.py +++ b/lib/ansible/module_utils/common/_collections_compat.py @@ -2,45 +2,27 @@ # Simplified BSD License (see licenses/simplified_bsd.txt or https://opensource.org/licenses/BSD-2-Clause) """Collections ABC import shim. -This module is intended only for internal use. -It will go away once the bundled copy of six includes equivalent functionality. -Third parties should not use this. +Use `ansible.module_utils.six.moves.collections_abc` instead, which has been available since ansible-core 2.11. +This module exists only for backwards compatibility. """ from __future__ import absolute_import, division, print_function __metaclass__ = type -try: - """Python 3.3+ branch.""" - from collections.abc import ( - MappingView, - ItemsView, - KeysView, - ValuesView, - Mapping, MutableMapping, - Sequence, MutableSequence, - Set, MutableSet, - Container, - Hashable, - Sized, - Callable, - Iterable, - Iterator, - ) -except ImportError: - """Use old lib location under 2.6-3.2.""" - from collections import ( # type: ignore[no-redef,attr-defined] # pylint: disable=deprecated-class - MappingView, - ItemsView, - KeysView, - ValuesView, - Mapping, MutableMapping, - Sequence, MutableSequence, - Set, MutableSet, - Container, - Hashable, - Sized, - Callable, - Iterable, - Iterator, - ) +# Although this was originally intended for internal use only, it has wide adoption in collections. +# This is due in part to sanity tests previously recommending its use over `collections` imports. +from ansible.module_utils.six.moves.collections_abc import ( # pylint: disable=unused-import + MappingView, + ItemsView, + KeysView, + ValuesView, + Mapping, MutableMapping, + Sequence, MutableSequence, + Set, MutableSet, + Container, + Hashable, + Sized, + Callable, + Iterable, + Iterator, +) |