From b1d9507cd2986cc2f3e9d918a56477ef2eba3d1f Mon Sep 17 00:00:00 2001 From: Felix Fontein Date: Sat, 4 Feb 2023 17:05:08 +0100 Subject: [PATCH] Fix pylint errors (#5933) * Fix pylint errors. * Also adjust to https://github.com/ansible/ansible/pull/79909. --- changelogs/fragments/5933-linting.yml | 2 ++ plugins/modules/gconftool2.py | 4 ++-- plugins/modules/pritunl_org.py | 2 +- plugins/modules/pritunl_org_info.py | 2 +- plugins/modules/pritunl_user.py | 2 +- plugins/modules/pritunl_user_info.py | 2 +- plugins/modules/terraform.py | 2 +- plugins/modules/timezone.py | 1 + plugins/modules/xfconf.py | 4 ++-- 9 files changed, 12 insertions(+), 9 deletions(-) create mode 100644 changelogs/fragments/5933-linting.yml diff --git a/changelogs/fragments/5933-linting.yml b/changelogs/fragments/5933-linting.yml new file mode 100644 index 0000000000..d0c46542bf --- /dev/null +++ b/changelogs/fragments/5933-linting.yml @@ -0,0 +1,2 @@ +bugfixes: + - "terraform and timezone - slight refactoring to avoid linter reporting potentially undefined variables (https://github.com/ansible-collections/community.general/pull/5933)." diff --git a/plugins/modules/gconftool2.py b/plugins/modules/gconftool2.py index a3ac8bb8f1..788aed3423 100644 --- a/plugins/modules/gconftool2.py +++ b/plugins/modules/gconftool2.py @@ -88,8 +88,8 @@ from ansible_collections.community.general.plugins.module_utils.gconftool2 impor class GConftool(StateModuleHelper): - change_params = 'value', - diff_params = 'value', + change_params = ('value', ) + diff_params = ('value', ) output_params = ('key', 'value_type') facts_params = ('key', 'value_type') facts_name = 'gconftool2' diff --git a/plugins/modules/pritunl_org.py b/plugins/modules/pritunl_org.py index 75c3564f24..4a6a8a3444 100644 --- a/plugins/modules/pritunl_org.py +++ b/plugins/modules/pritunl_org.py @@ -181,7 +181,7 @@ def main(): required=False, choices=["present", "absent"], default="present" ), ) - ), + ) module = AnsibleModule(argument_spec=argument_spec) diff --git a/plugins/modules/pritunl_org_info.py b/plugins/modules/pritunl_org_info.py index 7f3974e0e5..979e29b5a0 100644 --- a/plugins/modules/pritunl_org_info.py +++ b/plugins/modules/pritunl_org_info.py @@ -118,7 +118,7 @@ def main(): dict( organization=dict(required=False, type="str", default=None, aliases=["org"]) ) - ), + ) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) diff --git a/plugins/modules/pritunl_user.py b/plugins/modules/pritunl_user.py index 817d6fb3f6..f3feb94eed 100644 --- a/plugins/modules/pritunl_user.py +++ b/plugins/modules/pritunl_user.py @@ -336,7 +336,7 @@ def main(): user_gravatar=dict(required=False, type="bool", default=None), user_mac_addresses=dict(required=False, type="list", elements="str", default=None), ) - ), + ) module = AnsibleModule(argument_spec=argument_spec) diff --git a/plugins/modules/pritunl_user_info.py b/plugins/modules/pritunl_user_info.py index d4c68ca6e0..7b0399061f 100644 --- a/plugins/modules/pritunl_user_info.py +++ b/plugins/modules/pritunl_user_info.py @@ -160,7 +160,7 @@ def main(): default="client", ), ) - ), + ) module = AnsibleModule(argument_spec=argument_spec, supports_check_mode=True) diff --git a/plugins/modules/terraform.py b/plugins/modules/terraform.py index b6b09b0eb2..9d1cc2ed02 100644 --- a/plugins/modules/terraform.py +++ b/plugins/modules/terraform.py @@ -628,9 +628,9 @@ def main(): outputs_command = [command[0], 'output', '-no-color', '-json'] + _state_args(state_file) rc, outputs_text, outputs_err = module.run_command(outputs_command, cwd=project_path) + outputs = {} if rc == 1: module.warn("Could not get Terraform outputs. This usually means none have been defined.\nstdout: {0}\nstderr: {1}".format(outputs_text, outputs_err)) - outputs = {} elif rc != 0: module.fail_json( msg="Failure when getting Terraform outputs. " diff --git a/plugins/modules/timezone.py b/plugins/modules/timezone.py index 9e89462089..20404d3a79 100644 --- a/plugins/modules/timezone.py +++ b/plugins/modules/timezone.py @@ -356,6 +356,7 @@ class NosystemdTimezone(Timezone): def __init__(self, module): super(NosystemdTimezone, self).__init__(module) # Validate given timezone + planned_tz = '' if 'name' in self.value: tzfile = self._verify_timezone() planned_tz = self.value['name']['planned'] diff --git a/plugins/modules/xfconf.py b/plugins/modules/xfconf.py index ec00763ee1..0fff6f0d14 100644 --- a/plugins/modules/xfconf.py +++ b/plugins/modules/xfconf.py @@ -169,8 +169,8 @@ from ansible_collections.community.general.plugins.module_utils.xfconf import xf class XFConfProperty(StateModuleHelper): - change_params = 'value', - diff_params = 'value', + change_params = ('value', ) + diff_params = ('value', ) output_params = ('property', 'channel', 'value') module = dict( argument_spec=dict(