mirror of
https://github.com/zebrajr/ansible.git
synced 2025-12-06 00:19:48 +01:00
Deprecate ansible.module_utils.six (#85934)
* Deprecate `ansible.module_utils.six` Fixes #85920
This commit is contained in:
parent
cb2ecda514
commit
686c3658ae
2
changelogs/fragments/deprecate-six.yml
Normal file
2
changelogs/fragments/deprecate-six.yml
Normal file
|
|
@ -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:
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user