Module rulebook-pylint.rulebook_pylint.unnecessary_switch
Functions
def register(linter: PyLinter)
-
Expand source code
def register(linter: 'PyLinter') -> None: linter.register_checker(UnnecessarySwitchChecker(linter))
Classes
class UnnecessarySwitchChecker (linter: PyLinter)
-
Expand source code
class UnnecessarySwitchChecker(RulebookChecker): """See detail: https://hanggrian.github.io/rulebook/rules/#unnecessary-switch""" MSG: str = 'unnecessary-switch' name: str = 'unnecessary-switch' msgs: dict[str, MessageDefinitionTuple] = Messages.of(MSG) def visit_match(self, node: Match) -> None: # checks for violation if len(node.cases) > 1: return self.add_message(self.MSG, node=node)
See detail: https://hanggrian.github.io/rulebook/rules/#unnecessary-switch
Checker instances should have the linter as argument.
Ancestors
- rulebook_pylint.checkers.RulebookChecker
- pylint.checkers.base_checker.BaseChecker
- pylint.config.arguments_provider._ArgumentsProvider
Class variables
var MSG : str
-
The type of the None singleton.
var msgs : dict[str, tuple[str, str, str] | tuple[str, str, str, pylint.typing.ExtraMessageOptions]]
-
The type of the None singleton.
var name : str
-
The type of the None singleton.
Methods
def visit_match(self, node: astroid.nodes.node_classes.Match) ‑> None
-
Expand source code
def visit_match(self, node: Match) -> None: # checks for violation if len(node.cases) > 1: return self.add_message(self.MSG, node=node)