From 70503411ee7d02a262284dc3f8691d725ea4dba0 Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Sat, 15 Jul 2023 22:54:28 +1200 Subject: [PATCH] remove noqa exceptions (#6928) * remove noqa exceptions * add changelog frag * review from PR --- changelogs/fragments/6928-noqa-comments.yml | 6 ++++++ plugins/modules/gitlab_project_variable.py | 11 ++--------- plugins/modules/pubnub_blocks.py | 2 +- plugins/modules/scaleway_security_group_rule.py | 17 +---------------- plugins/modules/xenserver_guest_info.py | 6 ------ plugins/modules/xenserver_guest_powerstate.py | 6 ------ 6 files changed, 10 insertions(+), 38 deletions(-) create mode 100644 changelogs/fragments/6928-noqa-comments.yml diff --git a/changelogs/fragments/6928-noqa-comments.yml b/changelogs/fragments/6928-noqa-comments.yml new file mode 100644 index 0000000000..7bef6f3994 --- /dev/null +++ b/changelogs/fragments/6928-noqa-comments.yml @@ -0,0 +1,6 @@ +minor_changes: + - gitlab_project_variable - minor refactor removing unnecessary code statements (https://github.com/ansible-collections/community.general/pull/6928). + - pubnub_blocks - minor refactor removing unnecessary code statements (https://github.com/ansible-collections/community.general/pull/6928). + - scaleway_security_group_rule - minor refactor removing unnecessary code statements (https://github.com/ansible-collections/community.general/pull/6928). + - xenserver_guest_info - minor refactor removing unnecessary code statements (https://github.com/ansible-collections/community.general/pull/6928). + - xenserver_guest_powerstate - minor refactor removing unnecessary code statements (https://github.com/ansible-collections/community.general/pull/6928). diff --git a/plugins/modules/gitlab_project_variable.py b/plugins/modules/gitlab_project_variable.py index 6423754e1d..459ecf0850 100644 --- a/plugins/modules/gitlab_project_variable.py +++ b/plugins/modules/gitlab_project_variable.py @@ -181,20 +181,13 @@ project_variable: sample: ['ACCESS_KEY_ID', 'SECRET_ACCESS_KEY'] ''' -import traceback from ansible.module_utils.basic import AnsibleModule, missing_required_lib from ansible.module_utils.api import basic_auth_argument_spec -GITLAB_IMP_ERR = None -try: - import gitlab # noqa: F401, pylint: disable=unused-import - HAS_GITLAB_PACKAGE = True -except Exception: - GITLAB_IMP_ERR = traceback.format_exc() - HAS_GITLAB_PACKAGE = False from ansible_collections.community.general.plugins.module_utils.gitlab import ( - auth_argument_spec, gitlab_authentication, ensure_gitlab_package, filter_returned_variables, vars_to_variables + auth_argument_spec, gitlab_authentication, ensure_gitlab_package, filter_returned_variables, vars_to_variables, + HAS_GITLAB_PACKAGE, GITLAB_IMP_ERR ) diff --git a/plugins/modules/pubnub_blocks.py b/plugins/modules/pubnub_blocks.py index c0ece17bd8..238fadeed4 100644 --- a/plugins/modules/pubnub_blocks.py +++ b/plugins/modules/pubnub_blocks.py @@ -243,7 +243,7 @@ import os try: # Import PubNub BLOCKS client. - from pubnub_blocks_client import User, Account, Owner, Application, Keyset # noqa: F401, pylint: disable=unused-import + from pubnub_blocks_client import User from pubnub_blocks_client import Block, EventHandler from pubnub_blocks_client import exceptions HAS_PUBNUB_BLOCKS_CLIENT = True diff --git a/plugins/modules/scaleway_security_group_rule.py b/plugins/modules/scaleway_security_group_rule.py index becbc7c6b6..9cbb2eb57e 100644 --- a/plugins/modules/scaleway_security_group_rule.py +++ b/plugins/modules/scaleway_security_group_rule.py @@ -22,8 +22,6 @@ description: extends_documentation_fragment: - community.general.scaleway - community.general.attributes -requirements: - - ipaddress attributes: check_mode: @@ -137,19 +135,8 @@ data: } ''' -import traceback - from ansible_collections.community.general.plugins.module_utils.scaleway import SCALEWAY_LOCATION, scaleway_argument_spec, Scaleway, payload_from_object -from ansible.module_utils.basic import AnsibleModule, missing_required_lib - -try: - from ipaddress import ip_network # noqa: F401, pylint: disable=unused-import -except ImportError: - IPADDRESS_IMP_ERR = traceback.format_exc() - HAS_IPADDRESS = False -else: - IPADDRESS_IMP_ERR = None - HAS_IPADDRESS = True +from ansible.module_utils.basic import AnsibleModule def get_sgr_from_api(security_group_rules, security_group_rule): @@ -272,8 +259,6 @@ def main(): argument_spec=argument_spec, supports_check_mode=True, ) - if not HAS_IPADDRESS: - module.fail_json(msg=missing_required_lib('ipaddress'), exception=IPADDRESS_IMP_ERR) core(module) diff --git a/plugins/modules/xenserver_guest_info.py b/plugins/modules/xenserver_guest_info.py index b61ba44968..3062fd34c0 100644 --- a/plugins/modules/xenserver_guest_info.py +++ b/plugins/modules/xenserver_guest_info.py @@ -151,12 +151,6 @@ instance: } ''' -HAS_XENAPI = False -try: - import XenAPI # noqa: F401, pylint: disable=unused-import - HAS_XENAPI = True -except ImportError: - pass from ansible.module_utils.basic import AnsibleModule from ansible_collections.community.general.plugins.module_utils.xenserver import (xenserver_common_argument_spec, XenServerObject, get_object_ref, diff --git a/plugins/modules/xenserver_guest_powerstate.py b/plugins/modules/xenserver_guest_powerstate.py index c270a999d4..cfb1c5157e 100644 --- a/plugins/modules/xenserver_guest_powerstate.py +++ b/plugins/modules/xenserver_guest_powerstate.py @@ -177,12 +177,6 @@ instance: } ''' -HAS_XENAPI = False -try: - import XenAPI # noqa: F401, pylint: disable=unused-import - HAS_XENAPI = True -except ImportError: - pass from ansible.module_utils.basic import AnsibleModule from ansible_collections.community.general.plugins.module_utils.xenserver import (xenserver_common_argument_spec, XenServerObject, get_object_ref,