mirror of
https://github.com/ansible-collections/community.general.git
synced 2026-06-04 23:37:12 +00:00
Fix typing (#12078)
Fix typing. ansible-core 2.21.0 is out and has more type definitions.
This commit is contained in:
parent
cf9b91be47
commit
e6ca0df592
7 changed files with 23 additions and 9 deletions
|
|
@ -149,6 +149,10 @@ class ActionModule(ActionBase):
|
|||
# 3. Confirm the restored state by removing the backup on the remote.
|
||||
# Retrieve the results of the asynchronous task to return them.
|
||||
if "_back" in module_args:
|
||||
# If _back is there, the following two are defined:
|
||||
assert starter_cmd is not None
|
||||
assert confirm_cmd is not None
|
||||
|
||||
async_status_args["jid"] = result.get("ansible_job_id", None)
|
||||
if async_status_args["jid"] is None:
|
||||
raise AnsibleActionFail("Unable to get 'ansible_job_id'.")
|
||||
|
|
@ -170,7 +174,7 @@ class ActionModule(ActionBase):
|
|||
except AttributeError:
|
||||
pass
|
||||
|
||||
for dummy in range(max_timeout):
|
||||
for dummy2 in range(max_timeout):
|
||||
time.sleep(1)
|
||||
remaining_time -= 1
|
||||
# - AnsibleConnectionFailure covers rejected requests (i.e.
|
||||
|
|
@ -178,7 +182,7 @@ class ActionModule(ActionBase):
|
|||
# - ansible_timeout is able to cover dropped requests (due
|
||||
# to a rule or policy DROP) if not lower than async_val.
|
||||
try:
|
||||
dummy = self._low_level_execute_command(confirm_cmd, sudoable=self.DEFAULT_SUDOABLE)
|
||||
dummy3 = self._low_level_execute_command(confirm_cmd, sudoable=self.DEFAULT_SUDOABLE)
|
||||
break
|
||||
except AnsibleConnectionFailure:
|
||||
continue
|
||||
|
|
@ -196,7 +200,7 @@ class ActionModule(ActionBase):
|
|||
del result["invocation"]["module_args"][key]
|
||||
|
||||
async_status_args["mode"] = "cleanup"
|
||||
dummy = self._async_result(async_status_args, task_vars, 0)
|
||||
dummy4 = self._async_result(async_status_args, task_vars, 0)
|
||||
|
||||
if not wrap_async:
|
||||
# remove a temporary path we created
|
||||
|
|
|
|||
|
|
@ -91,10 +91,12 @@ class ActionModule(ActionBase):
|
|||
raise AnsibleError(
|
||||
f"Failed to determine system distribution. {to_native(module_output['module_stdout'])}, {to_native(module_output['module_stderr'])}"
|
||||
)
|
||||
# For some reason, ansible-core insists of using "object" for "arbitrary JSON", which makes it very awkward to use the result...
|
||||
ansible_facts: dict[str, t.Any] = module_output["ansible_facts"] # type: ignore
|
||||
distribution: Distribution = {
|
||||
"name": module_output["ansible_facts"]["ansible_distribution"].lower(),
|
||||
"version": to_text(module_output["ansible_facts"]["ansible_distribution_version"].split(".")[0]),
|
||||
"family": to_text(module_output["ansible_facts"]["ansible_os_family"].lower()),
|
||||
"name": ansible_facts["ansible_distribution"].lower(),
|
||||
"version": to_text(ansible_facts["ansible_distribution_version"].split(".")[0]),
|
||||
"family": to_text(ansible_facts["ansible_os_family"].lower()),
|
||||
}
|
||||
display.debug(f"{self._task.action}: distribution: {distribution}")
|
||||
return distribution
|
||||
|
|
@ -112,7 +114,8 @@ class ActionModule(ActionBase):
|
|||
module_name="ansible.legacy.find",
|
||||
module_args={"paths": find_search_paths, "patterns": [command], "file_type": "any"},
|
||||
)
|
||||
return [x["path"] for x in find_result["files"]]
|
||||
files: list[dict[str, t.Any]] = find_result["files"] # type: ignore
|
||||
return [x["path"] for x in files]
|
||||
|
||||
shutdown_bin = self._get_value_from_facts(self.SHUTDOWN_COMMANDS, distribution, self.DEFAULT_SHUTDOWN_COMMAND)
|
||||
default_search_paths = ["/sbin", "/usr/sbin", "/usr/local/sbin"]
|
||||
|
|
@ -159,7 +162,7 @@ class ActionModule(ActionBase):
|
|||
|
||||
def perform_shutdown(self, task_vars, distribution) -> dict[str, t.Any]:
|
||||
result: dict[str, t.Any] = {}
|
||||
shutdown_result = {}
|
||||
shutdown_result: dict[str, t.Any] = {}
|
||||
shutdown_command_exec = self.get_shutdown_command(task_vars, distribution)
|
||||
|
||||
self.cleanup(force=True)
|
||||
|
|
@ -169,7 +172,9 @@ class ActionModule(ActionBase):
|
|||
if self._play_context.check_mode:
|
||||
shutdown_result["rc"] = 0
|
||||
else:
|
||||
shutdown_result = self._low_level_execute_command(shutdown_command_exec, sudoable=self.DEFAULT_SUDOABLE)
|
||||
shutdown_result.update(
|
||||
self._low_level_execute_command(shutdown_command_exec, sudoable=self.DEFAULT_SUDOABLE)
|
||||
)
|
||||
except AnsibleConnectionFailure as e:
|
||||
# If the connection is closed too quickly due to the system being shutdown, carry on
|
||||
display.debug(f"{self._task.action}: AnsibleConnectionFailure caught and handled: {e}")
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
plugins/action/iptables_state.py no-assert
|
||||
plugins/module_utils/_crypt.py import-3.11 # Uses deprecated stdlib library 'crypt'
|
||||
plugins/module_utils/_crypt.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
||||
plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
plugins/action/iptables_state.py no-assert
|
||||
plugins/module_utils/_crypt.py import-3.11 # Uses deprecated stdlib library 'crypt'
|
||||
plugins/module_utils/_crypt.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
||||
plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
plugins/action/iptables_state.py no-assert
|
||||
plugins/module_utils/_crypt.py import-3.11 # Uses deprecated stdlib library 'crypt'
|
||||
plugins/module_utils/_crypt.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
||||
plugins/modules/consul_session.py validate-modules:parameter-state-invalid-choice
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
plugins/action/iptables_state.py no-assert
|
||||
plugins/module_utils/_crypt.py import-3.11 # Uses deprecated stdlib library 'crypt'
|
||||
plugins/module_utils/_crypt.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
||||
plugins/module_utils/_lxc.py pylint:ansible-bad-function # needs to use Popen() to stream logs
|
||||
|
|
|
|||
|
|
@ -1,3 +1,4 @@
|
|||
plugins/action/iptables_state.py no-assert
|
||||
plugins/module_utils/_crypt.py import-3.11 # Uses deprecated stdlib library 'crypt'
|
||||
plugins/module_utils/_crypt.py import-3.12 # Uses deprecated stdlib library 'crypt'
|
||||
plugins/module_utils/_lxc.py pylint:ansible-bad-function # needs to use Popen() to stream logs
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue