From 935956b6106327b53851b61b0cc05fec88311872 Mon Sep 17 00:00:00 2001 From: Rafael Guterres Jeffman <rjeffman@redhat.com> Date: Thu, 29 Apr 2021 16:22:05 -0300 Subject: [PATCH] Fix pylint's warning `invalid-name`. --- .../module_utils/ansible_freeipa_module.py | 4 +-- plugins/modules/ipaconfig.py | 25 ++++++++----------- plugins/modules/ipadnsrecord.py | 2 +- plugins/modules/ipauser.py | 2 +- setup.cfg | 15 +++++++++++ 5 files changed, 30 insertions(+), 18 deletions(-) diff --git a/plugins/module_utils/ansible_freeipa_module.py b/plugins/module_utils/ansible_freeipa_module.py index 9a040ad0..a725af01 100644 --- a/plugins/module_utils/ansible_freeipa_module.py +++ b/plugins/module_utils/ansible_freeipa_module.py @@ -57,7 +57,7 @@ else: # FreeIPA releases. import re - class version: + class version: # pylint: disable=invalid-name @staticmethod def parse(version_str): """ @@ -460,7 +460,7 @@ else: cert = load_certificate(cert.encode('utf-8')) return cert - def DN_x500_text(text): + def DN_x500_text(text): # pylint: disable=invalid-name if hasattr(DN, "x500_text"): return DN(text).x500_text() else: diff --git a/plugins/modules/ipaconfig.py b/plugins/modules/ipaconfig.py index e97e3647..5e4a1bae 100644 --- a/plugins/modules/ipaconfig.py +++ b/plugins/modules/ipaconfig.py @@ -264,10 +264,7 @@ def config_show(module): def gen_args(params): - _args = {} - for k, v in params.items(): - if v is not None: - _args[k] = v + _args = {k: v for k, v in params.items() if v is not None} return _args @@ -434,7 +431,7 @@ def main(): rawresult = api_command_no_name(ansible_module, "config_show", {}) result = rawresult['result'] del result['dn'] - for key, v in result.items(): + for key, value in result.items(): k = reverse_field_map.get(key, key) if ansible_module.argument_spec.get(k): if k == 'ipaselinuxusermaporder': @@ -449,20 +446,20 @@ def main(): elif k == 'groupsearch': exit_args['groupsearch'] = \ result.get(key)[0].split(',') - elif isinstance(v, str) and \ + elif isinstance(value, str) and \ ansible_module.argument_spec[k]['type'] == "list": - exit_args[k] = [v] - elif isinstance(v, list) and \ + exit_args[k] = [value] + elif isinstance(value, list) and \ ansible_module.argument_spec[k]['type'] == "str": - exit_args[k] = ",".join(v) - elif isinstance(v, list) and \ + exit_args[k] = ",".join(value) + elif isinstance(value, list) and \ ansible_module.argument_spec[k]['type'] == "int": - exit_args[k] = ",".join(v) - elif isinstance(v, list) and \ + exit_args[k] = ",".join(value) + elif isinstance(value, list) and \ ansible_module.argument_spec[k]['type'] == "bool": - exit_args[k] = (v[0] == "TRUE") + exit_args[k] = (value[0] == "TRUE") else: - exit_args[k] = v + exit_args[k] = value except ipalib_errors.EmptyModlist: changed = False except Exception as e: diff --git a/plugins/modules/ipadnsrecord.py b/plugins/modules/ipadnsrecord.py index 0b998be6..1741a7a7 100644 --- a/plugins/modules/ipadnsrecord.py +++ b/plugins/modules/ipadnsrecord.py @@ -1377,7 +1377,7 @@ def define_commands_for_present_state(module, zone_name, entry, res_find): _args['idnsname'] = name _commands.append([zone_name, 'dnsrecord_add', _args]) # clean used fields from args - for f in part_fields: + for f in part_fields: # pylint: disable=invalid-name if f in args: del args[f] else: diff --git a/plugins/modules/ipauser.py b/plugins/modules/ipauser.py index 2e80811a..576fc59b 100644 --- a/plugins/modules/ipauser.py +++ b/plugins/modules/ipauser.py @@ -712,7 +712,7 @@ def check_certmapdata(data): return False i = data.find("<I>", 4) - s = data.find("<S>", i) + s = data.find("<S>", i) # pylint: disable=invalid-name issuer = data[i+3:s] subject = data[s+3:] diff --git a/setup.cfg b/setup.cfg index 4d60e31f..d06c1495 100644 --- a/setup.cfg +++ b/setup.cfg @@ -31,3 +31,18 @@ per-file-ignores = [pydocstyle] inherit = false ignore = D1,D212,D203 +[pylint.BASIC] +good-names = ex, i, j, k, Run, _, e, x, dn, cn, ip, os, unicode + +[pylint.IMPORTS] +ignored-modules = + ansible.module_utils.ansible_freeipa_module, + ipalib, ipalib.config, ipalib.constants, ipalib.krb_utils, ipalib.errors, + ipapython.ipautil, ipapython.dn, ipapython.version, ipapython.dnsutil, + ipaplatform.paths + +[pylint.REFACTORING] +max-nested-blocks = 9 + +[pylint.FORMAT] +max-line-length = 80 -- GitLab