From f6b5b793c8a13c2f510431801afb1020c7f0b96e Mon Sep 17 00:00:00 2001 From: "patchback[bot]" <45432694+patchback[bot]@users.noreply.github.com> Date: Fri, 14 Jul 2023 07:41:55 +0200 Subject: [PATCH] [PR #6927/4b382ed1 backport][stable-7] remove pylint exceptions (#6929) remove pylint exceptions (#6927) * remove pylint exceptions * add changelog frag (cherry picked from commit 4b382ed1df8d3e8f9add8cb474acb625321301b9) Co-authored-by: Alexei Znamensky <103110+russoz@users.noreply.github.com> --- changelogs/fragments/6927-pylint-comments.yml | 3 +++ plugins/modules/copr.py | 6 +++--- plugins/modules/gitlab_runner.py | 9 +-------- plugins/modules/keyring.py | 4 ++-- 4 files changed, 9 insertions(+), 13 deletions(-) create mode 100644 changelogs/fragments/6927-pylint-comments.yml diff --git a/changelogs/fragments/6927-pylint-comments.yml b/changelogs/fragments/6927-pylint-comments.yml new file mode 100644 index 0000000000..495a12eb5a --- /dev/null +++ b/changelogs/fragments/6927-pylint-comments.yml @@ -0,0 +1,3 @@ +minor_changes: + - gitlab_runner - minor refactor removing unnecessary code statements (https://github.com/ansible-collections/community.general/pull/6927). + - keyring - minor refactor removing unnecessary code statements (https://github.com/ansible-collections/community.general/pull/6927). diff --git a/plugins/modules/copr.py b/plugins/modules/copr.py index f60a7b6e66..157a6c1605 100644 --- a/plugins/modules/copr.py +++ b/plugins/modules/copr.py @@ -100,9 +100,9 @@ except ImportError: from ansible.module_utils.common import respawn from ansible.module_utils.six.moves.urllib.error import HTTPError from ansible.module_utils.basic import missing_required_lib -from ansible.module_utils import distro # pylint: disable=import-error -from ansible.module_utils.basic import AnsibleModule # pylint: disable=import-error -from ansible.module_utils.urls import open_url # pylint: disable=import-error +from ansible.module_utils import distro +from ansible.module_utils.basic import AnsibleModule +from ansible.module_utils.urls import open_url def _respawn_dnf(): diff --git a/plugins/modules/gitlab_runner.py b/plugins/modules/gitlab_runner.py index 2bfb3bf3d7..4bcbedda11 100644 --- a/plugins/modules/gitlab_runner.py +++ b/plugins/modules/gitlab_runner.py @@ -210,13 +210,6 @@ from ansible_collections.community.general.plugins.module_utils.gitlab import ( ) -try: - cmp # pylint: disable=used-before-assignment -except NameError: - def cmp(a, b): - return (a > b) - (a < b) - - class GitLabRunner(object): def __init__(self, module, gitlab_instance, group=None, project=None): self._module = module @@ -302,7 +295,7 @@ class GitLabRunner(object): list1.sort() list2 = arguments[arg_key] list2.sort() - if cmp(list1, list2): + if list1 != list2: setattr(runner, arg_key, arguments[arg_key]) changed = True else: diff --git a/plugins/modules/keyring.py b/plugins/modules/keyring.py index ada22ed581..8329b727bd 100644 --- a/plugins/modules/keyring.py +++ b/plugins/modules/keyring.py @@ -106,7 +106,7 @@ def del_passphrase(module): try: keyring.delete_password(module.params["service"], module.params["username"]) return None - except keyring.errors.KeyringLocked as keyring_locked_err: # pylint: disable=unused-variable + except keyring.errors.KeyringLocked: delete_argument = ( 'echo "%s" | gnome-keyring-daemon --unlock\nkeyring del %s %s\n' % ( @@ -140,7 +140,7 @@ def set_passphrase(module): module.params["user_password"], ) return None - except keyring.errors.KeyringLocked as keyring_locked_err: # pylint: disable=unused-variable + except keyring.errors.KeyringLocked: set_argument = ( 'echo "%s" | gnome-keyring-daemon --unlock\nkeyring set %s %s\n%s\n' % (