Skip to content

Commit

Permalink
Remove hardcoded error for bad-reversed-sequence on dicts
Browse files Browse the repository at this point in the history
As a consequence, pylint will only emit `bad-reversed-sequence` on
dictionaries if below py3.8, as a `__reversed__` dunder was added to
dicts on py3.8
  • Loading branch information
ethan-leba committed Nov 29, 2020
1 parent 0847265 commit 22e805e
Showing 1 changed file with 3 additions and 6 deletions.
9 changes: 3 additions & 6 deletions pylint/checkers/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1524,14 +1524,11 @@ def _check_reversed(self, node):
return

if isinstance(argument, astroid.Instance):
if argument._proxied.name == "dict" and utils.is_builtin_object(
argument._proxied
):
self.add_message("bad-reversed-sequence", node=node)
return
if any(
ancestor.name == "dict" and utils.is_builtin_object(ancestor)
for ancestor in argument._proxied.ancestors()
for ancestor in itertools.chain(
(argument._proxied,), argument._proxied.ancestors()
)
):
# Mappings aren't accepted by reversed(), unless
# they provide explicitly a __reversed__ method.
Expand Down

0 comments on commit 22e805e

Please sign in to comment.