Module rulebook-pylint.rulebook_pylint.duplicate_blank_line
Functions
def register(linter: PyLinter)
-
Expand source code
def register(linter: 'PyLinter') -> None: linter.register_checker(DuplicateBlankLineChecker(linter))
Classes
class DuplicateBlankLineChecker (linter: PyLinter)
-
Expand source code
class DuplicateBlankLineChecker(RulebookFileChecker): """See detail: https://hanggrian.github.io/rulebook/rules/#duplicate-blank-line""" MSG: str = 'duplicate-blank-line' name: str = 'duplicate-blank-line' msgs: dict[str, MessageDefinitionTuple] = Messages.of(MSG) def process_module(self, node: Module) -> None: # checks for violation counter: int = 0 with node.stream() as stream: for (i, line) in enumerate(stream.readlines()): counter = counter + 1 if not line.strip() else 0 if counter < 3: continue self.add_message(self.MSG, line=i + 1)
See detail: https://hanggrian.github.io/rulebook/rules/#duplicate-blank-line
Checker instances should have the linter as argument.
Ancestors
- rulebook_pylint.checkers.RulebookFileChecker
- pylint.checkers.base_checker.BaseRawFileChecker
- pylint.checkers.base_checker.BaseChecker
- pylint.config.arguments_provider._ArgumentsProvider
- abc.ABC
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 process_module(self, node: astroid.nodes.scoped_nodes.scoped_nodes.Module) ‑> None
-
Expand source code
def process_module(self, node: Module) -> None: # checks for violation counter: int = 0 with node.stream() as stream: for (i, line) in enumerate(stream.readlines()): counter = counter + 1 if not line.strip() else 0 if counter < 3: continue self.add_message(self.MSG, line=i + 1)
Process a module.
The module's content is accessible via
astroid.stream