Ejemplo n.º 1
0
    def _ensure_case(self, target: ast.AST) -> None:
        if not isinstance(target, ast.Name):
            return

        if not target.id or not logical.is_upper_case_name(target.id):
            return

        self._error_callback(
            naming.UpperCaseAttributeViolation(target, text=target.id), )
Ejemplo n.º 2
0
    def _ensure_case(self, node: ast.AST) -> None:
        if not isinstance(node, ast.Name):
            return

        if not node.id or not logical.is_upper_case_name(node.id):
            return

        self._error_callback(
            naming.UpperCaseAttributeViolation(node, text=node.id), )
Ejemplo n.º 3
0
    def check_attribute_name(self, node: ast.ClassDef) -> None:
        top_level_assigns = [
            sub_node for sub_node in node.body
            if isinstance(sub_node, AssignNodes)
        ]

        for assignment in top_level_assigns:
            for target in get_assign_targets(assignment):
                if not isinstance(target, ast.Name):
                    continue

                name = _get_name_from_node(target)
                if name and logical.is_upper_case_name(name):
                    self._error_callback(
                        naming.UpperCaseAttributeViolation(target,
                                                           text=name), )
 def _ensure_case(self, node: AnyAssign, name: str) -> None:
     if logical.is_upper_case_name(name):
         self._error_callback(
             naming.UpperCaseAttributeViolation(node, text=name),
         )