mirror of
https://github.com/ansible/ansible.git
synced 2026-08-03 00:22:10 +02:00
Deprecate ansible.module_utils.six (#85934)
* Deprecate `ansible.module_utils.six`
Fixes #85920
(cherry picked from commit 686c3658ae)
This commit is contained in:
@@ -0,0 +1,2 @@
|
||||
deprecated_features:
|
||||
- Deprecate the ``ansible.module_utils.six`` module. Use the Python standard library equivalent instead.
|
||||
@@ -33,6 +33,14 @@ import operator
|
||||
import sys
|
||||
import types
|
||||
|
||||
from ansible.module_utils.common import warnings as _warnings
|
||||
|
||||
_warnings.deprecate(
|
||||
msg="The `ansible.module_utils.six` module is deprecated.",
|
||||
help_text="Use the Python standard library equivalent instead.",
|
||||
version="2.24",
|
||||
)
|
||||
|
||||
# The following makes it easier for us to script updates of the bundled code. It is not part of
|
||||
# upstream six
|
||||
_BUNDLED_METADATA = {"pypi_name": "six", "version": "1.17.0"}
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
from __future__ import annotations
|
||||
|
||||
import functools
|
||||
import os
|
||||
import typing as t
|
||||
|
||||
@@ -108,10 +109,6 @@ class AnsibleUnwantedChecker(BaseChecker):
|
||||
'Iterator',
|
||||
)
|
||||
),
|
||||
|
||||
'ansible.module_utils.six': UnwantedEntry(
|
||||
'the Python standard library equivalent'
|
||||
),
|
||||
}
|
||||
|
||||
unwanted_functions = {
|
||||
@@ -136,6 +133,19 @@ class AnsibleUnwantedChecker(BaseChecker):
|
||||
modules_only=True),
|
||||
}
|
||||
|
||||
def __init__(self, *args, **kwargs) -> None:
|
||||
super().__init__(*args, **kwargs)
|
||||
# ansible.module_utils.six is deprecated and collections can still use it until it is removed
|
||||
if self.is_ansible_core:
|
||||
self.unwanted_imports['ansible.module_utils.six'] = UnwantedEntry(
|
||||
'the Python standard library equivalent'
|
||||
)
|
||||
|
||||
@functools.cached_property
|
||||
def is_ansible_core(self) -> bool:
|
||||
"""True if ansible-core is being tested."""
|
||||
return not self.linter.config.collection_name
|
||||
|
||||
def visit_import(self, node): # type: (astroid.node_classes.Import) -> None
|
||||
"""Visit an import node."""
|
||||
for name in node.names:
|
||||
|
||||
Reference in New Issue
Block a user