Open EmmanuelMess opened 8 months ago
I think this is expected behaviour and is documented as such: https://pylint.pycqa.org/en/stable/user_guide/messages/convention/consider-iterating-dictionary.html
Emitted when the keys of a dictionary are iterated through the .keys()
method or when .keys()
is used for a membership check..
Perhaps the content of the message could be updated to not necessarily mention iteration; what do you think @EmmanuelMess ? Edit: Perhaps something like: "Use of .keys()
is not required here"?
Perhaps the content of the message could be updated to not necessarily mention iteration; what do you think @EmmanuelMess ? Edit: Perhaps something like: "Use of .keys() is not required here"?
That would make it more clear, yes. As it is worded now makes little sense in this context.
Thanks! The name ‘consider-iterating-dict’ could also be updated so I’ll remove the ‘needs pr’ label until there is interest in that also from others.
Bug description
Similar to #5478
/tmp/test.py:
Generates
consider-iterating-dictionary
:Configuration
No response
Command used
Pylint output
Expected behavior
The error should not appear, that is an
if
, not a loop.Pylint version
OS / Environment
Ubuntu 22.04
Additional dependencies