Skip to content

Commit

Permalink
remove noqa exceptions (ansible-collections#6928)
Browse files Browse the repository at this point in the history
* remove noqa exceptions

* add changelog frag

* review from PR
  • Loading branch information
russoz authored and valeriopoggi committed Jul 17, 2023
1 parent 9f2c8e2 commit 644f5fd
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 38 deletions.
6 changes: 6 additions & 0 deletions changelogs/fragments/6928-noqa-comments.yml
Original file line number Diff line number Diff line change
@@ -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).
11 changes: 2 additions & 9 deletions plugins/modules/gitlab_project_variable.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,20 +181,13 @@
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
)


Expand Down
2 changes: 1 addition & 1 deletion plugins/modules/pubnub_blocks.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@

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
Expand Down
17 changes: 1 addition & 16 deletions plugins/modules/scaleway_security_group_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,8 +22,6 @@
extends_documentation_fragment:
- community.general.scaleway
- community.general.attributes
requirements:
- ipaddress
attributes:
check_mode:
Expand Down Expand Up @@ -137,19 +135,8 @@
}
'''

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):
Expand Down Expand Up @@ -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)

Expand Down
6 changes: 0 additions & 6 deletions plugins/modules/xenserver_guest_info.py
Original file line number Diff line number Diff line change
Expand Up @@ -151,12 +151,6 @@
}
'''

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,
Expand Down
6 changes: 0 additions & 6 deletions plugins/modules/xenserver_guest_powerstate.py
Original file line number Diff line number Diff line change
Expand Up @@ -177,12 +177,6 @@
}
'''

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,
Expand Down

0 comments on commit 644f5fd

Please sign in to comment.