mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-03-26 21:33:12 +00:00
Cleanup: use super() instead of super(__class__, self) (#11016)
* Address UP008: Use super() instead of super(__class__, self). * Linting.
This commit is contained in:
@@ -54,7 +54,7 @@ class FormatError(CmdRunnerException):
|
||||
self.value = value
|
||||
self.args_formats = args_formats
|
||||
self.exc = exc
|
||||
super(FormatError, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
def __repr__(self):
|
||||
return f"FormatError({self.name!r}, {self.value!r}, {self.args_formats!r}, {self.exc!r})"
|
||||
|
||||
@@ -85,16 +85,16 @@ class _DjangoRunner(PythonRunner):
|
||||
arg_fmts = dict(arg_formats) if arg_formats else {}
|
||||
arg_fmts.update(_django_std_arg_fmts)
|
||||
|
||||
super(_DjangoRunner, self).__init__(module, ["-m", "django"], arg_formats=arg_fmts, **kwargs)
|
||||
super().__init__(module, ["-m", "django"], arg_formats=arg_fmts, **kwargs)
|
||||
|
||||
def __call__(self, output_process=None, check_mode_skip=False, check_mode_return=None, **kwargs):
|
||||
args_order = (
|
||||
("command", "no_color", "settings", "pythonpath", "traceback", "verbosity", "skip_checks") + self._prepare_args_order(self.default_args_order)
|
||||
)
|
||||
return super(_DjangoRunner, self).__call__(args_order, output_process, check_mode_skip=check_mode_skip, check_mode_return=check_mode_return, **kwargs)
|
||||
return super().__call__(args_order, output_process, check_mode_skip=check_mode_skip, check_mode_return=check_mode_return, **kwargs)
|
||||
|
||||
def bare_context(self, *args, **kwargs):
|
||||
return super(_DjangoRunner, self).__call__(*args, **kwargs)
|
||||
return super().__call__(*args, **kwargs)
|
||||
|
||||
|
||||
class DjangoModuleHelper(ModuleHelper):
|
||||
@@ -109,7 +109,7 @@ class DjangoModuleHelper(ModuleHelper):
|
||||
self.module["argument_spec"], self.arg_formats = self._build_args(self.module.get("argument_spec", {}),
|
||||
self.arg_formats,
|
||||
*(["std"] + self._django_args))
|
||||
super(DjangoModuleHelper, self).__init__(self.module)
|
||||
super().__init__(self.module)
|
||||
if self.django_admin_cmd is not None:
|
||||
self.vars.command = self.django_admin_cmd
|
||||
|
||||
|
||||
@@ -25,7 +25,7 @@ from ansible.module_utils.common.text.converters import to_text
|
||||
|
||||
class HwcModuleException(Exception):
|
||||
def __init__(self, message):
|
||||
super(HwcModuleException, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
self._message = message
|
||||
|
||||
@@ -35,7 +35,7 @@ class HwcModuleException(Exception):
|
||||
|
||||
class HwcClientException(Exception):
|
||||
def __init__(self, code, message):
|
||||
super(HwcClientException, self).__init__()
|
||||
super().__init__()
|
||||
|
||||
self._code = code
|
||||
self._message = message
|
||||
@@ -47,7 +47,7 @@ class HwcClientException(Exception):
|
||||
|
||||
class HwcClientException404(HwcClientException):
|
||||
def __init__(self, message):
|
||||
super(HwcClientException404, self).__init__(404, message)
|
||||
super().__init__(404, message)
|
||||
|
||||
def __str__(self):
|
||||
return f"[HwcClientException404] message={self._message}"
|
||||
@@ -249,7 +249,7 @@ class HwcModule(AnsibleModule):
|
||||
)
|
||||
)
|
||||
|
||||
super(HwcModule, self).__init__(*args, **kwargs)
|
||||
super().__init__(*args, **kwargs)
|
||||
|
||||
|
||||
class _DictComparison:
|
||||
|
||||
@@ -16,4 +16,4 @@ class ModuleHelperException(Exception):
|
||||
if update_output is None:
|
||||
update_output = {}
|
||||
self.update_output: dict[str, t.Any] = update_output
|
||||
super(ModuleHelperException, self).__init__(*args)
|
||||
super().__init__(*args)
|
||||
|
||||
@@ -26,7 +26,7 @@ class ModuleHelper(DeprecateAttrsMixin, ModuleHelperBase):
|
||||
facts_params: Sequence[str] = ()
|
||||
|
||||
def __init__(self, module=None):
|
||||
super(ModuleHelper, self).__init__(module)
|
||||
super().__init__(module)
|
||||
|
||||
self.vars = VarDict()
|
||||
for name, value in self.module.params.items():
|
||||
|
||||
@@ -151,7 +151,7 @@ class OneViewModuleTaskError(OneViewModuleException):
|
||||
"""
|
||||
|
||||
def __init__(self, msg, error_code=None):
|
||||
super(OneViewModuleTaskError, self).__init__(msg)
|
||||
super().__init__(msg)
|
||||
self.error_code = error_code
|
||||
|
||||
|
||||
|
||||
@@ -30,5 +30,5 @@ class PythonRunner(CmdRunner):
|
||||
|
||||
python_cmd = [self.python] + _ensure_list(command)
|
||||
|
||||
super(PythonRunner, self).__init__(module, python_cmd, arg_formats, default_args_order,
|
||||
check_rc, force_lang, path_prefix, environ_update)
|
||||
super().__init__(module, python_cmd, arg_formats, default_args_order,
|
||||
check_rc, force_lang, path_prefix, environ_update)
|
||||
|
||||
@@ -21,7 +21,7 @@ from ansible.module_utils.urls import fetch_url
|
||||
class UTMModuleConfigurationError(Exception):
|
||||
|
||||
def __init__(self, msg, **args):
|
||||
super(UTMModuleConfigurationError, self).__init__(self, msg)
|
||||
super().__init__(self, msg)
|
||||
self.msg = msg
|
||||
self.module_fail_args = args
|
||||
|
||||
@@ -49,9 +49,9 @@ class UTMModule(AnsibleModule):
|
||||
validate_certs=dict(type='bool', required=False, default=True),
|
||||
state=dict(default='present', choices=['present', 'absent'])
|
||||
)
|
||||
super(UTMModule, self).__init__(self._merge_specs(default_specs, argument_spec), bypass_checks, no_log,
|
||||
mutually_exclusive, required_together, required_one_of,
|
||||
add_file_common_args, supports_check_mode, required_if)
|
||||
super().__init__(self._merge_specs(default_specs, argument_spec), bypass_checks, no_log,
|
||||
mutually_exclusive, required_together, required_one_of,
|
||||
add_file_common_args, supports_check_mode, required_if)
|
||||
|
||||
def _merge_specs(self, default_specs, custom_specs):
|
||||
result = default_specs.copy()
|
||||
|
||||
@@ -120,11 +120,11 @@ class VarDict:
|
||||
try:
|
||||
return self.__vars__[item].value
|
||||
except KeyError:
|
||||
return getattr(super(VarDict, self), item)
|
||||
return getattr(super(), item)
|
||||
|
||||
def __setattr__(self, key, value):
|
||||
if key == '__vars__':
|
||||
super(VarDict, self).__setattr__(key, value)
|
||||
super().__setattr__(key, value)
|
||||
else:
|
||||
self.set(key, value)
|
||||
|
||||
|
||||
@@ -48,12 +48,12 @@ class WdcRedfishUtils(RedfishUtils):
|
||||
module,
|
||||
resource_id,
|
||||
data_modification):
|
||||
super(WdcRedfishUtils, self).__init__(creds=creds,
|
||||
root_uri=root_uris[0],
|
||||
timeout=timeout,
|
||||
module=module,
|
||||
resource_id=resource_id,
|
||||
data_modification=data_modification)
|
||||
super().__init__(creds=creds,
|
||||
root_uri=root_uris[0],
|
||||
timeout=timeout,
|
||||
module=module,
|
||||
resource_id=resource_id,
|
||||
data_modification=data_modification)
|
||||
# Update the root URI if we cannot perform a Redfish GET to the first one
|
||||
self._set_root_uri(root_uris)
|
||||
|
||||
@@ -72,7 +72,7 @@ class WdcRedfishUtils(RedfishUtils):
|
||||
|
||||
def _find_updateservice_resource(self):
|
||||
"""Find the update service resource as well as additional WDC-specific resources."""
|
||||
response = super(WdcRedfishUtils, self)._find_updateservice_resource()
|
||||
response = super()._find_updateservice_resource()
|
||||
if not response['ret']:
|
||||
return response
|
||||
return self._find_updateservice_additional_uris()
|
||||
|
||||
Reference in New Issue
Block a user