Closed
Description
Steps to reproduce
reproducer.py:
"""false positive: bad-reversed-sequence"""
x = {'hello': 'world'}
for key in reversed(x):
print(key)
> pylint reproducer.py
************* Module reproducer
reproducer.py:3:11: E0111: The first reversed() argument is not a sequence (bad-reversed-sequence)
Current behavior
Using a dictionary with reversed() causes a bad-reversed-sequence error to be emitted.
Expected behavior
This is fine in Python 3.7 and up, where dictionaries have a known order. Though they are not Sequence types as such, they do implement the __reversed__
method.
pylint --version output
pylint 2.6.0
astroid 2.4.2
Python 3.8.6 (default, Sep 25 2020, 00:00:00)
[GCC 10.2.1 20200723 (Red Hat 10.2.1-1)]