Deprecate module_utils.common.collections.count (#85233)

Co-authored-by: 🇺🇦 Sviatoslav Sydorenko (Святослав Сидоренко) <wk.cvs.github@sydorenko.org.ua>
Co-authored-by: Matt Clay <matt@mystile.com>
pull/85088/merge
Martin Krizek 6 months ago committed by GitHub
parent b4741fc495
commit 487d699226
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

@ -0,0 +1,2 @@
deprecated_features:
- "The ``ansible.module_utils.common.collections.count()`` function is deprecated and will be removed in ansible-core 2.23. Use ``collections.Counter()`` from the Python standard library instead."

@ -6,6 +6,7 @@
from __future__ import annotations
from ansible.module_utils.common import warnings as _warnings
from ansible.module_utils.six import binary_type, text_type
from ansible.module_utils.six.moves.collections_abc import Hashable, Mapping, MutableMapping, Sequence # pylint: disable=unused-import
@ -102,6 +103,11 @@ def count(seq):
code is run on Python 2.6.* where collections.Counter is not available. It should be
deprecated and replaced when support for Python < 2.7 is dropped.
"""
_warnings.deprecate(
msg="The `ansible.module_utils.common.collections.count` function is deprecated.",
version="2.23",
help_text="Use `collections.Counter` from the Python standard library instead.",
)
if not is_iterable(seq):
raise Exception('Argument provided is not an iterable')
counters = dict()

Loading…
Cancel
Save