diff options
author | Laura M?dioni <laura.medioni@logilab.fr> | 2015-11-30 09:28:59 +0100 |
---|---|---|
committer | Laura M?dioni <laura.medioni@logilab.fr> | 2015-11-30 09:28:59 +0100 |
commit | 435459a3ed0e2de14d93ef9d7659a1a3dee156b3 (patch) | |
tree | 7be95fa52089164614d957d75dc71389bce146fc | |
parent | b04bf8e720d65525ff7b2826c06fe92dcc608c37 (diff) | |
download | pylint-435459a3ed0e2de14d93ef9d7659a1a3dee156b3.tar.gz |
fix elif-used rule
The bug was introduced when porting the rule from pylint core to an extension
-rw-r--r-- | pylint/extensions/check_elif.py | 22 |
1 files 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() |