Ejemplo n.º 1
0
    def _ensure_underscores(self, node: ast.AST, name: str):
        if access.is_private(name):
            self._error_callback(
                naming.PrivateNameViolation(node, text=name),
            )

        if logical.does_contain_underscored_number(name):
            self._error_callback(
                naming.UnderscoredNumberNameViolation(node, text=name),
            )

        if logical.does_contain_consecutive_underscores(name):
            self._error_callback(
                naming.ConsecutiveUnderscoresInNameViolation(
                    node, text=name,
                ),
            )

        if builtins.is_wrong_alias(name):
            self._error_callback(
                naming.TrailingUnderscoreViolation(node, text=name),
            )

        if access.is_unused(name) and len(name) > 1:
            self._error_callback(
                naming.WrongUnusedVariableNameViolation(node, text=name),
            )
    def _check_module_name_pattern(self) -> None:
        if alphabet.does_contain_consecutive_underscores(self.stem):
            self.add_violation(
                naming.ConsecutiveUnderscoresInNameViolation(text=self.stem), )

        if alphabet.does_contain_underscored_number(self.stem):
            self.add_violation(
                naming.UnderscoredNumberNameViolation(text=self.stem), )
    def _ensure_underscores(self, node: ast.AST, name: str):
        if access.is_private(name):
            self._error_callback(naming.PrivateNameViolation(node,
                                                             text=name), )

        if logical.does_contain_underscored_number(name):
            self._error_callback(
                naming.UnderscoredNumberNameViolation(node, text=name), )

        if logical.does_contain_consecutive_underscores(name):
            self._error_callback(
                naming.ConsecutiveUnderscoresInNameViolation(
                    node,
                    text=name,
                ), )