Skip to content

Commit 209f234

Browse files
Pyreverse: Don't show multiple class association arrows (#9055)
Co-authored-by: Pierre Sassoulas <[email protected]>
1 parent 65959d3 commit 209f234

File tree

3 files changed

+8
-1
lines changed

3 files changed

+8
-1
lines changed

doc/whatsnew/fragments/9045.bugfix

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Pyreverse doesn't show multiple class association arrows anymore, but only the strongest one.
2+
3+
Refs #9045

pylint/pyreverse/writer.py

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@
99
import argparse
1010
import itertools
1111
import os
12+
from collections import defaultdict
1213
from collections.abc import Iterable
1314

1415
from astroid import modutils, nodes
@@ -133,8 +134,10 @@ def write_classes(self, diagram: ClassDiagram) -> None:
133134
rel.to_object.fig_id,
134135
type_=EdgeType.INHERITS,
135136
)
137+
associations: dict[str, set[str]] = defaultdict(set)
136138
# generate associations
137139
for rel in diagram.get_relationships("association"):
140+
associations[rel.from_object.fig_id].add(rel.to_object.fig_id)
138141
self.printer.emit_edge(
139142
rel.from_object.fig_id,
140143
rel.to_object.fig_id,
@@ -143,6 +146,8 @@ def write_classes(self, diagram: ClassDiagram) -> None:
143146
)
144147
# generate aggregations
145148
for rel in diagram.get_relationships("aggregation"):
149+
if rel.to_object.fig_id in associations[rel.from_object.fig_id]:
150+
continue
146151
self.printer.emit_edge(
147152
rel.from_object.fig_id,
148153
rel.to_object.fig_id,

tests/pyreverse/functional/class_diagrams/aggregation/fields.mmd

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@ classDiagram
2121
P --* D : x
2222
P --* E : x
2323
P --o B : x
24-
P --o C : x

0 commit comments

Comments
 (0)