From ca32d9f925e5133ed06da22b7402f33f16424537 Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Wed, 7 Aug 2024 16:03:43 +0200 Subject: [PATCH] [stable-8] Fix pylint and pep8 issues exposed by latest ansible-core's ansible-test sanity checks (#8723) Fix pylint and pep8 issues exposed by latest ansible-core's ansible-test sanity checks (#8720) * Remove bad whitespace. * 'Fixing' various used-before-assignment issues that pylint flagged. (cherry picked from commit 9a16eaf9ba657b7f944c085ed66c69b36752d3b4) --- plugins/action/iptables_state.py | 4 ++++ plugins/callback/opentelemetry.py | 1 + plugins/module_utils/ilo_redfish_utils.py | 1 + plugins/modules/aix_inittab.py | 1 + plugins/modules/cronvar.py | 1 + plugins/modules/iptables_state.py | 1 + plugins/modules/memset_zone_record.py | 1 + plugins/modules/proxmox_disk.py | 1 + plugins/modules/snmp_facts.py | 2 ++ tests/unit/plugins/inventory/test_xen_orchestra.py | 2 +- 10 files changed, 14 insertions(+), 1 deletion(-) diff --git a/plugins/action/iptables_state.py b/plugins/action/iptables_state.py index 4a27ef8a01..5ea55af58c 100644 --- a/plugins/action/iptables_state.py +++ b/plugins/action/iptables_state.py @@ -88,6 +88,10 @@ class ActionModule(ActionBase): max_timeout = self._connection._play_context.timeout module_args = self._task.args + async_status_args = {} + starter_cmd = None + confirm_cmd = None + if module_args.get('state', None) == 'restored': if not wrap_async: if not check_mode: diff --git a/plugins/callback/opentelemetry.py b/plugins/callback/opentelemetry.py index 11c15e1da9..b62cf36f84 100644 --- a/plugins/callback/opentelemetry.py +++ b/plugins/callback/opentelemetry.py @@ -304,6 +304,7 @@ class OpenTelemetrySource(object): status = Status(status_code=StatusCode.OK) if host_data.status != 'included': # Support loops + enriched_error_message = None if 'results' in host_data.result._result: if host_data.status == 'failed': message = self.get_error_message_from_results(host_data.result._result['results'], task_data.action) diff --git a/plugins/module_utils/ilo_redfish_utils.py b/plugins/module_utils/ilo_redfish_utils.py index 9cb6e527a3..808583ae63 100644 --- a/plugins/module_utils/ilo_redfish_utils.py +++ b/plugins/module_utils/ilo_redfish_utils.py @@ -29,6 +29,7 @@ class iLORedfishUtils(RedfishUtils): result['ret'] = True data = response['data'] + current_session = None if 'Oem' in data: if data["Oem"]["Hpe"]["Links"]["MySession"]["@odata.id"]: current_session = data["Oem"]["Hpe"]["Links"]["MySession"]["@odata.id"] diff --git a/plugins/modules/aix_inittab.py b/plugins/modules/aix_inittab.py index d4c9aa0b56..79336bab8d 100644 --- a/plugins/modules/aix_inittab.py +++ b/plugins/modules/aix_inittab.py @@ -192,6 +192,7 @@ def main(): rmitab = module.get_bin_path('rmitab') chitab = module.get_bin_path('chitab') rc = 0 + err = None # check if the new entry exists current_entry = check_current_entry(module) diff --git a/plugins/modules/cronvar.py b/plugins/modules/cronvar.py index fdcbc7d24b..66fa175498 100644 --- a/plugins/modules/cronvar.py +++ b/plugins/modules/cronvar.py @@ -183,6 +183,7 @@ class CronVar(object): fileh = open(backup_file, 'w') elif self.cron_file: fileh = open(self.cron_file, 'w') + path = None else: filed, path = tempfile.mkstemp(prefix='crontab') fileh = os.fdopen(filed, 'w') diff --git a/plugins/modules/iptables_state.py b/plugins/modules/iptables_state.py index b0cc3bd3f6..c97b5694c9 100644 --- a/plugins/modules/iptables_state.py +++ b/plugins/modules/iptables_state.py @@ -459,6 +459,7 @@ def main(): if not os.access(b_path, os.R_OK): module.fail_json(msg="Source %s not readable" % path) state_to_restore = read_state(b_path) + cmd = None else: cmd = ' '.join(SAVECOMMAND) diff --git a/plugins/modules/memset_zone_record.py b/plugins/modules/memset_zone_record.py index 8406d93d21..80838a26a3 100644 --- a/plugins/modules/memset_zone_record.py +++ b/plugins/modules/memset_zone_record.py @@ -181,6 +181,7 @@ def api_validation(args=None): https://www.memset.com/apidocs/methods_dns.html#dns.zone_record_create) ''' failed_validation = False + error = None # priority can only be integer 0 > 999 if not 0 <= args['priority'] <= 999: diff --git a/plugins/modules/proxmox_disk.py b/plugins/modules/proxmox_disk.py index 69a7300dfd..35868b2ad6 100644 --- a/plugins/modules/proxmox_disk.py +++ b/plugins/modules/proxmox_disk.py @@ -541,6 +541,7 @@ class ProxmoxDiskAnsible(ProxmoxAnsible): # NOOP return False, "Disk %s not found in VM %s and creation was disabled in parameters." % (disk, vmid) + timeout_str = "Reached timeout. Last line in task before timeout: %s" if (create == 'regular' and disk not in vm_config) or (create == 'forced'): # CREATE playbook_config = self.get_create_attributes() diff --git a/plugins/modules/snmp_facts.py b/plugins/modules/snmp_facts.py index aecc08f325..39c75bcd93 100644 --- a/plugins/modules/snmp_facts.py +++ b/plugins/modules/snmp_facts.py @@ -307,6 +307,8 @@ def main(): if m_args['community'] is None: module.fail_json(msg='Community not set when using snmp version 2') + integrity_proto = None + privacy_proto = None if m_args['version'] == "v3": if m_args['username'] is None: module.fail_json(msg='Username not set when using snmp version 3') diff --git a/tests/unit/plugins/inventory/test_xen_orchestra.py b/tests/unit/plugins/inventory/test_xen_orchestra.py index bae038e807..d626fb988b 100644 --- a/tests/unit/plugins/inventory/test_xen_orchestra.py +++ b/tests/unit/plugins/inventory/test_xen_orchestra.py @@ -146,7 +146,7 @@ def serialize_groups(groups): return list(map(str, groups)) -@ pytest.fixture(scope="module") +@pytest.fixture(scope="module") def inventory(): r = InventoryModule() r.inventory = InventoryData()