pylint: Fix consider-using-dict-items

Pylint 2.9 introduced new check:
> New checker consider-using-dict-items. Emitted when iterating over
dictionary keys and then indexing the same dictionary with the key
within loop body.

Fixes: https://pagure.io/freeipa/issue/9117
Signed-off-by: Stanislav Levin <slev@altlinux.org>
Reviewed-By: Rob Crittenden <rcritten@redhat.com>
This commit is contained in:
Stanislav Levin
2021-07-29 15:29:31 +03:00
committed by Rob Crittenden
parent f9d0fc8a8c
commit 851f6d48ac
20 changed files with 84 additions and 80 deletions

View File

@@ -890,13 +890,13 @@ class help(frontend.Local):
commands = self._topics[topic][2]
else:
commands = []
for t in self._topics:
if type(self._topics[t][2]) is not dict:
for v in self._topics.values():
if not isinstance(v[2], dict):
continue
if topic not in self._topics[t][2]:
if topic not in v[2]:
continue
mcl = self._topics[t][2][topic][1]
commands = self._topics[t][2][topic][2]
mcl = v[2][topic][1]
commands = v[2][topic][2]
break
doc, _topic = self._get_topic(topic)

View File

@@ -376,9 +376,9 @@ class StateFile:
p = SafeConfigParser(interpolation=None)
p.optionxform = str
for module in self.modules:
for module, vals in self.modules.items():
p.add_section(module)
for (key, value) in self.modules[module].items():
for (key, value) in vals.items():
p.set(module, key, str(value))
with open(self._path, "w") as f: