Skip to content

Commit

Permalink
Fix pylint and pep8 issues exposed by latest ansible-core's ansible-t…
Browse files Browse the repository at this point in the history
…est sanity checks (ansible-collections#8720)

* Remove bad whitespace.

* 'Fixing' various used-before-assignment issues that pylint flagged.
  • Loading branch information
felixfontein authored Aug 7, 2024
1 parent 5b2711b commit 9a16eaf
Show file tree
Hide file tree
Showing 11 changed files with 16 additions and 1 deletion.
4 changes: 4 additions & 0 deletions plugins/action/iptables_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,10 @@ def run(self, tmp=None, task_vars=None):
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:
Expand Down
1 change: 1 addition & 0 deletions plugins/callback/opentelemetry.py
Original file line number Diff line number Diff line change
Expand Up @@ -356,6 +356,7 @@ def update_span_data(self, task_data, host_data, span, disable_logs, disable_att
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)
Expand Down
1 change: 1 addition & 0 deletions plugins/module_utils/ilo_redfish_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ def get_ilo_sessions(self):
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"]
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/aix_inittab.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/cronvar.py
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,7 @@ def write(self, backup_file=None):
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')
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/iptables_state.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)

Expand Down
1 change: 1 addition & 0 deletions plugins/modules/memset_zone_record.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/proxmox.py
Original file line number Diff line number Diff line change
Expand Up @@ -740,6 +740,8 @@ def build_volume(
# If not, we have proxmox create one using the special syntax
except Exception:
vol_string = "{storage}:{size}".format(storage=storage, size=size)
else:
raise AssertionError('Internal error')

# 1.3 If we have a host_path, we don't have storage, a volume, or a size
vol_string = ",".join(
Expand Down
1 change: 1 addition & 0 deletions plugins/modules/proxmox_disk.py
Original file line number Diff line number Diff line change
Expand Up @@ -544,6 +544,7 @@ def create_disk(self, disk, vmid, vm, vm_config):
# 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()
Expand Down
2 changes: 2 additions & 0 deletions plugins/modules/snmp_facts.py
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion tests/unit/plugins/inventory/test_xen_orchestra.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 9a16eaf

Please sign in to comment.