diff options
author | PHeanEX <github@pheanex.de> | 2019-07-12 19:15:03 +0200 |
---|---|---|
committer | Claudiu Popa <pcmanticore@gmail.com> | 2019-07-16 07:55:08 +0200 |
commit | 0a6b0c54a042d8f9156ed4077951dfbd67ecdbb5 (patch) | |
tree | 4dab9268f30683ea36afb4fdd9ff7ff971a00bd5 /pylint/checkers/refactoring.py | |
parent | 18d9e992b341312e22a956a7eb1ea49e0f8f4a06 (diff) | |
download | pylint-git-0a6b0c54a042d8f9156ed4077951dfbd67ecdbb5.tar.gz |
blacken the code
I mean its ugly now, but if you want it like that: Here you go
Diffstat (limited to 'pylint/checkers/refactoring.py')
-rw-r--r-- | pylint/checkers/refactoring.py | 53 |
1 files changed, 36 insertions, 17 deletions
diff --git a/pylint/checkers/refactoring.py b/pylint/checkers/refactoring.py index f6a5c927e..ae91c1110 100644 --- a/pylint/checkers/refactoring.py +++ b/pylint/checkers/refactoring.py @@ -272,7 +272,7 @@ class RefactoringChecker(checkers.BaseTokenChecker): "Instead of using an identitiy comprehension, " "consider using the list, dict or set constructor. " "It is faster and simpler.", - ) + ), } options = ( ( @@ -976,30 +976,49 @@ class RefactoringChecker(checkers.BaseTokenChecker): self._check_unnecessary_comprehension(node) def _check_unnecessary_comprehension(self, node): - if (isinstance(node.parent, astroid.GeneratorExp) - or len(node.ifs) != 0 - or len(node.parent.generators) != 1 - or node.is_async): + if ( + isinstance(node.parent, astroid.GeneratorExp) + or len(node.ifs) != 0 + or len(node.parent.generators) != 1 + or node.is_async + ): return - if (isinstance(node.parent, astroid.DictComp) - and isinstance(node.parent.key, astroid.Name) - and isinstance(node.parent.value, astroid.Name) - and isinstance(node.target, astroid.Tuple) - and all(isinstance(elt, astroid.AssignName) - for elt in node.target.elts)): + if ( + isinstance(node.parent, astroid.DictComp) + and isinstance(node.parent.key, astroid.Name) + and isinstance(node.parent.value, astroid.Name) + and isinstance(node.target, astroid.Tuple) + and all(isinstance(elt, astroid.AssignName) for elt in node.target.elts) + ): expr_list = [node.parent.key.name, node.parent.value.name] target_list = [elt.name for elt in node.target.elts] 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 []) + 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 [] + ) + ) target = node.parent.generators[0].target - target_list = target.name if isinstance(target, astroid.AssignName) else ( - [elt.name for elt in target.elts if isinstance(elt, astroid.AssignName)] - if isinstance(target, astroid.Tuple) else []) + target_list = ( + target.name + if isinstance(target, astroid.AssignName) + else ( + [ + elt.name + for elt in target.elts + if isinstance(elt, astroid.AssignName) + ] + if isinstance(target, astroid.Tuple) + else [] + ) + ) else: return if expr_list == target_list != []: |