From f0ee21b8b2fa3b4ca97db7b243750ae55251db1d Mon Sep 17 00:00:00 2001 From: Alexei Znamensky <103110+russoz@users.noreply.github.com> Date: Mon, 26 Sep 2022 03:28:06 +1300 Subject: [PATCH] ini_file: fix lint error (#5307) * ini_file: fix lint error * add changelog fragment * remove line from sanity test ignore files --- changelogs/fragments/5307-ini_file-lint.yaml | 2 ++ plugins/modules/files/ini_file.py | 2 +- tests/sanity/ignore-2.11.txt | 1 - tests/sanity/ignore-2.12.txt | 1 - tests/sanity/ignore-2.13.txt | 1 - 5 files changed, 3 insertions(+), 4 deletions(-) create mode 100644 changelogs/fragments/5307-ini_file-lint.yaml diff --git a/changelogs/fragments/5307-ini_file-lint.yaml b/changelogs/fragments/5307-ini_file-lint.yaml new file mode 100644 index 0000000000..a1eb642356 --- /dev/null +++ b/changelogs/fragments/5307-ini_file-lint.yaml @@ -0,0 +1,2 @@ +bugfixes: + - ini_file - minor refactor fixing a python lint error (https://github.com/ansible-collections/community.general/pull/5307). diff --git a/plugins/modules/files/ini_file.py b/plugins/modules/files/ini_file.py index aaef3bb3db..ee4ad62b72 100644 --- a/plugins/modules/files/ini_file.py +++ b/plugins/modules/files/ini_file.py @@ -310,7 +310,7 @@ def do_ini(module, filename, section=None, option=None, values=None, # override option with no value to option with value if not allow_no_value if len(values) > 0: for index, line in enumerate(section_lines): - if not changed_lines[index] and match_active_opt(option, section_lines[index]): # pylint: disable=unnecessary-list-index-lookup + if not changed_lines[index] and match_active_opt(option, line): newline = assignment_format % (option, values.pop(0)) (changed, msg) = update_section_line(changed, section_lines, index, changed_lines, newline, msg) if len(values) == 0: diff --git a/tests/sanity/ignore-2.11.txt b/tests/sanity/ignore-2.11.txt index e6919b17b7..855883d64a 100644 --- a/tests/sanity/ignore-2.11.txt +++ b/tests/sanity/ignore-2.11.txt @@ -22,7 +22,6 @@ plugins/modules/cloud/univention/udm_user.py validate-modules:parameter-list-no- plugins/modules/clustering/consul/consul.py validate-modules:doc-missing-type plugins/modules/clustering/consul/consul.py validate-modules:undocumented-parameter plugins/modules/clustering/consul/consul_session.py validate-modules:parameter-state-invalid-choice -plugins/modules/files/ini_file.py pylint:bad-option-value plugins/modules/packaging/language/yarn.py use-argspec-type-path plugins/modules/packaging/os/redhat_subscription.py validate-modules:return-syntax-error plugins/modules/remote_management/manageiq/manageiq_policies.py validate-modules:parameter-state-invalid-choice diff --git a/tests/sanity/ignore-2.12.txt b/tests/sanity/ignore-2.12.txt index ae52113f15..39c97f6bf8 100644 --- a/tests/sanity/ignore-2.12.txt +++ b/tests/sanity/ignore-2.12.txt @@ -17,7 +17,6 @@ plugins/modules/cloud/univention/udm_user.py validate-modules:parameter-list-no- plugins/modules/clustering/consul/consul.py validate-modules:doc-missing-type plugins/modules/clustering/consul/consul.py validate-modules:undocumented-parameter plugins/modules/clustering/consul/consul_session.py validate-modules:parameter-state-invalid-choice -plugins/modules/files/ini_file.py pylint:bad-option-value plugins/modules/packaging/language/yarn.py use-argspec-type-path plugins/modules/packaging/os/redhat_subscription.py validate-modules:return-syntax-error plugins/modules/remote_management/manageiq/manageiq_policies.py validate-modules:parameter-state-invalid-choice diff --git a/tests/sanity/ignore-2.13.txt b/tests/sanity/ignore-2.13.txt index ae52113f15..39c97f6bf8 100644 --- a/tests/sanity/ignore-2.13.txt +++ b/tests/sanity/ignore-2.13.txt @@ -17,7 +17,6 @@ plugins/modules/cloud/univention/udm_user.py validate-modules:parameter-list-no- plugins/modules/clustering/consul/consul.py validate-modules:doc-missing-type plugins/modules/clustering/consul/consul.py validate-modules:undocumented-parameter plugins/modules/clustering/consul/consul_session.py validate-modules:parameter-state-invalid-choice -plugins/modules/files/ini_file.py pylint:bad-option-value plugins/modules/packaging/language/yarn.py use-argspec-type-path plugins/modules/packaging/os/redhat_subscription.py validate-modules:return-syntax-error plugins/modules/remote_management/manageiq/manageiq_policies.py validate-modules:parameter-state-invalid-choice