summaryrefslogtreecommitdiff
path: root/pylint/checkers/refactoring.py
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2018-07-08 12:02:57 +0200
committerClaudiu Popa <pcmanticore@gmail.com>2018-07-08 12:02:57 +0200
commit0d4aedafdd474cc503f744241e2d48a188302206 (patch)
tree5ac0565df0b2235c5adcd3774aa9de1045ad4abf /pylint/checkers/refactoring.py
parent2bac1d98b82fceec29a856d307b37202a2ce98a9 (diff)
downloadpylint-git-0d4aedafdd474cc503f744241e2d48a188302206.tar.gz
Do not emit consider-using-ternary when all the elements involved are a Compare node (might not be simplifiable to a ternary).
Diffstat (limited to 'pylint/checkers/refactoring.py')
-rw-r--r--pylint/checkers/refactoring.py2
1 files changed, 2 insertions, 0 deletions
diff --git a/pylint/checkers/refactoring.py b/pylint/checkers/refactoring.py
index 53ebe6326..fa24169b2 100644
--- a/pylint/checkers/refactoring.py
+++ b/pylint/checkers/refactoring.py
@@ -708,6 +708,8 @@ class RefactoringChecker(checkers.BaseTokenChecker):
suggestion = false_value.as_string()
else:
message = 'consider-using-ternary'
+ if all(isinstance(value, astroid.Compare) for value in (truth_value, false_value)):
+ return
suggestion = '{truth} if {cond} else {false}'.format(
truth=truth_value.as_string(),
cond=cond.as_string(),