Skip to content

Commit

Permalink
Removed redundant logic from consider-using-dict-items (#4486)
Browse files Browse the repository at this point in the history
  • Loading branch information
yushao2 committed May 21, 2021
1 parent 55d3cb7 commit 0978e09
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions pylint/checkers/refactoring/recommendation_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ class RecommendationChecker(checkers.BaseChecker):
"Consider iterating with .items()",
"consider-using-dict-items",
"Emitted when iterating over the keys of a dictionary and accessing the "
"value by index lookup."
"value by index lookup. "
"Both the key and value can be accessed by iterating using the .items() "
"method of the dictionary instead.",
),
Expand Down Expand Up @@ -188,10 +188,7 @@ def visit_comprehension(self, node: astroid.Comprehension) -> None:
if iterating_object_name is None:
return

children = list(node.parent.get_children())
if node.ifs:
children.extend(node.ifs)
for child in children:
for child in node.parent.get_children():
for subscript in child.nodes_of_class(astroid.Subscript):
subscript = cast(astroid.Subscript, subscript)

Expand Down

0 comments on commit 0978e09

Please sign in to comment.