def get_methods(self, node: nodes.ClassDef) -> list[nodes.FunctionDef]: """Return visible methods.""" methods = [ m for m in node.values() if isinstance(m, nodes.FunctionDef) and not isinstance(m, astroid.objects.Property) and not decorated_with_property(m) and self.show_attr(m.name) ] return sorted(methods, key=lambda n: n.name)
def visit_classdef(self, ast: ast_node.ClassDef): self.write("class %s {" % ast.name) self.indent += 1 for instance_attrs in ast.instance_attrs.values(): for attr in instance_attrs: if isinstance(attr, ast_node.AssignAttr): attr.accept(self) break for local in ast.values(): local.accept(self) self.indent -= 1 self.write("}") for anc in ast.ancestors(recurs=False): cls = next(anc.infer()) if isinstance(cls, ast_node.ClassDef): module = cls.root().name if is_target_module(module): self.write("%s <|- %s.%s" % (ast.name, cls.root().name, cls.name))