diff --git a/pylint/pyreverse/writer.py b/pylint/pyreverse/writer.py index 093c459598..4168a975db 100644 --- a/pylint/pyreverse/writer.py +++ b/pylint/pyreverse/writer.py @@ -169,10 +169,27 @@ def get_package_properties(self, obj: PackageEntity) -> NodeProperties: def get_class_properties(self, obj: ClassEntity) -> NodeProperties: """Get label and shape for classes.""" + attrs = obj.attrs if not self.config.only_classnames else None + methods = obj.methods if not self.config.only_classnames else None + + if attrs and hasattr(obj.node, "properties"): + formatted_attrs = [] + property_names = {prop.name for prop in obj.node.properties} + + for attr in attrs: + name = attr.split(":")[0].strip() + if name in property_names: + # Get type from instance_attrs_type + prop_type = obj.node.instance_attrs_type.get(name, ["Unknown"])[0] + formatted_attrs.append(f"{name} «property»: {prop_type}") + else: + formatted_attrs.append(attr) + attrs = formatted_attrs + properties = NodeProperties( label=obj.title, - attrs=obj.attrs if not self.config.only_classnames else None, - methods=obj.methods if not self.config.only_classnames else None, + attrs=attrs, + methods=methods, fontcolor="red" if is_exception(obj.node) else "black", color=self.get_shape_color(obj) if self.config.colorized else "black", )