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:30:43 +0200 |
commit | 8435a39c8f899fc5448cf31fa6201e641ffec8e7 (patch) | |
tree | 66a118f02f848690c5a2cecee66f8fd58457c2f1 /pylint/checkers/refactoring.py | |
parent | beab1555b4b9aa8548c9968b08ca2e940fb59c2a (diff) | |
download | pylint-git-8435a39c8f899fc5448cf31fa6201e641ffec8e7.tar.gz |
expand nested ternaries in ``unnecessary-comprehension`` to proper if statements
Diffstat (limited to 'pylint/checkers/refactoring.py')
-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 |