Esempio 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), )
Esempio 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), )
    def check_attribute_name(self, node: ast.ClassDef) -> None:
        top_level_assigns = [
            sub_node for sub_node in node.body
            if isinstance(sub_node, ast.Assign)
        ]

        for assignment in top_level_assigns:
            for target in assignment.targets:
                name = getattr(target, 'id', None)
                if logical.is_upper_case_name(name):
                    self._error_callback(
                        naming.UpperCaseAttributeViolation(target,
                                                           text=name), )
Esempio n. 4
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),
         )