Cleanup: use super() instead of super(__class__, self) (#11016)

* Address UP008: Use super() instead of super(__class__, self).

* Linting.
This commit is contained in:
Felix Fontein
2025-10-30 20:17:26 +01:00
committed by GitHub
parent 0c5466de47
commit 74c2c804e5
204 changed files with 390 additions and 401 deletions

View File

@@ -71,14 +71,14 @@ class CallbackModule(CallbackBase):
CALLBACK_NEEDS_WHITELIST = True
def __init__(self, display=None):
super(CallbackModule, self).__init__(display)
super().__init__(display)
self._task_memprof = None
self.task_results = []
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self.cgroup_max_file = self.get_option('max_mem_file')
self.cgroup_current_file = self.get_option('cur_mem_file')

View File

@@ -31,7 +31,7 @@ class CallbackModule(CallbackBase):
CALLBACK_NEEDS_WHITELIST = True
def __init__(self, *args, **kwargs):
super(CallbackModule, self).__init__(*args, **kwargs)
super().__init__(*args, **kwargs)
self.task = None
self.play = None

View File

@@ -47,7 +47,7 @@ class CallbackModule(CallbackBase):
_previous_batch_total = 0
def __init__(self):
super(CallbackModule, self).__init__()
super().__init__()
self._playbook = ""
self._play = ""

View File

@@ -161,7 +161,7 @@ class CallbackModule(CallbackModule_default):
if HAS_OD:
self.disabled = False
self.super_ref = super(CallbackModule, self)
self.super_ref = super()
self.super_ref.__init__()
# Attributes to remove from results for more density

View File

@@ -849,7 +849,7 @@ class CallbackModule(Default):
return (spec['msg'] is not None) and (spec['msg'] != omit or omit is sentinel)
def _parent_has_callback(self):
return hasattr(super(CallbackModule, self), sys._getframe(1).f_code.co_name)
return hasattr(super(), sys._getframe(1).f_code.co_name)
def _template(self, loader, template, variables):
_templar = Templar(loader=loader, variables=variables)
@@ -1027,7 +1027,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_on_any(*args, **kwargs)
super().v2_on_any(*args, **kwargs)
def v2_runner_on_failed(self, result, ignore_errors=False):
self._diy_spec = self._get_output_specification(
@@ -1045,7 +1045,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_runner_on_failed(result, ignore_errors)
super().v2_runner_on_failed(result, ignore_errors)
def v2_runner_on_ok(self, result):
self._diy_spec = self._get_output_specification(
@@ -1063,7 +1063,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_runner_on_ok(result)
super().v2_runner_on_ok(result)
def v2_runner_on_skipped(self, result):
self._diy_spec = self._get_output_specification(
@@ -1081,7 +1081,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_runner_on_skipped(result)
super().v2_runner_on_skipped(result)
def v2_runner_on_unreachable(self, result):
self._diy_spec = self._get_output_specification(
@@ -1099,7 +1099,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_runner_on_unreachable(result)
super().v2_runner_on_unreachable(result)
# not implemented as the call to this is not implemented yet
def v2_runner_on_async_poll(self, result):
@@ -1130,7 +1130,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_runner_item_on_ok(result)
super().v2_runner_item_on_ok(result)
def v2_runner_item_on_failed(self, result):
self._diy_spec = self._get_output_specification(
@@ -1149,7 +1149,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_runner_item_on_failed(result)
super().v2_runner_item_on_failed(result)
def v2_runner_item_on_skipped(self, result):
self._diy_spec = self._get_output_specification(
@@ -1168,7 +1168,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_runner_item_on_skipped(result)
super().v2_runner_item_on_skipped(result)
def v2_runner_retry(self, result):
self._diy_spec = self._get_output_specification(
@@ -1186,7 +1186,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_runner_retry(result)
super().v2_runner_retry(result)
def v2_runner_on_start(self, host, task):
self._diy_host = host
@@ -1207,7 +1207,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_runner_on_start(host, task)
super().v2_runner_on_start(host, task)
def v2_playbook_on_start(self, playbook):
self._diy_playbook = playbook
@@ -1225,7 +1225,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_playbook_on_start(playbook)
super().v2_playbook_on_start(playbook)
def v2_playbook_on_notify(self, handler, host):
self._diy_handler = handler
@@ -1246,7 +1246,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_playbook_on_notify(handler, host)
super().v2_playbook_on_notify(handler, host)
def v2_playbook_on_no_hosts_matched(self):
self._diy_spec = self._get_output_specification(
@@ -1259,7 +1259,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_playbook_on_no_hosts_matched()
super().v2_playbook_on_no_hosts_matched()
def v2_playbook_on_no_hosts_remaining(self):
self._diy_spec = self._get_output_specification(
@@ -1272,7 +1272,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_playbook_on_no_hosts_remaining()
super().v2_playbook_on_no_hosts_remaining()
def v2_playbook_on_task_start(self, task, is_conditional):
self._diy_task = task
@@ -1291,7 +1291,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_playbook_on_task_start(task, is_conditional)
super().v2_playbook_on_task_start(task, is_conditional)
# not implemented as the call to this is not implemented yet
def v2_playbook_on_cleanup_task_start(self, task):
@@ -1314,7 +1314,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_playbook_on_handler_task_start(task)
super().v2_playbook_on_handler_task_start(task)
def v2_playbook_on_vars_prompt(self, varname, private=True, prompt=None, encrypt=None,
confirm=False, salt_size=None, salt=None, default=None,
@@ -1329,7 +1329,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_playbook_on_vars_prompt(
super().v2_playbook_on_vars_prompt(
varname, private, prompt, encrypt,
confirm, salt_size, salt, default,
unsafe
@@ -1359,7 +1359,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_playbook_on_play_start(play)
super().v2_playbook_on_play_start(play)
def v2_playbook_on_stats(self, stats):
self._diy_stats = stats
@@ -1378,7 +1378,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_playbook_on_stats(stats)
super().v2_playbook_on_stats(stats)
def v2_playbook_on_include(self, included_file):
self._diy_included_file = included_file
@@ -1398,7 +1398,7 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_playbook_on_include(included_file)
super().v2_playbook_on_include(included_file)
def v2_on_file_diff(self, result):
self._diy_spec = self._get_output_specification(
@@ -1416,4 +1416,4 @@ class CallbackModule(Default):
if self._parent_has_callback():
with self._suppress_stdout(enabled=self._using_diy(spec=self._diy_spec)):
super(CallbackModule, self).v2_on_file_diff(result)
super().v2_on_file_diff(result)

View File

@@ -297,7 +297,7 @@ class CallbackModule(CallbackBase):
CALLBACK_NEEDS_ENABLED = True
def __init__(self, display=None):
super(CallbackModule, self).__init__(display=display)
super().__init__(display=display)
self.hide_task_arguments = None
self.apm_service_name = None
self.ansible_playbook = None
@@ -315,9 +315,7 @@ class CallbackModule(CallbackBase):
self.elastic = ElasticSource(display=self._display)
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys,
var_options=var_options,
direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self.hide_task_arguments = self.get_option('hide_task_arguments')

View File

@@ -62,7 +62,7 @@ class CallbackModule(CallbackBase):
def __init__(self, display=None):
super(CallbackModule, self).__init__(display=display)
super().__init__(display=display)
if not HAS_XMPP:
self._display.warning("The required python xmpp library (xmpppy) is not installed. "

View File

@@ -62,10 +62,10 @@ class CallbackModule(CallbackBase):
def __init__(self):
super(CallbackModule, self).__init__()
super().__init__()
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self.log_folder = self.get_option("log_folder")

View File

@@ -157,7 +157,7 @@ class CallbackModule(CallbackBase):
CALLBACK_NEEDS_WHITELIST = True
def __init__(self, display=None):
super(CallbackModule, self).__init__(display=display)
super().__init__(display=display)
self.start_datetimes = {} # Collect task start times
self.workspace_id = None
self.shared_key = None
@@ -170,7 +170,7 @@ class CallbackModule(CallbackBase):
).total_seconds()
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self.workspace_id = self.get_option('workspace_id')
self.shared_key = self.get_option('shared_key')

View File

@@ -114,7 +114,7 @@ class CallbackModule(CallbackBase):
CALLBACK_NEEDS_WHITELIST = True
def __init__(self, display=None):
super(CallbackModule, self).__init__(display=display)
super().__init__(display=display)
self.disabled = True
self.playbook_name = None
@@ -125,7 +125,7 @@ class CallbackModule(CallbackBase):
self.conf_tags = None
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self.conf_key = self.get_option('conf_key')
self.plugin_ignore_errors = self.get_option('plugin_ignore_errors')

View File

@@ -218,7 +218,7 @@ class CallbackModule(CallbackBase):
def __init__(self):
# TODO: allow for alternate posting methods (REST/UDP/agent/etc)
super(CallbackModule, self).__init__()
super().__init__()
# verify dependencies
if not HAS_SSL:
@@ -235,7 +235,7 @@ class CallbackModule(CallbackBase):
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
# get options
try:

View File

@@ -122,7 +122,7 @@ class CallbackModule(CallbackBase):
CALLBACK_NEEDS_WHITELIST = True
def __init__(self):
super(CallbackModule, self).__init__()
super().__init__()
if not HAS_LOGSTASH:
self.disabled = True
@@ -163,7 +163,7 @@ class CallbackModule(CallbackBase):
self.base_data['inventory'] = context.CLIARGS.get('inventory')
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self.ls_server = self.get_option('server')
self.ls_port = int(self.get_option('port'))

View File

@@ -99,7 +99,7 @@ class CallbackModule(CallbackBase):
CALLBACK_NEEDS_WHITELIST = True
def __init__(self, display=None):
super(CallbackModule, self).__init__(display=display)
super().__init__(display=display)
self.sender = None
self.to = 'root'
self.smtphost = os.getenv('SMTPHOST', 'localhost')
@@ -109,7 +109,7 @@ class CallbackModule(CallbackBase):
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self.sender = self.get_option('sender')
self.to = self.get_option('to')

View File

@@ -89,14 +89,14 @@ class CallbackModule(CallbackBase):
UNKNOWN = 3
def __init__(self):
super(CallbackModule, self).__init__()
super().__init__()
self.printed_playbook = False
self.playbook_name = None
self.play = None
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self.url = self.get_option('url')
if not self.url.endswith('/'):

View File

@@ -478,7 +478,7 @@ class CallbackModule(CallbackBase):
CALLBACK_NEEDS_ENABLED = True
def __init__(self, display=None):
super(CallbackModule, self).__init__(display=display)
super().__init__(display=display)
self.hide_task_arguments = None
self.disable_attributes_in_logs = None
self.disable_logs = None
@@ -502,9 +502,7 @@ class CallbackModule(CallbackBase):
self.opentelemetry = OpenTelemetrySource(display=self._display)
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys,
var_options=var_options,
direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
environment_variable = self.get_option('enable_from_environment')
if environment_variable is not None and os.environ.get(environment_variable, 'false').lower() != 'true':

View File

@@ -44,7 +44,7 @@ class CallbackModule(CallbackBase):
CALLBACK_NEEDS_ENABLED = True
def __init__(self):
super(CallbackModule, self).__init__()
super().__init__()
self._printed_message = False
def _print_task(self, task):

View File

@@ -37,7 +37,7 @@ class CallbackModule(CallbackBase):
def __init__(self):
super(CallbackModule, self).__init__()
super().__init__()
self.FAILED_VOICE = None
self.REGULAR_VOICE = None

View File

@@ -83,14 +83,14 @@ class CallbackModule(CallbackBase):
def __init__(self, display=None):
"""selective.py callback plugin."""
super(CallbackModule, self).__init__(display)
super().__init__(display)
self.last_skipped = False
self.last_task_name = None
self.printed_last_task = False
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
global DONT_COLORIZE
DONT_COLORIZE = self.get_option('nocolor')

View File

@@ -86,7 +86,7 @@ class CallbackModule(CallbackBase):
def __init__(self, display=None):
super(CallbackModule, self).__init__(display=display)
super().__init__(display=display)
if not HAS_PRETTYTABLE:
self.disabled = True
@@ -103,7 +103,7 @@ class CallbackModule(CallbackBase):
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self.webhook_url = self.get_option('webhook_url')
self.channel = self.get_option('channel')

View File

@@ -168,7 +168,7 @@ class CallbackModule(CallbackBase):
CALLBACK_NEEDS_WHITELIST = True
def __init__(self, display=None):
super(CallbackModule, self).__init__(display=display)
super().__init__(display=display)
self.start_datetimes = {} # Collect task start times
self.url = None
self.authtoken = None
@@ -184,9 +184,7 @@ class CallbackModule(CallbackBase):
).total_seconds()
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys,
var_options=var_options,
direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self.url = self.get_option('url')

View File

@@ -113,7 +113,7 @@ class CallbackModule(CallbackBase):
CALLBACK_NEEDS_WHITELIST = True
def __init__(self, display=None):
super(CallbackModule, self).__init__(display=display)
super().__init__(display=display)
self.start_datetimes = {} # Collect task start times
self.url = None
self.sumologic = SumologicHTTPCollectorSource()
@@ -125,7 +125,7 @@ class CallbackModule(CallbackBase):
).total_seconds()
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
self.url = self.get_option('url')

View File

@@ -74,11 +74,11 @@ class CallbackModule(CallbackBase):
def __init__(self):
super(CallbackModule, self).__init__()
super().__init__()
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
syslog_host = self.get_option("server")
syslog_port = int(self.get_option("port"))

View File

@@ -61,7 +61,7 @@ class CallbackModule(Default):
pass
def set_options(self, *args, **kwargs):
result = super(CallbackModule, self).set_options(*args, **kwargs)
result = super().set_options(*args, **kwargs)
self.number_of_columns = self.get_option("number_of_columns")
if self.number_of_columns is not None:
self._display.columns = self.number_of_columns

View File

@@ -104,13 +104,13 @@ class CallbackModule(Default):
CALLBACK_NAME = "community.general.timestamp"
def __init__(self):
super(CallbackModule, self).__init__()
super().__init__()
# Replace the banner method of the display object with the custom one
self._display.banner = types.MethodType(banner, self._display)
def set_options(self, task_keys=None, var_options=None, direct=None):
super(CallbackModule, self).set_options(task_keys=task_keys, var_options=var_options, direct=direct)
super().set_options(task_keys=task_keys, var_options=var_options, direct=direct)
# Store zoneinfo for specified timezone if available
tzinfo = None