summaryrefslogtreecommitdiff
path: root/venv/Lib/site-packages/pylint/extensions/check_elif.py
diff options
context:
space:
mode:
authorpravindalve2023-05-30 04:20:14 +0530
committerGitHub2023-05-30 04:20:14 +0530
commitcbdd7ca21f1f673a3a739065098f7cc6c9c4b881 (patch)
tree595e888c38f00a314e751096b6bf636a544a5efe /venv/Lib/site-packages/pylint/extensions/check_elif.py
parent7740d1ca0c2e6bf34900460b0c58fa4d528577fb (diff)
parent280c6aa89a15331fb76b7014957953dc72af6093 (diff)
downloadChemical-Simulator-GUI-master.tar.gz
Chemical-Simulator-GUI-master.tar.bz2
Chemical-Simulator-GUI-master.zip
Merge pull request #63 from brenda-br/Fix-35HEADmaster
Restructure Project and Deployment
Diffstat (limited to 'venv/Lib/site-packages/pylint/extensions/check_elif.py')
-rw-r--r--venv/Lib/site-packages/pylint/extensions/check_elif.py77
1 files changed, 0 insertions, 77 deletions
diff --git a/venv/Lib/site-packages/pylint/extensions/check_elif.py b/venv/Lib/site-packages/pylint/extensions/check_elif.py
deleted file mode 100644
index 67555b1..0000000
--- a/venv/Lib/site-packages/pylint/extensions/check_elif.py
+++ /dev/null
@@ -1,77 +0,0 @@
-# -*- coding: utf-8 -*-
-# Copyright (c) 2015 LOGILAB S.A. (Paris, FRANCE) <contact@logilab.fr>
-# Copyright (c) 2016-2017 Claudiu Popa <pcmanticore@gmail.com>
-# Copyright (c) 2016 Glenn Matthews <glmatthe@cisco.com>
-# Copyright (c) 2018 Ville Skyttä <ville.skytta@upcloud.com>
-
-# Licensed under the GPL: https://www.gnu.org/licenses/old-licenses/gpl-2.0.html
-# For details: https://github.com/PyCQA/pylint/blob/master/COPYING
-
-import astroid
-
-from pylint.checkers import BaseTokenChecker
-from pylint.checkers.utils import check_messages
-from pylint.interfaces import IAstroidChecker, ITokenChecker
-
-
-class ElseifUsedChecker(BaseTokenChecker):
- """Checks for use of "else if" when an "elif" could be used
- """
-
- __implements__ = (ITokenChecker, IAstroidChecker)
- name = "else_if_used"
- msgs = {
- "R5501": (
- 'Consider using "elif" instead of "else if"',
- "else-if-used",
- "Used when an else statement is immediately followed by "
- "an if statement and does not contain statements that "
- "would be unrelated to it.",
- )
- }
-
- def __init__(self, linter=None):
- BaseTokenChecker.__init__(self, linter)
- self._init()
-
- def _init(self):
- self._elifs = []
- self._if_counter = 0
-
- def process_tokens(self, tokens):
- # Process tokens and look for 'if' or 'elif'
- for _, token, _, _, _ in tokens:
- if token == "elif":
- self._elifs.append(True)
- elif token == "if":
- self._elifs.append(False)
-
- def leave_module(self, _):
- self._init()
-
- def visit_ifexp(self, node):
- if isinstance(node.parent, astroid.FormattedValue):
- return
- self._if_counter += 1
-
- def visit_comprehension(self, node):
- self._if_counter += len(node.ifs)
-
- @check_messages("else-if-used")
- def visit_if(self, node):
- if isinstance(node.parent, astroid.If):
- orelse = node.parent.orelse
- # current if node must directly follow an "else"
- if orelse and orelse == [node]:
- if not self._elifs[self._if_counter]:
- self.add_message("else-if-used", node=node)
- self._if_counter += 1
-
-
-def register(linter):
- """Required method to auto register this checker.
-
- :param linter: Main interface object for Pylint plugins
- :type linter: Pylint object
- """
- linter.register_checker(ElseifUsedChecker(linter))