Skip to content

Commit

Permalink
STY: SIM102
Browse files Browse the repository at this point in the history
  • Loading branch information
MartinThoma committed Sep 23, 2023
1 parent f71dd58 commit 0bb9d73
Showing 1 changed file with 21 additions and 22 deletions.
43 changes: 21 additions & 22 deletions flake8_simplify/rules/ast_call.py
Original file line number Diff line number Diff line change
Expand Up @@ -274,29 +274,28 @@ def get_sim911(node: ast.AST) -> List[Tuple[int, int, str]]:
)
errors: List[Tuple[int, int, str]] = []

if isinstance(node, ast.Call):
if isinstance(node, ast.Call) and (
isinstance(node.func, ast.Name)
and node.func.id == "zip"
and len(node.args) == 2
):
first_arg, second_arg = node.args
if (
isinstance(node.func, ast.Name)
and node.func.id == "zip"
and len(node.args) == 2
isinstance(first_arg, ast.Call)
and isinstance(first_arg.func, ast.Attribute)
and isinstance(first_arg.func.value, ast.Name)
and first_arg.func.attr == "keys"
and isinstance(second_arg, ast.Call)
and isinstance(second_arg.func, ast.Attribute)
and isinstance(second_arg.func.value, ast.Name)
and second_arg.func.attr == "values"
and first_arg.func.value.id == second_arg.func.value.id
):
first_arg, second_arg = node.args
if (
isinstance(first_arg, ast.Call)
and isinstance(first_arg.func, ast.Attribute)
and isinstance(first_arg.func.value, ast.Name)
and first_arg.func.attr == "keys"
and isinstance(second_arg, ast.Call)
and isinstance(second_arg.func, ast.Attribute)
and isinstance(second_arg.func.value, ast.Name)
and second_arg.func.attr == "values"
and first_arg.func.value.id == second_arg.func.value.id
):
errors.append(
(
node.lineno,
node.col_offset,
RULE.format(name=first_arg.func.value.id),
)
errors.append(
(
node.lineno,
node.col_offset,
RULE.format(name=first_arg.func.value.id),
)
)
return errors

0 comments on commit 0bb9d73

Please sign in to comment.