mirror of
https://salsa.debian.org/freeipa-team/freeipa.git
synced 2026-10-26 07:00:07 -05:00
pylint: Fix unnecessary-dict-index-lookup
Pylint 2.9 introduced new check:
> Emitted when iterating over the dictionary items (key-item pairs) and
accessing the value by index lookup. The value can be accessed directly
instead.
Note: in Python3 removing from dict during an iteration is not
possible even. For example,
```
cat a.py
d = {"a": 1}
for k, v in d.items():
if v is not None:
del d[k]
python3 a.py
Traceback (most recent call last):
File "/usr/src/RPM/BUILD/freeipa/a.py", line 3, in <module>
for k, v in d.items():
RuntimeError: dictionary changed size during iteration
```
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:
1 parent
139f6b63b1
commit
516adf40f8
2 files changed
+2
-4
No files matched your search
@@ -1788,7 +1788,7 @@ class LDAPAddMember(LDAPModMember):
|
||||
completed = 0
|
||||
for (attr, objs) in member_dns.items():
|
||||
for ldap_obj_name in objs:
|
||||
for m_dn in member_dns[attr][ldap_obj_name]:
|
||||
for m_dn in objs[ldap_obj_name]:
|
||||
assert isinstance(m_dn, DN)
|
||||
if not m_dn:
|
||||
continue
|
||||
|
||||
@@ -155,9 +155,7 @@ class ModificationTracker(BaseTracker):
|
||||
result = command()
|
||||
self.attrs.update(updates)
|
||||
self.attrs.update(expected_updates)
|
||||
for key, value in self.attrs.items():
|
||||
if value is None:
|
||||
del self.attrs[key]
|
||||
self.attrs = {k: v for k, v in self.attrs.items() if v is not None}
|
||||
|
||||
self.check_update(
|
||||
result,
|
||||
|
||||
Reference in new issue
Block a user