Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions doc/whatsnew/fragments/9045.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Pyreverse doesn't show multiple class association arrows anymore, but only the strongest one.

Refs #9045
5 changes: 5 additions & 0 deletions pylint/pyreverse/writer.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
import argparse
import itertools
import os
from collections import defaultdict
from collections.abc import Iterable

from astroid import modutils, nodes
Expand Down Expand Up @@ -133,8 +134,10 @@ def write_classes(self, diagram: ClassDiagram) -> None:
rel.to_object.fig_id,
type_=EdgeType.INHERITS,
)
associations: dict[str, set[str]] = defaultdict(set)
# generate associations
for rel in diagram.get_relationships("association"):
associations[rel.from_object.fig_id].add(rel.to_object.fig_id)
self.printer.emit_edge(
rel.from_object.fig_id,
rel.to_object.fig_id,
Expand All @@ -143,6 +146,8 @@ def write_classes(self, diagram: ClassDiagram) -> None:
)
# generate aggregations
for rel in diagram.get_relationships("aggregation"):
if rel.to_object.fig_id in associations[rel.from_object.fig_id]:
continue
self.printer.emit_edge(
rel.from_object.fig_id,
rel.to_object.fig_id,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,4 +21,3 @@ classDiagram
P --* D : x
P --* E : x
P --o B : x
P --o C : x