summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorClaudiu Popa <pcmanticore@gmail.com>2015-10-26 16:42:57 +0000
committerClaudiu Popa <pcmanticore@gmail.com>2015-10-26 16:42:57 +0000
commit486091452ad54d6bac7cc0100c62652e858aa8c8 (patch)
treea060738db080de85677538f50d8401d8976f9f8a
parent5ec61312c563df13c29e67dc5cb3e003f8f492f6 (diff)
downloadpylint-486091452ad54d6bac7cc0100c62652e858aa8c8.tar.gz
Simplify visit_compare, by moving the verifications for misplaced constants into their own if statement.
-rw-r--r--pylint/checkers/base.py8
1 files changed, 4 insertions, 4 deletions
diff --git a/pylint/checkers/base.py b/pylint/checkers/base.py
index cd4a81e..c9e8b75 100644
--- a/pylint/checkers/base.py
+++ b/pylint/checkers/base.py
@@ -1506,15 +1506,15 @@ class ComparisonChecker(_BasicChecker):
return
left = node.left
operator, right = node.ops[0]
+ if (operator in ('<', '<=', '>', '>=', '!=', '==')
+ and isinstance(left, astroid.Const)):
+ self._check_misplaced_constant(node, left, right, operator)
+
if operator == '==':
if isinstance(left, astroid.Const):
- self._check_misplaced_constant(node, left, right, operator)
self._check_singleton_comparison(left, node)
elif isinstance(right, astroid.Const):
self._check_singleton_comparison(right, node)
- elif (operator in ('<', '<=', '>', '>=', '!=')
- and isinstance(left, astroid.Const)):
- self._check_misplaced_constant(node, left, right, operator)
def register(linter):