Skip to content

Commit

Permalink
Cleaned up logic based on PR review
Browse files Browse the repository at this point in the history
  • Loading branch information
yushao2 committed May 11, 2021
1 parent e8161a5 commit f54b22d
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 10 deletions.
4 changes: 0 additions & 4 deletions pylint/checkers/refactoring/recommendation_checker.py
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ def _check_consider_using_dict_items(self, node: astroid.For) -> None:
continue

value = subscript.slice
if isinstance(value, astroid.Index):
value = value.value
if (
not isinstance(value, astroid.Name)
or value.name != node.target.name
Expand Down Expand Up @@ -198,8 +196,6 @@ def visit_comprehension(self, node: astroid.Comprehension) -> None:
continue

value = subscript.slice
if isinstance(value, astroid.Index):
value = value.value
if (
not isinstance(value, astroid.Name)
or value.name != node.target.name
Expand Down
11 changes: 5 additions & 6 deletions pylint/checkers/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -1504,12 +1504,11 @@ def get_iterating_dictionary_name(
or a dictionary itself, this returns None.
"""
# Is it a proper keys call?
if isinstance(node.iter, astroid.Call):
if (
isinstance(node.iter.func, astroid.Name)
or node.iter.func.attrname != "keys"
):
return None
if (
isinstance(node.iter, astroid.Call)
and isinstance(node.iter.func, astroid.Attribute)
and node.iter.func.attrname == "keys"
):
inferred = safe_infer(node.iter.func)
if not isinstance(inferred, (astroid.BoundMethod, astroid.Dict)):
return None
Expand Down

0 comments on commit f54b22d

Please sign in to comment.