Module rulebook-pylint.rulebook_pylint.duplicate_blank_line_in_block_comment

Functions

def register(linter: PyLinter)
Expand source code
def register(linter: 'PyLinter') -> None:
    linter.register_checker(DuplicateBlankLineInBlockCommentChecker(linter))

Classes

class DuplicateBlankLineInBlockCommentChecker (linter: PyLinter)
Expand source code
class DuplicateBlankLineInBlockCommentChecker(RulebookChecker):
    """See detail: https://hanggrian.github.io/rulebook/rules/#duplicate-blank-line-in-block-comment"""
    MSG: str = 'duplicate-blank-line-in-block-comment'

    name: str = 'duplicate-blank-line-in-block-comment'
    msgs: dict[str, MessageDefinitionTuple] = Messages.of(MSG)

    def visit_module(self, node: Module) -> None:
        self._process(node.doc_node)

    def visit_classdef(self, node: ClassDef) -> None:
        self._process(node.doc_node)

    def visit_functiondef(self, node: FunctionDef) -> None:
        self._process(node.doc_node)

    def _process(self, docstring: Const | None) -> None:
        # checks for violation
        if not docstring or '\n\n\n' not in docstring.value:
            return
        self.add_message(self.MSG, node=docstring)

See detail: https://hanggrian.github.io/rulebook/rules/#duplicate-blank-line-in-block-comment

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_classdef(self, node: astroid.nodes.scoped_nodes.scoped_nodes.ClassDef) ‑> None
Expand source code
def visit_classdef(self, node: ClassDef) -> None:
    self._process(node.doc_node)
def visit_functiondef(self, node: astroid.nodes.scoped_nodes.scoped_nodes.FunctionDef) ‑> None
Expand source code
def visit_functiondef(self, node: FunctionDef) -> None:
    self._process(node.doc_node)
def visit_module(self, node: astroid.nodes.scoped_nodes.scoped_nodes.Module) ‑> None
Expand source code
def visit_module(self, node: Module) -> None:
    self._process(node.doc_node)