From 435459a3ed0e2de14d93ef9d7659a1a3dee156b3 Mon Sep 17 00:00:00 2001 From: Laura M?dioni Date: Mon, 30 Nov 2015 09:28:59 +0100 Subject: fix elif-used rule The bug was introduced when porting the rule from pylint core to an extension --- pylint/extensions/check_elif.py | 22 ++++------------------ 1 file changed, 4 insertions(+), 18 deletions(-) diff --git a/pylint/extensions/check_elif.py b/pylint/extensions/check_elif.py index e9f2dfa..11521ec 100644 --- a/pylint/extensions/check_elif.py +++ b/pylint/extensions/check_elif.py @@ -25,27 +25,13 @@ class ElseifUsedChecker(BaseTokenChecker): self._elifs = [] self._if_counter = 0 - def _is_actual_elif(self, node): - """Check if the given node is an actual elif - - This is a problem we're having with the builtin ast module, - which splits `elif` branches into a separate if statement. - Unfortunately we need to know the exact type in certain - cases. - """ - - if isinstance(node.parent, astroid.If): - orelse = node.parent.orelse - # current if node must directly follow a "else" - if orelse and orelse == [node]: - if self._elifs[self._if_counter]: - return True - return False - def process_tokens(self, tokens): # Process tokens and look for 'if' or 'elif' for _, token, _, _, _ in tokens: - self._elifs.append(True if token == 'elif' else False) + if token == 'elif': + self._elifs.append(True) + elif token == 'if': + self._elifs.append(False) def leave_module(self, _): self._init() -- cgit v1.2.1