Example #1
0
 def _ensure_super_context(self, node: ast.Call) -> None:
     parent_context = nodes.get_context(node)
     if isinstance(parent_context, FunctionNodes):
         grand_context = nodes.get_context(parent_context)
         if isinstance(grand_context, ast.ClassDef):
             return
     self.add_violation(
         WrongSuperCallViolation(node, text='not inside method'), )
    def _ensure_super_context(self, node: ast.Call) -> None:
        parent_context = nodes.get_context(node)
        parent_node = nodes.get_parent(node)

        attr = getattr(parent_node, 'attr', None)
        parent_name = getattr(parent_context, 'name', None)

        if attr and parent_name and attr != parent_name:
            self.add_violation(
                WrongSuperCallAccessViolation(
                    node,
                    text='super call with incorrect method or property access',
                ), )

        if isinstance(parent_context, FunctionNodes):
            grand_context = nodes.get_context(parent_context)
            if isinstance(grand_context, ast.ClassDef):
                return
        self.add_violation(
            WrongSuperCallViolation(node, text='not inside method'), )
Example #3
0
 def _ensure_super_arguments(self, node: ast.Call) -> None:
     if node.args or node.keywords:
         self.add_violation(
             WrongSuperCallViolation(node, text='remove arguments'),
         )