diff --git a/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_facts/vlans.py b/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_facts/vlans.py index 1bf21fcf11f..7b1500e5db4 100644 --- a/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_facts/vlans.py +++ b/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_facts/vlans.py @@ -7,14 +7,7 @@ from functools import cached_property from typing import TYPE_CHECKING -try: - from pyavd.j2filters.convert_dicts import convert_dicts - - PYAVD_IMPORT_EXCEPTION = None -except ImportError as e: - convert_dicts = None - PYAVD_IMPORT_EXCEPTION = e - +from ansible_collections.arista.avd.plugins.filter.convert_dicts import convert_dicts from ansible_collections.arista.avd.plugins.filter.list_compress import list_compress from ansible_collections.arista.avd.plugins.filter.range_expand import range_expand from ansible_collections.arista.avd.plugins.plugin_utils.utils import get diff --git a/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/connected_endpoints_keys.py b/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/connected_endpoints_keys.py index f3c277823ef..1102b2e2484 100644 --- a/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/connected_endpoints_keys.py +++ b/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/connected_endpoints_keys.py @@ -6,14 +6,7 @@ from functools import cached_property from typing import TYPE_CHECKING -try: - from pyavd.j2filters.convert_dicts import convert_dicts - - PYAVD_IMPORT_EXCEPTION = None -except ImportError as e: - convert_dicts = None - PYAVD_IMPORT_EXCEPTION = e - +from ansible_collections.arista.avd.plugins.filter.convert_dicts import convert_dicts from ansible_collections.arista.avd.plugins.plugin_utils.utils import get if TYPE_CHECKING: diff --git a/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/filtered_tenants.py b/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/filtered_tenants.py index 2bf00441ae0..f6f4bdd9e36 100644 --- a/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/filtered_tenants.py +++ b/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/filtered_tenants.py @@ -6,14 +6,7 @@ from functools import cached_property from typing import TYPE_CHECKING -try: - from pyavd.j2filters.convert_dicts import convert_dicts - - PYAVD_IMPORT_EXCEPTION = None -except ImportError as e: - convert_dicts = None - PYAVD_IMPORT_EXCEPTION = e - +from ansible_collections.arista.avd.plugins.filter.convert_dicts import convert_dicts from ansible_collections.arista.avd.plugins.filter.natural_sort import natural_sort from ansible_collections.arista.avd.plugins.filter.range_expand import range_expand from ansible_collections.arista.avd.plugins.plugin_utils.errors import AristaAvdError, AristaAvdMissingVariableError diff --git a/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/misc.py b/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/misc.py index 103acb92774..e8f92b000f3 100644 --- a/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/misc.py +++ b/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/misc.py @@ -7,14 +7,7 @@ from functools import cached_property from typing import TYPE_CHECKING -try: - from pyavd.j2filters.convert_dicts import convert_dicts - - PYAVD_IMPORT_EXCEPTION = None -except ImportError as e: - convert_dicts = None - PYAVD_IMPORT_EXCEPTION = e - +from ansible_collections.arista.avd.plugins.filter.convert_dicts import convert_dicts from ansible_collections.arista.avd.plugins.filter.natural_sort import natural_sort from ansible_collections.arista.avd.plugins.filter.range_expand import range_expand from ansible_collections.arista.avd.plugins.plugin_utils.errors.errors import AristaAvdError, AristaAvdMissingVariableError diff --git a/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/node_type_keys.py b/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/node_type_keys.py index bb3cb32009e..96ca5a88131 100644 --- a/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/node_type_keys.py +++ b/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/node_type_keys.py @@ -6,14 +6,7 @@ from functools import cached_property from typing import TYPE_CHECKING -try: - from pyavd.j2filters.convert_dicts import convert_dicts - - PYAVD_IMPORT_EXCEPTION = None -except ImportError as e: - convert_dicts = None - PYAVD_IMPORT_EXCEPTION = e - +from ansible_collections.arista.avd.plugins.filter.convert_dicts import convert_dicts from ansible_collections.arista.avd.plugins.plugin_utils.errors import AristaAvdMissingVariableError from ansible_collections.arista.avd.plugins.plugin_utils.utils import get diff --git a/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/switch_data.py b/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/switch_data.py index 16bf72be609..0d1be55bacb 100644 --- a/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/switch_data.py +++ b/ansible_collections/arista/avd/plugins/plugin_utils/eos_designs_shared_utils/switch_data.py @@ -6,14 +6,7 @@ from functools import cached_property from typing import TYPE_CHECKING -try: - from pyavd.j2filters.convert_dicts import convert_dicts - - PYAVD_IMPORT_EXCEPTION = None -except ImportError as e: - convert_dicts = None - PYAVD_IMPORT_EXCEPTION = e - +from ansible_collections.arista.avd.plugins.filter.convert_dicts import convert_dicts from ansible_collections.arista.avd.plugins.plugin_utils.merge import merge from ansible_collections.arista.avd.plugins.plugin_utils.utils import get diff --git a/ansible_collections/arista/avd/plugins/plugin_utils/schema/avddataconverter.py b/ansible_collections/arista/avd/plugins/plugin_utils/schema/avddataconverter.py index 2c2360659a8..de54f6cba99 100644 --- a/ansible_collections/arista/avd/plugins/plugin_utils/schema/avddataconverter.py +++ b/ansible_collections/arista/avd/plugins/plugin_utils/schema/avddataconverter.py @@ -5,14 +5,7 @@ from typing import TYPE_CHECKING, Generator -try: - from pyavd.j2filters.convert_dicts import convert_dicts - - PYAVD_IMPORT_EXCEPTION = None -except ImportError as e: - convert_dicts = None - PYAVD_IMPORT_EXCEPTION = e - +from ansible_collections.arista.avd.plugins.filter.convert_dicts import convert_dicts from ansible_collections.arista.avd.plugins.plugin_utils.errors import AvdConversionWarning, AvdDeprecationWarning from ansible_collections.arista.avd.plugins.plugin_utils.utils import get_all diff --git a/ansible_collections/arista/avd/roles/eos_designs/python_modules/base/avdstructuredconfig.py b/ansible_collections/arista/avd/roles/eos_designs/python_modules/base/avdstructuredconfig.py index 42f5c6a9fe4..4bebb6671ac 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/python_modules/base/avdstructuredconfig.py +++ b/ansible_collections/arista/avd/roles/eos_designs/python_modules/base/avdstructuredconfig.py @@ -5,14 +5,7 @@ from functools import cached_property -try: - from pyavd.j2filters.convert_dicts import convert_dicts - - PYAVD_IMPORT_EXCEPTION = None -except ImportError as e: - convert_dicts = None - PYAVD_IMPORT_EXCEPTION = e - +from ansible_collections.arista.avd.plugins.filter.convert_dicts import convert_dicts from ansible_collections.arista.avd.plugins.filter.natural_sort import natural_sort from ansible_collections.arista.avd.plugins.plugin_utils.avdfacts import AvdFacts from ansible_collections.arista.avd.plugins.plugin_utils.errors import AristaAvdMissingVariableError diff --git a/ansible_collections/arista/avd/roles/eos_designs/python_modules/connected_endpoints/utils.py b/ansible_collections/arista/avd/roles/eos_designs/python_modules/connected_endpoints/utils.py index 31957727ca3..a0d279b7d96 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/python_modules/connected_endpoints/utils.py +++ b/ansible_collections/arista/avd/roles/eos_designs/python_modules/connected_endpoints/utils.py @@ -7,14 +7,7 @@ from functools import cached_property from hashlib import sha256 -try: - from pyavd.j2filters.convert_dicts import convert_dicts - - PYAVD_IMPORT_EXCEPTION = None -except ImportError as e: - convert_dicts = None - PYAVD_IMPORT_EXCEPTION = e - +from ansible_collections.arista.avd.plugins.filter.convert_dicts import convert_dicts from ansible_collections.arista.avd.plugins.filter.generate_esi import generate_esi from ansible_collections.arista.avd.plugins.filter.generate_route_target import generate_route_target from ansible_collections.arista.avd.plugins.plugin_utils.eos_designs_shared_utils import SharedUtils diff --git a/ansible_collections/arista/avd/roles/eos_designs/python_modules/core_interfaces_and_l3_edge/utils.py b/ansible_collections/arista/avd/roles/eos_designs/python_modules/core_interfaces_and_l3_edge/utils.py index a8b9c5e60a2..9415374fa02 100644 --- a/ansible_collections/arista/avd/roles/eos_designs/python_modules/core_interfaces_and_l3_edge/utils.py +++ b/ansible_collections/arista/avd/roles/eos_designs/python_modules/core_interfaces_and_l3_edge/utils.py @@ -9,14 +9,7 @@ from ipaddress import ip_network from itertools import islice -try: - from pyavd.j2filters.convert_dicts import convert_dicts - - PYAVD_IMPORT_EXCEPTION = None -except ImportError as e: - convert_dicts = None - PYAVD_IMPORT_EXCEPTION = e - +from ansible_collections.arista.avd.plugins.filter.convert_dicts import convert_dicts from ansible_collections.arista.avd.plugins.plugin_utils.eos_designs_shared_utils import SharedUtils from ansible_collections.arista.avd.plugins.plugin_utils.errors import AristaAvdMissingVariableError from ansible_collections.arista.avd.plugins.plugin_utils.merge import merge diff --git a/python-avd/pyavd/j2filters/convert_dicts.py b/python-avd/pyavd/j2filters/convert_dicts.py index f54204e3644..acae4f8d5b4 100644 --- a/python-avd/pyavd/j2filters/convert_dicts.py +++ b/python-avd/pyavd/j2filters/convert_dicts.py @@ -1,9 +1,8 @@ # Copyright (c) 2024 Arista Networks, Inc. # Use of this source code is governed by the Apache License 2.0 # that can be found in the LICENSE file. -from __future__ import absolute_import, division, print_function +from __future__ import annotations -__metaclass__ = type import os