diff --git a/src/ansiblelint/utils.py b/src/ansiblelint/utils.py index e2a23cd72ce..7261d86db21 100644 --- a/src/ansiblelint/utils.py +++ b/src/ansiblelint/utils.py @@ -26,9 +26,8 @@ import logging import os import re -import warnings from argparse import Namespace -from collections.abc import Generator, ItemsView, Mapping, Sequence +from collections.abc import ItemsView, Mapping, Sequence from functools import lru_cache from pathlib import Path from typing import Any, Callable @@ -878,26 +877,3 @@ def _extend_with_roles(lintables: list[Lintable]) -> None: def convert_to_boolean(value: Any) -> bool: """Use Ansible to convert something to a boolean.""" return bool(boolean(value)) - - -def nested_items( - data: dict[Any, Any] | list[Any], parent: str = "" -) -> Generator[tuple[Any, Any, str], None, None]: - """Iterate a nested data structure.""" - warnings.warn( - "Call to deprecated function ansiblelint.utils.nested_items. " - "Use ansiblelint.yaml_utils.nested_items_path instead.", - category=DeprecationWarning, - stacklevel=2, - ) - if isinstance(data, dict): - for k, v in data.items(): - yield k, v, parent - # pylint: disable=redefined-outer-name - for k, v, returned_parent in nested_items(v, k): - yield k, v, returned_parent - if isinstance(data, list): - for item in data: - yield "list-item", item, parent - for k, v, returned_parent in nested_items(item): - yield k, v, returned_parent diff --git a/test/test_utils.py b/test/test_utils.py index 877ea292c44..5fee3a2a4f7 100644 --- a/test/test_utils.py +++ b/test/test_utils.py @@ -376,24 +376,6 @@ def test_get_rules_dirs_with_custom_rules( assert get_rules_dirs(user_ruledirs, use_default) == expected -def test_nested_items() -> None: - """Verify correct function of nested_items().""" - data = {"foo": "text", "bar": {"some": "text2"}, "fruits": ["apple", "orange"]} - - items = [ - ("foo", "text", ""), - ("bar", {"some": "text2"}, ""), - ("some", "text2", "bar"), - ("fruits", ["apple", "orange"], ""), - ("list-item", "apple", "fruits"), - ("list-item", "orange", "fruits"), - ] - with pytest.deprecated_call( - match=r"Call to deprecated function ansiblelint\.utils\.nested_items.*" - ): - assert list(utils.nested_items(data)) == items - - def test_find_children() -> None: """Verify correct function of find_children().""" utils.find_children(Lintable("examples/playbooks/find_children.yml"))