diff options
author | RĂ©mi Cardona <remi.cardona@polyconseil.fr> | 2019-09-30 17:57:26 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-10-03 09:31:06 +0200 |
commit | 252efa1675d7659457740171e9a147318df094a6 (patch) | |
tree | 03a0648f7b139e2273daff5b2a7da5a3f739b340 | |
parent | f7850aa8d9403d86e7f6d16a8974736180b043f2 (diff) | |
download | pylint-git-252efa1675d7659457740171e9a147318df094a6.tar.gz |
expand nested ternaries in ``unnecessary-comprehension`` to proper if statements
-rw-r--r-- | pylint/checkers/refactoring.py | 15 |
1 files changed, 6 insertions, 9 deletions
diff --git a/pylint/checkers/refactoring.py b/pylint/checkers/refactoring.py index e63d18081..0d2c6d7a0 100644 --- a/pylint/checkers/refactoring.py +++ b/pylint/checkers/refactoring.py @@ -1047,15 +1047,12 @@ class RefactoringChecker(checkers.BaseTokenChecker): elif isinstance(node.parent, (astroid.ListComp, astroid.SetComp)): expr = node.parent.elt - expr_list = ( - expr.name - if isinstance(expr, astroid.Name) - else ( - [elt.name for elt in expr.elts if isinstance(elt, astroid.Name)] - if isinstance(expr, astroid.Tuple) - else [] - ) - ) + if isinstance(expr, astroid.Name): + expr_list = expr.name + elif isinstance(expr, astroid.Tuple): + expr_list = [elt.name for elt in expr.elts if isinstance(elt, astroid.Name)] + else: + expr_list = [] target = node.parent.generators[0].target target_list = ( target.name |