1
0
Fork 0
mirror of https://github.com/ansible-collections/community.general.git synced 2026-04-04 19:26:58 +00:00

[stable-10] Avoid six in plugin code (#10873) (#10877)

Avoid six in plugin code (#10873)

Avoid six in plugin code.

(cherry picked from commit 6cd4665412)
This commit is contained in:
Felix Fontein 2025-10-05 07:42:27 +02:00 committed by GitHub
parent 4ab8f79eae
commit 171a028ef8
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
37 changed files with 80 additions and 130 deletions

View file

@ -27,7 +27,6 @@ try:
except ImportError:
pass
from ansible.module_utils.six import binary_type, text_type
from collections.abc import MutableMapping, MutableSequence
from ansible.plugins.callback.default import CallbackModule as CallbackModule_default
from ansible.utils.color import colorize, hostcolor
@ -236,7 +235,7 @@ class CallbackModule(CallbackModule_default):
# Remove empty attributes (list, dict, str)
for attr in result.copy():
if isinstance(result[attr], (MutableSequence, MutableMapping, binary_type, text_type)):
if isinstance(result[attr], (MutableSequence, MutableMapping, bytes, str)):
if not result[attr]:
del result[attr]

View file

@ -87,7 +87,6 @@ from contextlib import closing
from os.path import basename
from ansible.errors import AnsibleError, AnsibleRuntimeError
from ansible.module_utils.six import raise_from
from ansible.plugins.callback import CallbackBase
try:
@ -312,9 +311,7 @@ class CallbackModule(CallbackBase):
self.disabled = False
if ELASTIC_LIBRARY_IMPORT_ERROR:
raise_from(
AnsibleError('The `elastic-apm` must be installed to use this plugin'),
ELASTIC_LIBRARY_IMPORT_ERROR)
raise AnsibleError('The `elastic-apm` must be installed to use this plugin') from ELASTIC_LIBRARY_IMPORT_ERROR
self.tasks_data = OrderedDict()

View file

@ -66,7 +66,8 @@ options:
type: string
"""
from ansible.module_utils.six.moves.urllib.parse import urlencode
from urllib.parse import urlencode
from ansible.module_utils.common.text.converters import to_bytes
from ansible.module_utils.urls import open_url
from ansible.plugins.callback import CallbackBase

View file

@ -137,14 +137,12 @@ import json
import os
import socket
import uuid
from time import time_ns
from collections import OrderedDict
from os.path import basename
from time import time_ns
from urllib.parse import urlparse
from ansible.errors import AnsibleError
from ansible.module_utils.six import raise_from
from ansible.module_utils.six.moves.urllib.parse import urlparse
from ansible.plugins.callback import CallbackBase
try:
@ -499,9 +497,9 @@ class CallbackModule(CallbackBase):
self.otel_exporter_otlp_traces_protocol = None
if OTEL_LIBRARY_IMPORT_ERROR:
raise_from(
AnsibleError('The `opentelemetry-api`, `opentelemetry-exporter-otlp` or `opentelemetry-sdk` must be installed to use this plugin'),
OTEL_LIBRARY_IMPORT_ERROR)
raise AnsibleError(
'The `opentelemetry-api`, `opentelemetry-exporter-otlp` or `opentelemetry-sdk` must be installed to use this plugin'
) from OTEL_LIBRARY_IMPORT_ERROR
self.tasks_data = OrderedDict()